Update to support new stores

This commit is contained in:
Andrew Kingston 2021-04-01 10:29:47 +01:00
parent 44c5c3cf87
commit 46745a757a
57 changed files with 107 additions and 275 deletions

View File

@ -1,10 +1,7 @@
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { get } from "svelte/store" import { get } from "svelte/store"
import { store } from "builderStore" import { store } from "builderStore"
import { import { tables as tablesStore, queries as queriesStores } from "stores/backend"
tables as tablesStore,
queries as queriesStores,
} from "stores/backend/"
import { findComponentPath } from "./storeUtils" import { findComponentPath } from "./storeUtils"
import { makePropSafe } from "@budibase/string-templates" import { makePropSafe } from "@budibase/string-templates"
import { TableNames } from "../constants" import { TableNames } from "../constants"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,4 @@
<script> <script>
<<<<<<< HEAD
import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore"
import { notifier } from "builderStore/store/notifications"
import * as api from "./api"
=======
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
import Table from "./Table.svelte" import Table from "./Table.svelte"
export let query = {} export let query = {}

View File

@ -1,7 +1,7 @@
<script> <script>
import api from "builderStore/api" import api from "builderStore/api"
import Table from "./Table.svelte" import Table from "./Table.svelte"
import { tables } from 'stores/backend/' import { tables } from "stores/backend"
export let tableId export let tableId
export let rowId export let rowId
@ -12,9 +12,7 @@
$: data = row?.[fieldName] ?? [] $: data = row?.[fieldName] ?? []
$: linkedTableId = data?.length ? data[0].tableId : null $: linkedTableId = data?.length ? data[0].tableId : null
$: linkedTable = $tables.list.find( $: linkedTable = $tables.list.find(table => table._id === linkedTableId)
table => table._id === linkedTableId
)
$: schema = linkedTable?.schema $: schema = linkedTable?.schema
$: table = $tables.list.find(table => table._id === tableId) $: table = $tables.list.find(table => table._id === tableId)
$: fetchData(tableId, rowId) $: fetchData(tableId, rowId)

View File

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

View File

@ -1,6 +1,6 @@
<script> <script>
import { TextButton, Popover } from "@budibase/bbui" import { TextButton, Popover } from "@budibase/bbui"
import { permissions } from 'stores/backend/' import { permissions } from "stores/backend"
import ManageAccessPopover from "../popovers/ManageAccessPopover.svelte" import ManageAccessPopover from "../popovers/ManageAccessPopover.svelte"
export let resourceId export let resourceId
@ -10,9 +10,7 @@
let resourcePermissions let resourcePermissions
async function openDropdown() { async function openDropdown() {
resourcePermissions = await permissions.forResource( resourcePermissions = await permissions.forResource(resourceId)
resourceId
)
dropdown.show() dropdown.show()
} }
</script> </script>

View File

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

View File

