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