Remove legacy concept of database store
This commit is contained in:
parent
1efd5725c7
commit
94544c4008
|
@ -9,7 +9,6 @@
|
||||||
views,
|
views,
|
||||||
viewsV2,
|
viewsV2,
|
||||||
userSelectedResourceMap,
|
userSelectedResourceMap,
|
||||||
database,
|
|
||||||
} from "stores/builder"
|
} from "stores/builder"
|
||||||
import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte"
|
import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte"
|
||||||
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
|
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
|
||||||
|
@ -75,69 +74,67 @@
|
||||||
searchTerm && !showAppUsersTable && !enrichedDataSources.find(ds => ds.show)
|
searchTerm && !showAppUsersTable && !enrichedDataSources.find(ds => ds.show)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database?._id}
|
<div class="hierarchy-items-container">
|
||||||
<div class="hierarchy-items-container">
|
{#if showAppUsersTable}
|
||||||
{#if showAppUsersTable}
|
<NavItem
|
||||||
<NavItem
|
icon="UserGroup"
|
||||||
icon="UserGroup"
|
text={appUsersTableName}
|
||||||
text={appUsersTableName}
|
selected={$isActive("./table/:tableId") &&
|
||||||
selected={$isActive("./table/:tableId") &&
|
$tables.selected?._id === TableNames.USERS}
|
||||||
$tables.selected?._id === TableNames.USERS}
|
on:click={() => selectTable(TableNames.USERS)}
|
||||||
on:click={() => selectTable(TableNames.USERS)}
|
selectedBy={$userSelectedResourceMap[TableNames.USERS]}
|
||||||
selectedBy={$userSelectedResourceMap[TableNames.USERS]}
|
/>
|
||||||
/>
|
{/if}
|
||||||
{/if}
|
{#each enrichedDataSources.filter(ds => ds.show) as datasource}
|
||||||
{#each enrichedDataSources.filter(ds => ds.show) as datasource}
|
<NavItem
|
||||||
<NavItem
|
border
|
||||||
border
|
text={datasource.name}
|
||||||
text={datasource.name}
|
opened={datasource.open}
|
||||||
opened={datasource.open}
|
selected={$isActive("./datasource") && datasource.selected}
|
||||||
selected={$isActive("./datasource") && datasource.selected}
|
withArrow={true}
|
||||||
withArrow={true}
|
on:click={() => selectDatasource(datasource)}
|
||||||
on:click={() => selectDatasource(datasource)}
|
on:iconClick={() => toggleNode(datasource)}
|
||||||
on:iconClick={() => toggleNode(datasource)}
|
selectedBy={$userSelectedResourceMap[datasource._id]}
|
||||||
selectedBy={$userSelectedResourceMap[datasource._id]}
|
>
|
||||||
>
|
<div class="datasource-icon" slot="icon">
|
||||||
<div class="datasource-icon" slot="icon">
|
<IntegrationIcon
|
||||||
<IntegrationIcon
|
integrationType={datasource.source}
|
||||||
integrationType={datasource.source}
|
schema={datasource.schema}
|
||||||
schema={datasource.schema}
|
size="18"
|
||||||
size="18"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
{#if datasource._id !== BUDIBASE_INTERNAL_DB_ID}
|
||||||
{#if datasource._id !== BUDIBASE_INTERNAL_DB_ID}
|
<EditDatasourcePopover {datasource} />
|
||||||
<EditDatasourcePopover {datasource} />
|
|
||||||
{/if}
|
|
||||||
</NavItem>
|
|
||||||
|
|
||||||
{#if datasource.open}
|
|
||||||
<TableNavigator tables={datasource.tables} {selectTable} />
|
|
||||||
{#each datasource.queries as query}
|
|
||||||
<NavItem
|
|
||||||
indentLevel={1}
|
|
||||||
icon="SQLQuery"
|
|
||||||
iconText={customQueryIconText(datasource, query)}
|
|
||||||
iconColor={customQueryIconColor(datasource, query)}
|
|
||||||
text={customQueryText(datasource, query)}
|
|
||||||
selected={$isActive("./query/:queryId") &&
|
|
||||||
$queries.selectedQueryId === query._id}
|
|
||||||
on:click={() => $goto(`./query/${query._id}`)}
|
|
||||||
selectedBy={$userSelectedResourceMap[query._id]}
|
|
||||||
>
|
|
||||||
<EditQueryPopover {query} />
|
|
||||||
</NavItem>
|
|
||||||
{/each}
|
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
</NavItem>
|
||||||
{#if showNoResults}
|
|
||||||
<Layout paddingY="none" paddingX="L">
|
{#if datasource.open}
|
||||||
<div class="no-results">
|
<TableNavigator tables={datasource.tables} {selectTable} />
|
||||||
There aren't any datasources matching that name
|
{#each datasource.queries as query}
|
||||||
</div>
|
<NavItem
|
||||||
</Layout>
|
indentLevel={1}
|
||||||
|
icon="SQLQuery"
|
||||||
|
iconText={customQueryIconText(datasource, query)}
|
||||||
|
iconColor={customQueryIconColor(datasource, query)}
|
||||||
|
text={customQueryText(datasource, query)}
|
||||||
|
selected={$isActive("./query/:queryId") &&
|
||||||
|
$queries.selectedQueryId === query._id}
|
||||||
|
on:click={() => $goto(`./query/${query._id}`)}
|
||||||
|
selectedBy={$userSelectedResourceMap[query._id]}
|
||||||
|
>
|
||||||
|
<EditQueryPopover {query} />
|
||||||
|
</NavItem>
|
||||||
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
{/each}
|
||||||
{/if}
|
{#if showNoResults}
|
||||||
|
<Layout paddingY="none" paddingX="L">
|
||||||
|
<div class="no-results">
|
||||||
|
There aren't any datasources matching that name
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.hierarchy-items-container {
|
.hierarchy-items-container {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
views,
|
views,
|
||||||
viewsV2,
|
viewsV2,
|
||||||
userSelectedResourceMap,
|
userSelectedResourceMap,
|
||||||
database,
|
|
||||||
} from "stores/builder"
|
} from "stores/builder"
|
||||||
import { TableNames } from "constants"
|
import { TableNames } from "constants"
|
||||||
import EditTablePopover from "./popovers/EditTablePopover.svelte"
|
import EditTablePopover from "./popovers/EditTablePopover.svelte"
|
||||||
|
@ -29,42 +28,40 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database?._id}
|
<div class="hierarchy-items-container">
|
||||||
<div class="hierarchy-items-container">
|
{#each sortedTables as table, idx}
|
||||||
{#each sortedTables as table, idx}
|
<NavItem
|
||||||
|
indentLevel={1}
|
||||||
|
border={idx > 0}
|
||||||
|
icon={table._id === TableNames.USERS ? "UserGroup" : "Table"}
|
||||||
|
text={table.name}
|
||||||
|
selected={$isActive("./table/:tableId") &&
|
||||||
|
$tablesStore.selected?._id === table._id}
|
||||||
|
on:click={() => selectTable(table._id)}
|
||||||
|
selectedBy={$userSelectedResourceMap[table._id]}
|
||||||
|
>
|
||||||
|
{#if table._id !== TableNames.USERS}
|
||||||
|
<EditTablePopover {table} />
|
||||||
|
{/if}
|
||||||
|
</NavItem>
|
||||||
|
{#each [...Object.entries(table.views || {})].sort() as [name, view], idx (idx)}
|
||||||
<NavItem
|
<NavItem
|
||||||
indentLevel={1}
|
indentLevel={2}
|
||||||
border={idx > 0}
|
icon="Remove"
|
||||||
icon={table._id === TableNames.USERS ? "UserGroup" : "Table"}
|
text={name}
|
||||||
text={table.name}
|
selected={isViewActive(view, $isActive, $views, $viewsV2)}
|
||||||
selected={$isActive("./table/:tableId") &&
|
on:click={() => {
|
||||||
$tablesStore.selected?._id === table._id}
|
if (view.version === 2) {
|
||||||
on:click={() => selectTable(table._id)}
|
$goto(`./view/v2/${encodeURIComponent(view.id)}`)
|
||||||
selectedBy={$userSelectedResourceMap[table._id]}
|
} else {
|
||||||
|
$goto(`./view/v1/${encodeURIComponent(name)}`)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
selectedBy={$userSelectedResourceMap[name] ||
|
||||||
|
$userSelectedResourceMap[view.id]}
|
||||||
>
|
>
|
||||||
{#if table._id !== TableNames.USERS}
|
<EditViewPopover {view} />
|
||||||
<EditTablePopover {table} />
|
|
||||||
{/if}
|
|
||||||
</NavItem>
|
</NavItem>
|
||||||
{#each [...Object.entries(table.views || {})].sort() as [name, view], idx (idx)}
|
|
||||||
<NavItem
|
|
||||||
indentLevel={2}
|
|
||||||
icon="Remove"
|
|
||||||
text={name}
|
|
||||||
selected={isViewActive(view, $isActive, $views, $viewsV2)}
|
|
||||||
on:click={() => {
|
|
||||||
if (view.version === 2) {
|
|
||||||
$goto(`./view/v2/${encodeURIComponent(view.id)}`)
|
|
||||||
} else {
|
|
||||||
$goto(`./view/v1/${encodeURIComponent(name)}`)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
selectedBy={$userSelectedResourceMap[name] ||
|
|
||||||
$userSelectedResourceMap[view.id]}
|
|
||||||
>
|
|
||||||
<EditViewPopover {view} />
|
|
||||||
</NavItem>
|
|
||||||
{/each}
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
{/each}
|
||||||
{/if}
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { queries, datasources, database } from "stores/builder"
|
import { queries, datasources } from "stores/builder"
|
||||||
import QueryViewer from "components/integration/QueryViewer.svelte"
|
import QueryViewer from "components/integration/QueryViewer.svelte"
|
||||||
import RestQueryViewer from "components/integration/RestQueryViewer.svelte"
|
import RestQueryViewer from "components/integration/RestQueryViewer.svelte"
|
||||||
import { IntegrationTypes } from "constants/backend"
|
import { IntegrationTypes } from "constants/backend"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
$: isRestQuery = datasource?.source === IntegrationTypes.REST
|
$: isRestQuery = datasource?.source === IntegrationTypes.REST
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database._id && query}
|
{#if query}
|
||||||
{#if isRestQuery}
|
{#if isRestQuery}
|
||||||
<RestQueryViewer queryId={$queries.selectedQueryId} />
|
<RestQueryViewer queryId={$queries.selectedQueryId} />
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import QueryViewer from "components/integration/QueryViewer.svelte"
|
import QueryViewer from "components/integration/QueryViewer.svelte"
|
||||||
import RestQueryViewer from "components/integration/RestQueryViewer.svelte"
|
import RestQueryViewer from "components/integration/RestQueryViewer.svelte"
|
||||||
import { IntegrationTypes } from "constants/backend"
|
import { IntegrationTypes } from "constants/backend"
|
||||||
import { database, datasources } from "stores/builder"
|
import { datasources } from "stores/builder"
|
||||||
|
|
||||||
$: datasource = $datasources.list.find(ds => ds._id === $params.datasourceId)
|
$: datasource = $datasources.list.find(ds => ds._id === $params.datasourceId)
|
||||||
$: {
|
$: {
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database._id && datasource && query}
|
{#if datasource && query}
|
||||||
{#if isRestQuery}
|
{#if isRestQuery}
|
||||||
<RestQueryViewer />
|
<RestQueryViewer />
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import TableDataTable from "components/backend/DataTable/TableDataTable.svelte"
|
import TableDataTable from "components/backend/DataTable/TableDataTable.svelte"
|
||||||
import { tables, database } from "stores/builder"
|
import { tables } from "stores/builder"
|
||||||
import { Banner } from "@budibase/bbui"
|
import { Banner } from "@budibase/bbui"
|
||||||
|
|
||||||
const verifyAutocolumns = table => {
|
const verifyAutocolumns = table => {
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database?._id && $tables?.selected?.name}
|
{#if $tables?.selected?.name}
|
||||||
{#if duplicates?.length}
|
{#if duplicates?.length}
|
||||||
<div class="alert-wrap">
|
<div class="alert-wrap">
|
||||||
<Banner type="warning" showCloseButton={false}>
|
<Banner type="warning" showCloseButton={false}>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import ViewDataTable from "components/backend/DataTable/ViewDataTable.svelte"
|
import ViewDataTable from "components/backend/DataTable/ViewDataTable.svelte"
|
||||||
import { views, database } from "stores/builder"
|
import { views } from "stores/builder"
|
||||||
|
|
||||||
$: selectedView = $views.selected
|
$: selectedView = $views.selected
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $database._id && selectedView}
|
{#if selectedView}
|
||||||
<ViewDataTable view={selectedView} />
|
<ViewDataTable view={selectedView} />
|
||||||
{:else}<i>Create your first table to start building</i>{/if}
|
{:else}<i>Create your first table to start building</i>{/if}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { SplitPage } from "@budibase/frontend-core"
|
import { SplitPage } from "@budibase/frontend-core"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { database } from "stores/builder"
|
|
||||||
import { auth, admin } from "stores/portal"
|
import { auth, admin } from "stores/portal"
|
||||||
|
|
||||||
let name = "My first app"
|
let name = "My first app"
|
||||||
|
@ -26,9 +25,6 @@
|
||||||
|
|
||||||
const createdApp = await API.createApp(data)
|
const createdApp = await API.createApp(data)
|
||||||
|
|
||||||
// Select Correct Application/DB in prep for creating user
|
|
||||||
database.syncAppDatabase(createdApp)
|
|
||||||
|
|
||||||
// Update checklist - in case first app
|
// Update checklist - in case first app
|
||||||
await admin.init()
|
await admin.init()
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
import { writable } from "svelte/store"
|
|
||||||
|
|
||||||
export const createDatabaseStore = () => {
|
|
||||||
const store = writable({})
|
|
||||||
|
|
||||||
const syncAppDatabase = application => {
|
|
||||||
store.set({ ...application.instance })
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe: store.subscribe,
|
|
||||||
syncAppDatabase,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const database = createDatabaseStore()
|
|
|
@ -18,7 +18,6 @@ import {
|
||||||
} from "./automations.js"
|
} from "./automations.js"
|
||||||
import { userStore, userSelectedResourceMap, isOnlyUser } from "./users.js"
|
import { userStore, userSelectedResourceMap, isOnlyUser } from "./users.js"
|
||||||
import { deploymentStore } from "./deployments.js"
|
import { deploymentStore } from "./deployments.js"
|
||||||
import { database } from "./database.js"
|
|
||||||
|
|
||||||
// Backend
|
// Backend
|
||||||
import { tables } from "./tables"
|
import { tables } from "./tables"
|
||||||
|
@ -34,7 +33,6 @@ import { flags } from "./flags"
|
||||||
|
|
||||||
export {
|
export {
|
||||||
layoutStore,
|
layoutStore,
|
||||||
database,
|
|
||||||
appStore,
|
appStore,
|
||||||
componentStore,
|
componentStore,
|
||||||
navigationStore,
|
navigationStore,
|
||||||
|
@ -104,8 +102,6 @@ export const initialise = async pkg => {
|
||||||
themeStore.syncAppTheme(application)
|
themeStore.syncAppTheme(application)
|
||||||
screenStore.syncAppScreens(pkg)
|
screenStore.syncAppScreens(pkg)
|
||||||
layoutStore.syncAppLayouts(pkg)
|
layoutStore.syncAppLayouts(pkg)
|
||||||
// required for api comms
|
|
||||||
database.syncAppDatabase(application)
|
|
||||||
resetBuilderHistory()
|
resetBuilderHistory()
|
||||||
await refreshBuilderData()
|
await refreshBuilderData()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue