Display users table as its own option at the very top of the datasource list

This commit is contained in:
Andrew Kingston 2023-06-26 10:50:54 +01:00
parent 5f407259dc
commit 2a2215f485
3 changed files with 26 additions and 11 deletions

View File

@ -12,8 +12,10 @@
customQueryText, customQueryText,
} from "helpers/data/utils" } from "helpers/data/utils"
import IntegrationIcon from "./IntegrationIcon.svelte" import IntegrationIcon from "./IntegrationIcon.svelte"
import { TableNames } from "constants"
let openDataSources = [] let openDataSources = []
$: enrichedDataSources = enrichDatasources( $: enrichedDataSources = enrichDatasources(
$datasources, $datasources,
$params, $params,
@ -71,6 +73,13 @@
$goto(`./datasource/${datasource._id}`) $goto(`./datasource/${datasource._id}`)
} }
const selectTable = tableId => {
tables.select(tableId)
if (!$isActive("./table/:tableId")) {
$goto(`./table/${tableId}`)
}
}
function closeNode(datasource) { function closeNode(datasource) {
openDataSources = openDataSources.filter(id => datasource._id !== id) openDataSources = openDataSources.filter(id => datasource._id !== id)
} }
@ -151,9 +160,16 @@
{#if $database?._id} {#if $database?._id}
<div class="hierarchy-items-container"> <div class="hierarchy-items-container">
<NavItem
icon="UserGroup"
text="Users"
selected={$isActive("./table/:tableId") &&
$tables.selected?._id === TableNames.USERS}
on:click={() => selectTable(TableNames.USERS)}
/>
{#each enrichedDataSources as datasource, idx} {#each enrichedDataSources as datasource, idx}
<NavItem <NavItem
border={idx > 0} border
text={datasource.name} text={datasource.name}
opened={datasource.open} opened={datasource.open}
selected={$isActive("./datasource") && datasource.selected} selected={$isActive("./datasource") && datasource.selected}
@ -174,7 +190,7 @@
</NavItem> </NavItem>
{#if datasource.open} {#if datasource.open}
<TableNavigator sourceId={datasource._id} /> <TableNavigator sourceId={datasource._id} {selectTable} />
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query} {#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
<NavItem <NavItem
indentLevel={1} indentLevel={1}

View File

@ -10,17 +10,13 @@
a.name?.toLowerCase() > b.name?.toLowerCase() ? 1 : -1 a.name?.toLowerCase() > b.name?.toLowerCase() ? 1 : -1
export let sourceId export let sourceId
export let selectTable
$: sortedTables = $tables.list $: sortedTables = $tables.list
.filter(table => table.sourceId === sourceId) .filter(
table => table.sourceId === sourceId && table._id !== TableNames.USERS
)
.sort(alphabetical) .sort(alphabetical)
const selectTable = tableId => {
tables.select(tableId)
if (!$isActive("./table/:tableId")) {
$goto(`./table/${tableId}`)
}
}
</script> </script>
{#if $database?._id} {#if $database?._id}

View File

@ -6,12 +6,15 @@
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
import { BUDIBASE_INTERNAL_DB_ID } from "constants/backend" import { BUDIBASE_INTERNAL_DB_ID } from "constants/backend"
import { TableNames } from "constants"
let modal let modal
$: internalTablesBySourceId = $tables.list.filter( $: internalTablesBySourceId = $tables.list.filter(
table => table =>
table.type !== "external" && table.sourceId === BUDIBASE_INTERNAL_DB_ID table.type !== "external" &&
table.sourceId === BUDIBASE_INTERNAL_DB_ID &&
table._id !== TableNames.USERS
) )
onMount(() => { onMount(() => {