@ -9,7 +9,7 @@
Radio, Radio,
} from "@budibase/bbui" } from "@budibase/bbui"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { tables } from 'stores/backend/' import { tables } from "stores/backend"
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants" import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
import { import {
@ -56,9 +56,7 @@
UNEDITABLE_USER_FIELDS.includes(field.name) UNEDITABLE_USER_FIELDS.includes(field.name)
$: invalid = $: invalid =
(field.type === LINK_TYPE && !field.tableId) || (field.type === LINK_TYPE && !field.tableId) ||
Object.keys($tables.draft.schema).some( Object.keys($tables.draft.schema).some(key => key === field.name)
key => key === field.name
)
// used to select what different options can be displayed for column type // used to select what different options can be displayed for column type
$: canBeSearched = $: canBeSearched =
@ -72,11 +70,7 @@
async function saveColumn() { async function saveColumn() {
if (field.type === AUTO_COL) { if (field.type === AUTO_COL) {
field = buildAutoColumn( field = buildAutoColumn($tables.draft.name, field.name, field.subtype)
$tables.draft.name,
field.name,
field.subtype
)
} }
tables.saveField({ tables.saveField({
originalName, originalName,

View File

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

View File

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

View File

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

View File

@ -4,16 +4,14 @@
import api from "builderStore/api" import api from "builderStore/api"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import ErrorsBox from "components/common/ErrorsBox.svelte" import ErrorsBox from "components/common/ErrorsBox.svelte"
import { roles } from 'stores/backend/' import { roles } from "stores/backend"
let basePermissions = [] let basePermissions = []
let selectedRole = {} let selectedRole = {}
let errors = [] let errors = []
let builtInRoles = ["Admin", "Power", "Basic", "Public"] let builtInRoles = ["Admin", "Power", "Basic", "Public"]
$: selectedRoleId = selectedRole._id $: selectedRoleId = selectedRole._id
$: otherRoles = $roles.filter( $: otherRoles = $roles.filter(role => role._id !== selectedRoleId)
role => role._id !== selectedRoleId
)
$: isCreating = selectedRoleId == null || selectedRoleId === "" $: isCreating = selectedRoleId == null || selectedRoleId === ""
const fetchBasePermissions = async () => { const fetchBasePermissions = async () => {

View File

@ -1,7 +1,7 @@
<script> <script>
import { Button, Select } from "@budibase/bbui" import { Button, Select } from "@budibase/bbui"
import { tables, views } from 'stores/backend/' import { tables, views } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import analytics from "analytics" import analytics from "analytics"
@ -23,9 +23,7 @@
export let view = {} export let view = {}
export let onClosed export let onClosed
$: viewTable = $tables.list.find( $: viewTable = $tables.list.find(({ _id }) => _id === $views.selected.tableId)
({ _id }) => _id === $views.selected.tableId
)
$: fields = $: fields =
viewTable && viewTable &&
Object.keys(viewTable.schema).filter( Object.keys(viewTable.schema).filter(

View File

@ -1,13 +1,8 @@
<script> <script>
import { Button, Input } from "@budibase/bbui" import { Button, Input } from "@budibase/bbui"
<<<<<<< HEAD
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { views as viewsStore } from "stores/backend"
======= import { tables } from "stores/backend"
import { goto } from "@sveltech/routify"
import { views as viewsStore } from 'stores/backend/'
import { tables } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import analytics from "analytics" import analytics from "analytics"
@ -16,9 +11,7 @@
let name let name
let field let field
$: views = $tables.list.flatMap(table => $: views = $tables.list.flatMap(table => Object.keys(table.views || {}))
Object.keys(table.views || {})
)
function saveView() { function saveView() {
if (views.includes(name)) { if (views.includes(name)) {

View File

@ -1,6 +1,6 @@
<script> <script>
import { Button, Input, Select, DatePicker } from "@budibase/bbui" import { Button, Input, Select, DatePicker } from "@budibase/bbui"
import { tables, views } from 'stores/backend/' import { tables, views } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import analytics from "analytics" import analytics from "analytics"
@ -49,9 +49,7 @@
export let view = {} export let view = {}
export let onClosed export let onClosed
$: viewTable = $tables.list.find( $: viewTable = $tables.list.find(({ _id }) => _id === $views.selected.tableId)
({ _id }) => _id === $views.selected.tableId
)
$: fields = viewTable && Object.keys(viewTable.schema) $: fields = viewTable && Object.keys(viewTable.schema)
function saveView() { function saveView() {

View File

@ -1,15 +1,13 @@
<script> <script>
import { Button, Select } from "@budibase/bbui" import { Button, Select } from "@budibase/bbui"
import { tables, views } from 'stores/backend/' import { tables, views } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { FIELDS } from "constants/backend" import { FIELDS } from "constants/backend"
export let view = {} export let view = {}
export let onClosed export let onClosed
$: viewTable = $tables.list.find( $: viewTable = $tables.list.find(({ _id }) => _id === $views.selected.tableId)
({ _id }) => _id === $views.selected.tableId
)
$: fields = $: fields =
viewTable && viewTable &&
Object.entries(viewTable.schema) Object.entries(viewTable.schema)

View File

@ -1,5 +1,5 @@
<script> <script>
import { roles, permissions as permissionsStore } from 'stores/backend/' import { roles, permissions as permissionsStore } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { Button, Label, Input, Select, Spacer } from "@budibase/bbui" import { Button, Label, Input, Select, Spacer } from "@budibase/bbui"
@ -15,9 +15,7 @@
}) })
// Show updated permissions in UI: REMOVE // Show updated permissions in UI: REMOVE
permissions = await permissionsStore.forResource( permissions = await permissionsStore.forResource(resourceId)
resourceId
)
notifier.success("Updated permissions.") notifier.success("Updated permissions.")
// TODO: update permissions // TODO: update permissions
// permissions[] // permissions[]

View File

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

View File

@ -1,11 +1,6 @@
<script> <script>
<<<<<<< HEAD import { goto } from "@roxi/routify"
import { goto, params } from "@roxi/routify" import { datasources } from "stores/backend"
import { backendUiStore, store } from "builderStore"
=======
import { goto } from "@sveltech/routify"
import { datasources } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { Input, Label, ModalContent } from "@budibase/bbui" import { Input, Label, ModalContent } from "@budibase/bbui"
import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte" import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte"
@ -19,9 +14,7 @@
function checkValid(evt) { function checkValid(evt) {
const datasourceName = evt.target.value const datasourceName = evt.target.value
if ( if (
$datasources?.list.some( $datasources?.list.some(datasource => datasource.name === datasourceName)
datasource => datasource.name === datasourceName
)
) { ) {
error = `Datasource with name ${datasourceName} already exists. Please choose another name.` error = `Datasource with name ${datasourceName} already exists. Please choose another name.`
return return

View File

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

View File

@ -1,18 +1,12 @@
<script> <script>
<<<<<<< HEAD
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { tables, views, database } from "stores/backend"
=======
import { goto } from "@sveltech/routify"
import { tables, views, database } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
import { TableNames } from "constants" import { TableNames } from "constants"
import EditTablePopover from "./popovers/EditTablePopover.svelte" import EditTablePopover from "./popovers/EditTablePopover.svelte"
import EditViewPopover from "./popovers/EditViewPopover.svelte" import EditViewPopover from "./popovers/EditViewPopover.svelte"
import NavItem from "components/common/NavItem.svelte" import NavItem from "components/common/NavItem.svelte"
$: selectedView = $: selectedView = $views.selected && $views.selected.name
$views.selected && $views.selected.name
function selectTable(table) { function selectTable(table) {
tables.select(table) tables.select(table)
@ -33,7 +27,6 @@
...table.views[viewName], ...table.views[viewName],
}) })
} }
</script> </script>
{#if $database?._id} {#if $database?._id}

View File

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

View File

@ -1,12 +1,7 @@
<script> <script>
<<<<<<< HEAD
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { backendUiStore, store, allScreens } from "builderStore"
=======
import { goto } from '@sveltech/routify'
import { store, allScreens } from "builderStore" import { store, allScreens } from "builderStore"
import { tables } from 'stores/backend/' import { tables } from "stores/backend"
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { DropdownMenu, Button, Input } from "@budibase/bbui" import { DropdownMenu, Button, Input } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte"
@ -62,7 +57,8 @@
function checkValid(evt) { function checkValid(evt) {
const tableName = evt.target.value const tableName = evt.target.value
error = originalName !== tableName error =
originalName !== tableName
? `Table with name ${tableName} already exists. Please choose another name.` ? `Table with name ${tableName} already exists. Please choose another name.`
: "" : ""
} }

View File

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

View File

@ -1,5 +1,5 @@
<script> <script>
import { tables } from 'stores/backend/' import { tables } from "stores/backend"
import api from "builderStore/api" import api from "builderStore/api"
import { Select, Label, Multiselect } from "@budibase/bbui" import { Select, Label, Multiselect } from "@budibase/bbui"
import { capitalise } from "../../helpers" import { capitalise } from "../../helpers"
@ -13,9 +13,7 @@
$: linkedRows = linkedIds $: linkedRows = linkedIds
$: label = capitalise(schema.name) $: label = capitalise(schema.name)
$: linkedTableId = schema.tableId $: linkedTableId = schema.tableId
$: linkedTable = $tables.list.find( $: linkedTable = $tables.list.find(table => table._id === linkedTableId)
table => table._id === linkedTableId
)
$: fetchRows(linkedTableId) $: fetchRows(linkedTableId)
async function fetchRows(linkedTableId) { async function fetchRows(linkedTableId) {

View File

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

View File

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

View File

@ -10,8 +10,11 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { store, currentAsset } from "builderStore" import { store, currentAsset } from "builderStore"
import { tables as tablesStore, queries as queriesStore } from 'stores/backend/' import {
import { datasources, integrations } from 'stores/backend/' tables as tablesStore,
queries as queriesStore,
} from "stores/backend"
import { datasources, integrations } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte" import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte" import IntegrationQueryEditor from "components/integration/index.svelte"
@ -83,9 +86,8 @@
} }
function fetchQueryDefinition(query) { function fetchQueryDefinition(query) {
const source = $datasources.list.find( const source = $datasources.list.find(ds => ds._id === query.datasourceId)
ds => ds._id === query.datasourceId .source
).source
return $integrations[source].query[query.queryVerb] return $integrations[source].query[query.queryVerb]
} }
</script> </script>

View File

@ -1,12 +1,13 @@
<script> <script>
import { Select, Label } from "@budibase/bbui" import { Select, Label } from "@budibase/bbui"
import { store, currentAsset, backendUiStore } from "builderStore" import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend"
import { getBindableProperties } from "builderStore/dataBinding" import { getBindableProperties } from "builderStore/dataBinding"
import DrawerBindableInput from "components/common/DrawerBindableInput.svelte" import DrawerBindableInput from "components/common/DrawerBindableInput.svelte"
export let parameters export let parameters
$: tableOptions = $backendUiStore.tables || [] $: tableOptions = $tables || []
$: bindings = getBindableProperties($currentAsset, $store.selectedComponentId) $: bindings = getBindableProperties($currentAsset, $store.selectedComponentId)
</script> </script>

View File

@ -1,7 +1,7 @@
<script> <script>
import { Select, Label, Spacer } from "@budibase/bbui" import { Select, Label, Spacer } from "@budibase/bbui"
import { store, currentAsset } from "builderStore" import { store, currentAsset } from "builderStore"
import { datasources, integrations, queries } from 'stores/backend/' import { datasources, integrations, queries } from "stores/backend"
import { getBindableProperties } from "builderStore/dataBinding" import { getBindableProperties } from "builderStore/dataBinding"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte" import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte" import IntegrationQueryEditor from "components/integration/index.svelte"
@ -25,14 +25,7 @@
} }
</script> </script>
<<<<<<< HEAD
<div class="root">
<Label small>Datasource</Label>
<Select thin secondary bind:value={parameters.datasourceId}>
<option value="" />
{#each $backendUiStore.datasources as datasource}
<option value={datasource._id}>{datasource.name}</option>
=======
<Label small>Datasource</Label> <Label small>Datasource</Label>
<Select thin secondary bind:value={parameters.datasourceId}> <Select thin secondary bind:value={parameters.datasourceId}>
<option value="" /> <option value="" />
@ -49,7 +42,6 @@
<option value="" /> <option value="" />
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query} {#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
<option value={query._id}>{query.name}</option> <option value={query._id}>{query.name}</option>
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d
{/each} {/each}
</Select> </Select>

View File

@ -1,6 +1,7 @@
<script> <script>
import { Select, Label, Body } from "@budibase/bbui" import { Select, Label, Body } from "@budibase/bbui"
import { store, currentAsset, backendUiStore } from "builderStore" import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend"
import { import {
getDataProviderComponents, getDataProviderComponents,
getSchemaForDatasource, getSchemaForDatasource,
@ -14,7 +15,7 @@
$store.selectedComponentId $store.selectedComponentId
) )
$: schemaFields = getSchemaFields(parameters?.tableId) $: schemaFields = getSchemaFields(parameters?.tableId)
$: tableOptions = $backendUiStore.tables || [] $: tableOptions = $tables || []
const getSchemaFields = tableId => { const getSchemaFields = tableId => {
const { schema } = getSchemaForDatasource({ type: "table", tableId }) const { schema } = getSchemaForDatasource({ type: "table", tableId })

View File

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

View File

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

View File

@ -15,7 +15,7 @@
import IntegrationQueryEditor from "components/integration/index.svelte" import IntegrationQueryEditor from "components/integration/index.svelte"
import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte" import ExternalDataSourceTable from "components/backend/DataTable/ExternalDataSourceTable.svelte"
import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte" import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte"
import { datasources, integrations, queries } from 'stores/backend/' import { datasources, integrations, queries } from "stores/backend"
const PREVIEW_HEADINGS = [ const PREVIEW_HEADINGS = [
{ {
@ -39,9 +39,7 @@
let parameters let parameters
let data = [] let data = []
$: datasource = $datasources.list.find( $: datasource = $datasources.list.find(ds => ds._id === query.datasourceId)
ds => ds._id === query.datasourceId
)
$: query.schema = fields.reduce( $: query.schema = fields.reduce(
(acc, next) => ({ (acc, next) => ({
@ -113,10 +111,7 @@
async function saveQuery() { async function saveQuery() {
try { try {
const { _id } = await queries.save( const { _id } = await queries.save(query.datasourceId, query)
query.datasourceId,
query
)
notifier.success(`Query saved successfully.`) notifier.success(`Query saved successfully.`)
$goto(`../../${_id}`) $goto(`../../${_id}`)
} catch (err) { } catch (err) {

View File

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

View File

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

View File

@ -1,16 +1,9 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { queries } from "stores/backend"
=======
import { params } from "@sveltech/routify"
import { queries } from "stores/backend/"
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/_layout.svelte
if ($params.query) { if ($params.query) {
const query = $queries.list.find( const query = $queries.list.find(m => m._id === $params.query)
m => m._id === $params.query
)
if (query) { if (query) {
queries.select(query) queries.select(query)
} }

View File

@ -1,11 +1,6 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { database, queries } from "stores/backend"
=======
import { params } from "@sveltech/routify"
import { database, queries } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte
import QueryInterface from "components/integration/QueryViewer.svelte" import QueryInterface from "components/integration/QueryViewer.svelte"
async function fetchQueryConfig() { async function fetchQueryConfig() {

View File

@ -1,11 +1,6 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/datasource/[selectedDatasource]/_layout.svelte
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { datasources } from "stores/backend"
=======
import { params } from "@sveltech/routify"
import { datasources } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/_layout.svelte
if ($params.selectedDatasource) { if ($params.selectedDatasource) {
const datasource = $datasources.list.find( const datasource = $datasources.list.find(

View File

@ -1,16 +1,14 @@
<script> <script>
import { goto, beforeUrlChange } from "@roxi/routify" import { goto, beforeUrlChange } from "@roxi/routify"
import { Button, Heading, Body, Spacer } from "@budibase/bbui" import { Button, Heading, Body, Spacer } from "@budibase/bbui"
import { datasources, integrations, queries } from 'stores/backend/' import { datasources, integrations, queries } from "stores/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte" import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
import ICONS from "components/backend/DatasourceNavigator/icons" import ICONS from "components/backend/DatasourceNavigator/icons"
let unsaved = false let unsaved = false
$: datasource = $datasources.list.find( $: datasource = $datasources.list.find(ds => ds._id === $datasources.selected)
ds => ds._id === $datasources.selected
)
$: integration = datasource && $integrations[datasource.source] $: integration = datasource && $integrations[datasource.source]
async function saveDatasource() { async function saveDatasource() {

View File

@ -1,15 +1,11 @@
<script> <script>
import { datasources } from 'stores/backend/' import { datasources } from "stores/backend"
import { goto, leftover } from "@sveltech/routify" import { goto, leftover } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
onMount(async () => { onMount(async () => {
// navigate to first datasource in list, if not already selected // navigate to first datasource in list, if not already selected
if ( if (!$leftover && $datasources.list.length > 0 && !$datasources.selected) {
!$leftover &&
$datasources.list.length > 0 &&
!$datasources.selected
) {
$goto(`./${$datasources.list[0]._id}`) $goto(`./${$datasources.list[0]._id}`)
} }
}) })

View File

@ -1,17 +1,15 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/datasource/index.svelte import { datasources, tables } from "stores/backend"
import { backendUiStore } from "builderStore"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
onMount(async () => { onMount(async () => {
// navigate to first table in list, if not already selected // navigate to first table in list, if not already selected
$backendUiStore.datasources.length > 0 && $datasources.list.length > 0 && $goto(`../${$datasources.list[0]._id}`)
$goto(`./${$backendUiStore.datasources[0]._id}`)
}) })
</script> </script>
{#if $backendUiStore.tables.length === 0} {#if $tables.list.length === 0}
<i>Connect your first datasource to start building.</i> <i>Connect your first datasource to start building.</i>
{:else}<i>Select a datasource to edit</i>{/if} {:else}<i>Select a datasource to edit</i>{/if}
@ -22,26 +20,3 @@
margin-top: 2px; margin-top: 2px;
} }
</style> </style>
=======
import { datasources, tables } from 'stores/backend/'
import { goto } from "@sveltech/routify"
import { onMount } from "svelte"
onMount(async () => {
// navigate to first table in list, if not already selected
$datasources.list.length > 0 && $goto(`../${$datasources.list[0]._id}`)
})
</script>
{#if $tables.list.length === 0}
<i>Connect your first datasource to start building.</i>
{:else}<i>Select a datasource to edit</i>{/if}
<style>
i {
font-size: var(--font-size-m);
color: var(--grey-5);
margin-top: 2px;
}
</style>
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/datasource/index.svelte

View File

@ -1,16 +1,9 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/table/[selectedTable]/_layout.svelte
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { tables } from "stores/backend"
=======
import { params } from "@sveltech/routify"
import { tables } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/table/[selectedTable]/_layout.svelte
if ($params.selectedTable) { if ($params.selectedTable) {
const table = $tables.list.find( const table = $tables.list.find(m => m._id === $params.selectedTable)
m => m._id === $params.selectedTable
)
if (table) { if (table) {
tables.select(table) tables.select(table)
} }

View File

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

View File

@ -1,6 +1,6 @@
<script> <script>
import { tables } from 'stores/backend/' import { tables } from "stores/backend"
import { goto, leftover } from "@sveltech/routify" import { goto, leftover } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
onMount(async () => { onMount(async () => {

View File

@ -1,20 +1,10 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/table/index.svelte
import { backendUiStore } from "builderStore"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
import { tables } from "stores/backend"
onMount(async () => {
$backendUiStore.tables.length > 0 &&
$goto(`./${$backendUiStore.tables[0]._id}`)
=======
import { tables } from 'stores/backend/'
import { goto } from "@sveltech/routify"
import { onMount } from "svelte"
onMount(async () => { onMount(async () => {
$tables.list.length > 0 && $goto(`../${$tables.list[0]._id}`) $tables.list.length > 0 && $goto(`../${$tables.list[0]._id}`)
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/table/index.svelte
}) })
</script> </script>

View File

@ -1,11 +1,6 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/view/[selectedView]/_layout.svelte
import { params } from "@roxi/routify" import { params } from "@roxi/routify"
import { backendUiStore } from "builderStore" import { tables, views } from "stores/backend"
=======
import { params } from "@sveltech/routify"
import { tables, views } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/view/[selectedView]/_layout.svelte
if ($params.selectedView) { if ($params.selectedView) {
let view let view

View File

@ -1,11 +1,6 @@
<script> <script>
<<<<<<< HEAD:packages/builder/src/pages/builder/[application]/data/view/[selectedView]/index.svelte
import ViewDataTable from "components/backend/DataTable/ViewDataTable.svelte" import ViewDataTable from "components/backend/DataTable/ViewDataTable.svelte"
import { backendUiStore } from "builderStore" import { views, database } from "stores/backend"
=======
import ViewDataTable from "components/backend/DataTable/ViewDataTable"
import { views, database } from 'stores/backend/'
>>>>>>> d803aa0bd7a74220e432f4a1b338abdd7fbe9b7d:packages/builder/src/pages/[application]/data/view/[selectedView]/index.svelte
$: selectedView = $views.selected $: selectedView = $views.selected
</script> </script>

View File

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