moves backend stores to "stores" in the root src directory

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-26 09:50:37 +01:00
parent a40a13af93
commit 44e3f29a0b
68 changed files with 129 additions and 71 deletions

View File

@ -60,6 +60,10 @@ export default {
find: "builderStore",
replacement: path.resolve(projectRootDir, "src/builderStore"),
},
{
find: "stores",
replacement: path.resolve(projectRootDir, "src/stores"),
},
{
find: "constants",
replacement: path.resolve(projectRootDir, "src/constants"),

View File

@ -4,7 +4,7 @@ import { store } from "builderStore"
import {
tables as tablesStore,
queries as queriesStores,
} from "builderStore/store/backend/"
} from "stores/backend/"
import { findComponentPath } from "./storeUtils"
import { makePropSafe } from "@budibase/string-templates"
import { TableNames } from "../constants"

View File

@ -15,7 +15,7 @@ import {
queries,
database,
tables,
} from "builderStore/store/backend/"
} from "stores/backend/"
import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
import api from "../api"

View File

@ -24,7 +24,7 @@ export default (frontendState, tables) => {
})
const fromScratch = enrichTemplate(createFromScratchScreen)
const tableTemplates = allTemplates(tables).map(enrichTemplate)
const tableTemplates = allTemplates(tables.list).map(enrichTemplate)
return [
fromScratch,
...tableTemplates.sort((templateA, templateB) => {

View File

@ -1,7 +1,7 @@
<script>
import { processStringSync } from "@budibase/string-templates"
import { get } from "lodash/fp"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
export let block

View File

@ -1,6 +1,6 @@
<script>
import { automationStore } from "builderStore"
import { database } from 'builderStore/store/backend/'
import { database } from 'stores/backend/'
import { goto } from "@sveltech/routify"
import { notifier } from "builderStore/store/notifications"
import { Input, ModalContent } from "@budibase/bbui"

View File

@ -1,7 +1,7 @@
<script>
import { goto } from "@sveltech/routify"
import { automationStore } from "builderStore"
import { database } from 'builderStore/store/backend/'
import { database } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { DropdownMenu } from "@budibase/bbui"
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"

View File

@ -1,5 +1,5 @@
<script>
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { Select } from "@budibase/bbui"
import DrawerBindableInput from "../../common/DrawerBindableInput.svelte"
import AutomationBindingPanel from "./AutomationBindingPanel.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { automationStore } from "builderStore"
import { database } from 'builderStore/store/backend/'
import { database } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import AutomationBlockSetup from "./AutomationBlockSetup.svelte"
import { Button, Modal } from "@budibase/bbui"

View File

@ -1,5 +1,5 @@
<script>
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { Select } from "@budibase/bbui"
export let value

View File

@ -1,6 +1,6 @@
<script>
import { automationStore } from "builderStore"
import { database } from 'builderStore/store/backend/'
import { database } from 'stores/backend/'
import WebhookDisplay from "./WebhookDisplay.svelte"
import { ModalContent } from "@budibase/bbui"
import { onMount, onDestroy } from "svelte"

View File

@ -1,5 +1,5 @@
<script>
import { tables, views } from 'builderStore/store/backend/'
import { tables, views } from 'stores/backend/'
import CreateRowButton from "./buttons/CreateRowButton.svelte"
import CreateColumnButton from "./buttons/CreateColumnButton.svelte"

View File

@ -1,7 +1,7 @@
<script>
import api from "builderStore/api"
import Table from "./Table.svelte"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
export let tableId
export let rowId

View File

@ -1,6 +1,6 @@
<script>
import api from "builderStore/api"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import Table from "./Table.svelte"
import CalculateButton from "./buttons/CalculateButton.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { TextButton, Popover } from "@budibase/bbui"
import { permissions } from 'builderStore/store/backend/'
import { permissions } from 'stores/backend/'
import ManageAccessPopover from "../popovers/ManageAccessPopover.svelte"
export let resourceId

View File

@ -1,5 +1,5 @@
<script>
import { roles } from 'builderStore/store/backend/'
import { roles } from 'stores/backend/'
export let roleId

View File

@ -9,7 +9,7 @@
Radio,
} from "@budibase/bbui"
import { cloneDeep } from "lodash/fp"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
import {

View File

@ -1,5 +1,5 @@
<script>
import { tables, rows } from 'builderStore/store/backend/'
import { tables, rows } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import RowFieldControl from "../RowFieldControl.svelte"
import * as api from "../api"

View File

@ -1,6 +1,6 @@
<script>
import { tables, rows } from 'builderStore/store/backend/'
import { roles } from 'builderStore/store/backend/'
import { tables, rows } from 'stores/backend/'
import { roles } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import RowFieldControl from "../RowFieldControl.svelte"
import * as backendApi from "../api"

View File

@ -1,5 +1,5 @@
<script>
import { rows } from 'builderStore/store/backend/'
import { rows } from 'stores/backend/'
import * as api from "../api"
import { notifier } from "builderStore/store/notifications"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"

View File

@ -4,7 +4,7 @@
import api from "builderStore/api"
import { notifier } from "builderStore/store/notifications"
import ErrorsBox from "components/common/ErrorsBox.svelte"
import { roles } from 'builderStore/store/backend/'
import { roles } from 'stores/backend/'
let basePermissions = []
let selectedRole = {}

View File

@ -1,7 +1,7 @@
<script>
import { Button, Select } from "@budibase/bbui"
import { tables, views } from 'builderStore/store/backend/'
import { tables, views } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import analytics from "analytics"

View File

@ -1,8 +1,8 @@
<script>
import { Button, Input } from "@budibase/bbui"
import { goto } from "@sveltech/routify"
import { views as viewsStore } from 'builderStore/store/backend/'
import { tables } from 'builderStore/store/backend/'
import { views as viewsStore } from 'stores/backend/'
import { tables } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import analytics from "analytics"

View File

@ -1,6 +1,6 @@
<script>
import { Button, Input, Select, DatePicker } from "@budibase/bbui"
import { tables, views } from 'builderStore/store/backend/'
import { tables, views } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import analytics from "analytics"

View File

@ -1,6 +1,6 @@
<script>
import { Button, Select } from "@budibase/bbui"
import { tables, views } from 'builderStore/store/backend/'
import { tables, views } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { FIELDS } from "constants/backend"

View File

@ -1,5 +1,5 @@
<script>
import { roles, permissions as permissionsStore } from 'builderStore/store/backend/'
import { roles, permissions as permissionsStore } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { Button, Label, Input, Select, Spacer } from "@budibase/bbui"

View File

@ -1,7 +1,7 @@
<script>
import { onMount } from "svelte"
import { goto } from "@sveltech/routify"
import { database, datasources, queries } from 'builderStore/store/backend/'
import { database, datasources, queries } from 'stores/backend/'
import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte"
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
import NavItem from "components/common/NavItem.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { goto } from "@sveltech/routify"
import { datasources } from 'builderStore/store/backend/'
import { datasources } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { Input, Label, ModalContent } from "@budibase/bbui"
import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { goto } from "@sveltech/routify"
import { datasources } from 'builderStore/store/backend/'
import { datasources } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { DropdownMenu } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { goto } from "@sveltech/routify"
import { tables, views, database } from 'builderStore/store/backend/'
import { tables, views, database } from 'stores/backend/'
import { TableNames } from "constants"
import EditTablePopover from "./popovers/EditTablePopover.svelte"
import EditViewPopover from "./popovers/EditViewPopover.svelte"

View File

@ -1,7 +1,7 @@
<script>
import { goto } from "@sveltech/routify"
import { store } from "builderStore"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { Input, Label, ModalContent, Toggle } from "@budibase/bbui"
import TableDataImport from "../TableDataImport.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { store, allScreens } from "builderStore"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { DropdownMenu, Button, Input } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { goto } from "@sveltech/routify"
import { views } from 'builderStore/store/backend/'
import { views } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import { DropdownMenu, Button, Input } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"

View File

@ -1,5 +1,5 @@
<script>
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import api from "builderStore/api"
import { Select, Label, Multiselect } from "@budibase/bbui"
import { capitalise } from "../../helpers"

View File

@ -7,7 +7,7 @@
selectedAccessRole,
screenSearchString,
} from "builderStore"
import { roles } from 'builderStore/store/backend/'
import { roles } from 'stores/backend/'
import { FrontendTypes } from "constants"
import ComponentNavigationTree from "components/design/NavigationPanel/ComponentNavigationTree/index.svelte"
import Layout from "components/design/NavigationPanel/Layout.svelte"

View File

@ -1,7 +1,7 @@
<script>
import { store, allScreens } from "builderStore"
import { tables } from 'builderStore/store/backend/'
import { roles } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { roles } from 'stores/backend/'
import { Input, Select, ModalContent, Toggle } from "@budibase/bbui"
import getTemplates from "builderStore/store/screenTemplates"
import analytics from "analytics"

View File

@ -10,8 +10,8 @@
} from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { store, currentAsset } from "builderStore"
import { tables as tablesStore, queries as queriesStore } from 'builderStore/store/backend/'
import { datasources, integrations } from 'builderStore/store/backend/'
import { tables as tablesStore, queries as queriesStore } from 'stores/backend/'
import { datasources, integrations } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte"

View File

@ -1,7 +1,7 @@
<script>
import { Select, Label, Spacer } from "@budibase/bbui"
import { store, currentAsset } from "builderStore"
import { datasources, integrations, queries } from 'builderStore/store/backend/'
import { datasources, integrations, queries } from 'stores/backend/'
import { getBindableProperties } from "builderStore/dataBinding"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { Select } from "@budibase/bbui"
import { roles } from 'builderStore/store/backend/'
import { roles } from 'stores/backend/'
export let value
</script>

View File

@ -1,6 +1,6 @@
<script>
import { Select } from "@budibase/bbui"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
export let value
</script>

View File

@ -15,7 +15,7 @@
import IntegrationQueryEditor from "components/integration/index.svelte"
import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import { datasources, integrations } from 'builderStore/store/backend/'
import { datasources, integrations } from 'stores/backend/'
const PREVIEW_HEADINGS = [
{

View File

@ -2,7 +2,7 @@
import { Input, Label, TextButton } from "@budibase/bbui"
import api from "builderStore/api"
import { notifier } from "builderStore/store/notifications"
import { database } from 'builderStore/store/backend/'
import { database } from 'stores/backend/'
import analytics from "analytics"
let keys = { budibase: "" }

View File

@ -1,6 +1,6 @@
<script>
import { store, automationStore } from "builderStore"
import { roles } from 'builderStore/store/backend/'
import { roles } from 'stores/backend/'
import { Button } from "@budibase/bbui"
import SettingsLink from "components/settings/Link.svelte"
import ThemeEditorDropdown from "components/settings/ThemeEditorDropdown.svelte"

View File

@ -1,6 +1,6 @@
<script>
import { params } from "@sveltech/routify"
import { queries } from "builderStore/store/backend/"
import { queries } from "stores/backend/"
if ($params.query) {
const query = $queries.list.find(

View File

@ -1,6 +1,6 @@
<script>
import { params } from "@sveltech/routify"
import { database, queries } from 'builderStore/store/backend/'
import { database, queries } from 'stores/backend/'
import QueryInterface from "components/integration/QueryViewer.svelte"
async function fetchQueryConfig() {

View File

@ -1,6 +1,6 @@
<script>
import { params } from "@sveltech/routify"
import { datasources } from 'builderStore/store/backend/'
import { datasources } from 'stores/backend/'
if ($params.selectedDatasource) {
const datasource = $datasources.list.find(

View File

@ -1,7 +1,7 @@
<script>
import { goto, beforeUrlChange } from "@sveltech/routify"
import { Button, Heading, Body, Spacer } from "@budibase/bbui"
import { datasources, integrations, queries } from 'builderStore/store/backend/'
import { datasources, integrations, queries } from 'stores/backend/'
import { notifier } from "builderStore/store/notifications"
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
import ICONS from "components/backend/DatasourceNavigator/icons"

View File

@ -1,5 +1,5 @@
<script>
import { datasources } from 'builderStore/store/backend/'
import { datasources } from 'stores/backend/'
import { goto, leftover } from "@sveltech/routify"
import { onMount } from "svelte"

View File

@ -1,5 +1,5 @@
<script>
import { datasources, tables } from 'builderStore/store/backend/'
import { datasources, tables } from 'stores/backend/'
import { goto } from "@sveltech/routify"
import { onMount } from "svelte"

View File

@ -1,6 +1,6 @@
<script>
import { params } from "@sveltech/routify"
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
if ($params.selectedTable) {
const table = $tables.list.find(

View File

@ -1,6 +1,6 @@
<script>
import TableDataTable from "components/backend/DataTable/DataTable.svelte"
import { tables, database } from 'builderStore/store/backend/'
import { tables, database } from 'stores/backend/'
</script>
{#if $database?._id && $tables?.selected?.name}

View File

@ -1,5 +1,5 @@
<script>
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { goto, leftover } from "@sveltech/routify"
import { onMount } from "svelte"

View File

@ -1,5 +1,5 @@
<script>
import { tables } from 'builderStore/store/backend/'
import { tables } from 'stores/backend/'
import { goto } from "@sveltech/routify"
import { onMount } from "svelte"

View File

@ -1,6 +1,6 @@
<script>
import { params } from "@sveltech/routify"
import { tables, views } from 'builderStore/store/backend/'
import { tables, views } from 'stores/backend/'
if ($params.selectedView) {
let view

View File

@ -1,6 +1,6 @@
<script>
import ViewDataTable from "components/backend/DataTable/ViewDataTable"
import { views, database } from 'builderStore/store/backend/'
import { views, database } from 'stores/backend/'
$: selectedView = $views.selected
</script>

View File

@ -1,8 +1,8 @@
import { writable } from "svelte/store"
import { queries } from "./"
import api from "../../api"
import api from "builderStore/api"
function createDatasourcesStore() {
export function createDatasourcesStore(_api = api) {
const { subscribe, update, set } = writable({
list: [],
selected: null,

View File

@ -1,7 +1,8 @@
import { writable } from "svelte/store"
import api from "../../api"
import api from "builderStore/api"
function createPermissionStore() {
export function createPermissionStore() {
const { subscribe, set } = writable([])
return {

View File

@ -1,8 +1,9 @@
import { writable, get } from "svelte/store"
import { datasources, integrations } from "./"
import api from "../../api"
import api from "builderStore/api"
function createQueriesStore() {
export function createQueriesStore() {
const { subscribe, set, update } = writable({ list: [], selected: null })
return {

View File

@ -1,7 +1,8 @@
import { writable } from "svelte/store"
import api from "../../api"
import api from "builderStore/api"
function createRolesStore() {
export function createRolesStore() {
const { subscribe, set } = writable([])
return {

View File

@ -1,7 +1,7 @@
import { writable, get } from "svelte/store"
import { views } from "./"
function createRowsStore() {
export function createRowsStore() {
const { subscribe } = writable([])
return {

View File

@ -1,9 +1,10 @@
import { writable, get } from "svelte/store"
import { views } from "./"
import { cloneDeep } from "lodash/fp"
import api from "../../api"
import api from "builderStore/api"
function createTablesStore() {
export function createTablesStore() {
const store = writable({
list: [],
selected: {},

View File

@ -0,0 +1,26 @@
import { database } from "../"
describe("Backend DataSources Store", () => {
let state;
let unsub;
beforeEach(() => {
unsub = database.subscribe(s => state = s);
})
afterEach(() => {
unsub()
})
it("initialises correctly", () => {
expect(state.list, [])
})
})
const api = {
post: () => ({}),
get: () => ({}),
patch: () => ({}),
delete: () => ({}),
put: () => ({}),
}

View File

@ -0,0 +1,24 @@
import { get } from 'svelte/store'
import { createDatasourcesStore } from "../datasources"
const mockApi = {
post: () => ({}),
get: () => ({}),
patch: () => ({}),
delete: () => ({}),
put: () => ({}),
}
describe("Automation Data Object", () => {
let store
beforeEach(() => {
store = createDatasourcesStore(mockApi)
})
it("Inits properly", () => {
const value = get(store)
expect(value).toBe(true)
})
})

View File

@ -1,8 +1,8 @@
import { writable, get } from "svelte/store"
import { tables } from "./"
import api from "../../api"
import api from "builderStore/api"
function createViewsStore() {
export function createViewsStore() {
const { subscribe, update } = writable({
list: [],
selected: null,