@antelopejs/dms-database 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/dist/automation/tableWatch.d.ts +2 -2
- package/dist/automation/tableWatch.js +3 -3
- package/dist/automation/tableWatch.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/connectionAccess.d.ts +3 -0
- package/dist/connectionAccess.js +20 -0
- package/dist/connectionAccess.js.map +1 -0
- package/dist/db/models/connection_selections.model.d.ts +27 -0
- package/dist/db/models/connection_selections.model.js +17 -0
- package/dist/db/models/connection_selections.model.js.map +1 -0
- package/dist/db/models/diagram_layouts.model.d.ts +4 -4
- package/dist/db/models/diagram_layouts.model.js +14 -12
- package/dist/db/models/diagram_layouts.model.js.map +1 -1
- package/dist/db/models/diagram_notes.model.d.ts +3 -3
- package/dist/db/models/index.d.ts +1 -0
- package/dist/db/models/index.js +1 -0
- package/dist/db/models/index.js.map +1 -1
- package/dist/db/models/query_history.model.d.ts +3 -3
- package/dist/db/models/saved_queries.model.d.ts +3 -3
- package/dist/db/tables/connection_selections.table.d.ts +6 -0
- package/dist/db/tables/connection_selections.table.js +30 -0
- package/dist/db/tables/connection_selections.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +1 -0
- package/dist/db/tables/index.js +1 -0
- package/dist/db/tables/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/externalLock.d.ts +8 -0
- package/dist/pages/externalLock.js +32 -0
- package/dist/pages/externalLock.js.map +1 -0
- package/dist/pages/overview.js +6 -3
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/schemas.js +6 -2
- package/dist/pages/schemas.js.map +1 -1
- package/dist/routes/connections.d.ts +14 -0
- package/dist/routes/connections.js +121 -0
- package/dist/routes/connections.js.map +1 -0
- package/dist/routes/data.d.ts +10 -9
- package/dist/routes/data.js +45 -61
- package/dist/routes/data.js.map +1 -1
- package/dist/routes/diagram.d.ts +6 -6
- package/dist/routes/diagram.js +16 -6
- package/dist/routes/diagram.js.map +1 -1
- package/dist/routes/health.d.ts +1 -1
- package/dist/routes/health.js +3 -2
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/overview.d.ts +2 -2
- package/dist/routes/overview.js +11 -4
- package/dist/routes/overview.js.map +1 -1
- package/dist/routes/query.d.ts +1 -1
- package/dist/routes/query.js +26 -10
- package/dist/routes/query.js.map +1 -1
- package/dist/routes/schemas.d.ts +1 -1
- package/dist/routes/schemas.js +4 -2
- package/dist/routes/schemas.js.map +1 -1
- package/dist/routes/tables.d.ts +2 -1
- package/dist/routes/tables.js +29 -21
- package/dist/routes/tables.js.map +1 -1
- package/dist/service/browse.d.ts +14 -6
- package/dist/service/browse.js +120 -18
- package/dist/service/browse.js.map +1 -1
- package/dist/service/builderRefusal.d.ts +2 -0
- package/dist/service/builderRefusal.js +28 -0
- package/dist/service/builderRefusal.js.map +1 -0
- package/dist/service/catalog.js +2 -1
- package/dist/service/catalog.js.map +1 -1
- package/dist/service/connectionRefusals.d.ts +17 -0
- package/dist/service/connectionRefusals.js +26 -0
- package/dist/service/connectionRefusals.js.map +1 -0
- package/dist/service/connectionState.d.ts +27 -0
- package/dist/service/connectionState.js +167 -0
- package/dist/service/connectionState.js.map +1 -0
- package/dist/service/connections.d.ts +12 -0
- package/dist/service/connections.js +73 -0
- package/dist/service/connections.js.map +1 -0
- package/dist/service/database.d.ts +12 -0
- package/dist/service/database.js +30 -0
- package/dist/service/database.js.map +1 -0
- package/dist/service/declaredFields.d.ts +3 -2
- package/dist/service/declaredFields.js +6 -7
- package/dist/service/declaredFields.js.map +1 -1
- package/dist/service/health.d.ts +2 -1
- package/dist/service/health.js +48 -21
- package/dist/service/health.js.map +1 -1
- package/dist/service/introspect.d.ts +7 -5
- package/dist/service/introspect.js +49 -41
- package/dist/service/introspect.js.map +1 -1
- package/dist/service/overview.d.ts +3 -2
- package/dist/service/overview.js +4 -4
- package/dist/service/overview.js.map +1 -1
- package/dist/service/queryInspection.js +6 -3
- package/dist/service/queryInspection.js.map +1 -1
- package/dist/service/references.d.ts +3 -2
- package/dist/service/references.js +9 -8
- package/dist/service/references.js.map +1 -1
- package/dist/service/rowEdit.d.ts +3 -0
- package/dist/service/rowEdit.js +36 -3
- package/dist/service/rowEdit.js.map +1 -1
- package/dist/service/types.d.ts +1 -1
- package/dist/utils/deadline.d.ts +2 -0
- package/dist/utils/deadline.js +18 -0
- package/dist/utils/deadline.js.map +1 -0
- package/dist/utils/guards.d.ts +2 -0
- package/dist/utils/guards.js +8 -0
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/query.js +5 -4
- package/dist/utils/query.js.map +1 -1
- package/frontend-vue/app/build/components/DataBrowserAccessBar.vue +88 -0
- package/frontend-vue/app/build/components/DataGridFooter.vue +16 -1
- package/frontend-vue/app/build/components/DataGridToolbar.vue +10 -5
- package/frontend-vue/app/build/components/FeatureLocked.vue +16 -0
- package/frontend-vue/app/build/components/QueryConsoleBoard.vue +601 -0
- package/frontend-vue/app/build/components/SchemaDiagramBoard.vue +691 -0
- package/frontend-vue/app/build/composables/registerDatabaseSwitcher.ts +16 -0
- package/frontend-vue/app/build/composables/reloadForSelection.ts +11 -0
- package/frontend-vue/app/build/composables/useDataBrowserGrid.ts +1 -0
- package/frontend-vue/app/build/composables/useDataBrowserTabs.ts +100 -15
- package/frontend-vue/app/build/composables/useDatabaseConnections.ts +164 -0
- package/frontend-vue/app/build/composables/useGridAccess.ts +25 -0
- package/frontend-vue/app/build/composables/useLockedPages.ts +53 -0
- package/frontend-vue/app/build/composables/useQueryRuntime.ts +4 -4
- package/frontend-vue/app/build/composables/useSelectionRecheck.ts +23 -0
- package/frontend-vue/app/build/data/assistantOnboarding.ts +12 -0
- package/frontend-vue/app/build/data/gridData.ts +22 -1
- package/frontend-vue/app/build/data/readOnlyReason.ts +30 -0
- package/frontend-vue/app/build/data/recentTables.ts +15 -8
- package/frontend-vue/app/build/data/useStagedSave.ts +7 -1
- package/frontend-vue/app/components/DataBrowser.vue +17 -14
- package/frontend-vue/app/components/DataBrowserSidebar.vue +24 -13
- package/frontend-vue/app/components/DataGrid.vue +22 -18
- package/frontend-vue/app/components/DataGridCell.vue +5 -2
- package/frontend-vue/app/components/DatabaseSwitcher.vue +101 -0
- package/frontend-vue/app/components/QueryBuilderPanel.vue +4 -4
- package/frontend-vue/app/components/QueryConsole.vue +11 -592
- package/frontend-vue/app/components/QueryLibrary.vue +3 -3
- package/frontend-vue/app/components/QueryResultPanel.vue +5 -5
- package/frontend-vue/app/components/RowDrawer.vue +21 -14
- package/frontend-vue/app/components/SchemaDiagram.vue +10 -683
- package/frontend-vue/app/components/SchemasFilterBar.vue +3 -0
- package/frontend-vue/app/components/TableInspector.vue +19 -10
- package/frontend-vue/build/backend-boundary.ts +8 -3
- package/frontend-vue/dms.frontend.ts +2 -0
- package/frontend-vue/eslint.config.mjs +0 -1
- package/frontend-vue/i18n/locales/database-en-GB.json +43 -1
- package/frontend-vue/i18n/locales/database-fr-FR.json +43 -1
- package/frontend-vue/package.json +3 -3
- package/frontend-vue/pnpm-lock.yaml +14 -11
- package/frontend-vue/tests/accessBar.test.ts +196 -0
- package/frontend-vue/tests/backend-boundary.test.ts +15 -7
- package/frontend-vue/tests/dataBrowserDatabase.test.ts +89 -0
- package/frontend-vue/tests/databaseSwitcher.test.ts +343 -0
- package/frontend-vue/tests/editRequest.test.ts +95 -0
- package/frontend-vue/tests/externalBrowser.test.ts +318 -0
- package/frontend-vue/tests/fixtures/connections.ts +73 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +135 -12
- package/frontend-vue/tests/lockedPages.test.ts +68 -0
- package/frontend-vue/tests/onDemandReads.test.ts +1 -1
- package/frontend-vue/tests/persistence.test.ts +254 -4
- package/frontend-vue/tests/recentTables.test.ts +70 -0
- package/frontend-vue/tests/registration.test.ts +15 -1
- package/frontend-vue/tests/serverRender.test.ts +80 -4
- package/frontend-vue/vitest.config.ts +11 -1
- package/package.json +19 -15
- package/dist/service/schemaRegistry.d.ts +0 -2
- package/dist/service/schemaRegistry.js +0 -8
- package/dist/service/schemaRegistry.js.map +0 -1
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
instanceBadge,
|
|
4
4
|
useDataBrowserTabs,
|
|
5
5
|
} from '../build/composables/useDataBrowserTabs'
|
|
6
|
+
import { useDatabaseConnections } from '../build/composables/useDatabaseConnections'
|
|
7
|
+
import { provideReadOnlyReason } from '../build/data/readOnlyReason'
|
|
6
8
|
import { useDatabaseSchemas } from '../build/composables/useDatabaseSchemas'
|
|
7
9
|
import { formatDatabaseRelativeTime } from '../build/utils/relativeTime'
|
|
8
|
-
import { type RecentTable, readRecentTables } from '../build/data/recentTables'
|
|
9
10
|
import { useStagedEdits } from '../build/data/stagedEdits'
|
|
11
|
+
import DataBrowserAccessBar from '../build/components/DataBrowserAccessBar.vue'
|
|
10
12
|
import DataBrowserSidebar from './DataBrowserSidebar.vue'
|
|
11
13
|
import DataBrowserTabBar from './DataBrowserTabBar.vue'
|
|
12
14
|
import DataGrid from './DataGrid.vue'
|
|
@@ -23,12 +25,20 @@ const {
|
|
|
23
25
|
error: schemasError,
|
|
24
26
|
refresh: refreshSchemas,
|
|
25
27
|
} = useDatabaseSchemas()
|
|
26
|
-
const {
|
|
28
|
+
const { ready: connectionsRead, selected } = useDatabaseConnections()
|
|
29
|
+
provideReadOnlyReason()
|
|
30
|
+
const { tabs, activeTab, recent, restore, follow, openTab, openFromRoute } =
|
|
27
31
|
useDataBrowserTabs()
|
|
28
32
|
const staged = useStagedEdits()
|
|
29
33
|
const route = useDmsRoute()
|
|
30
34
|
|
|
31
|
-
onMounted(() =>
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
restore(selected.value?.id)
|
|
37
|
+
watch(
|
|
38
|
+
() => selected.value?.id,
|
|
39
|
+
(id) => follow(id),
|
|
40
|
+
)
|
|
41
|
+
})
|
|
32
42
|
// A link from this page to another table (a relation) keeps the page mounted.
|
|
33
43
|
watch(
|
|
34
44
|
() => route.query,
|
|
@@ -48,19 +58,11 @@ const activeTableSummary = computed(() =>
|
|
|
48
58
|
: undefined,
|
|
49
59
|
)
|
|
50
60
|
|
|
51
|
-
// Read once mounted: the server renders without the browser's storage, and
|
|
52
|
-
// a list only the client has would not match its markup.
|
|
53
|
-
const recent = ref<RecentTable[]>([])
|
|
54
|
-
onMounted(() => {
|
|
55
|
-
recent.value = readRecentTables()
|
|
56
|
-
})
|
|
57
|
-
watch(activeTab, () => {
|
|
58
|
-
recent.value = readRecentTables()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
61
|
function instanceLabel(instance: string): string {
|
|
62
62
|
return instanceBadge(instance, t('dms_database.data.scope.all')) ?? ''
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
await connectionsRead
|
|
64
66
|
</script>
|
|
65
67
|
|
|
66
68
|
<template>
|
|
@@ -74,6 +76,7 @@ function instanceLabel(instance: string): string {
|
|
|
74
76
|
@retry="refreshSchemas()"
|
|
75
77
|
/>
|
|
76
78
|
<section class="flex min-w-0 flex-1 flex-col md:min-h-0">
|
|
79
|
+
<DataBrowserAccessBar />
|
|
77
80
|
<DataBrowserTabBar />
|
|
78
81
|
<DataGrid
|
|
79
82
|
v-if="activeTab"
|
|
@@ -93,7 +96,7 @@ function instanceLabel(instance: string): string {
|
|
|
93
96
|
>
|
|
94
97
|
<template v-if="recent.length" #actions>
|
|
95
98
|
<div class="grid w-full max-w-sm gap-1.5">
|
|
96
|
-
<
|
|
99
|
+
<DmsEyebrowLabel :label="t('dms_database.data.empty.recent')" />
|
|
97
100
|
<button
|
|
98
101
|
v-for="entry in recent"
|
|
99
102
|
:key="`${entry.schema}.${entry.instance}.${entry.table}`"
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
tabInstanceOf,
|
|
7
7
|
useDataBrowserTabs,
|
|
8
8
|
} from '../build/composables/useDataBrowserTabs'
|
|
9
|
+
import { useDatabaseConnections } from '../build/composables/useDatabaseConnections'
|
|
9
10
|
import { useTableCounts } from '../build/composables/useTableCounts'
|
|
10
11
|
import type { InstanceChoice } from '../build/data/instanceOptions'
|
|
11
12
|
import { onKeyStroke } from '@vueuse/core'
|
|
@@ -34,6 +35,7 @@ const emit = defineEmits<{ retry: [] }>()
|
|
|
34
35
|
const { t, n } = useI18n()
|
|
35
36
|
const { tabs, activeId, activeTab, activations, openTab } = useDataBrowserTabs()
|
|
36
37
|
const route = useDmsRoute()
|
|
38
|
+
const { lacks } = useDatabaseConnections()
|
|
37
39
|
|
|
38
40
|
const schemaId = ref<string | null>(null)
|
|
39
41
|
const instance = ref<string>(DEFAULT_INSTANCE_VALUE)
|
|
@@ -158,10 +160,10 @@ onKeyStroke('t', (event) => {
|
|
|
158
160
|
|
|
159
161
|
<template>
|
|
160
162
|
<aside
|
|
161
|
-
class="border-default bg-default flex max-h-[40vh] w-full shrink-0 flex-col border-b md:h-full md:max-h-none md:w-[264px] md:border-
|
|
163
|
+
class="border-default bg-default flex max-h-[40vh] w-full shrink-0 flex-col border-b md:h-full md:max-h-none md:w-[264px] md:border-b-0 md:border-r"
|
|
162
164
|
>
|
|
163
165
|
<div class="border-default grid gap-2 border-b p-3">
|
|
164
|
-
<
|
|
166
|
+
<DmsEyebrowLabel :label="t('dms_database.data.scope.schema')" />
|
|
165
167
|
<SchemaPicker
|
|
166
168
|
:model-value="schemaId"
|
|
167
169
|
:schema-ids="schemaIds"
|
|
@@ -175,16 +177,24 @@ onKeyStroke('t', (event) => {
|
|
|
175
177
|
class="w-full"
|
|
176
178
|
@update:model-value="pickSchema"
|
|
177
179
|
/>
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
<template v-if="!lacks('instances')">
|
|
181
|
+
<DmsEyebrowLabel
|
|
182
|
+
class="mt-1"
|
|
183
|
+
:label="t('dms_database.data.scope.instance')"
|
|
184
|
+
/>
|
|
185
|
+
<InstancePicker
|
|
186
|
+
:model-value="instanceChoice"
|
|
187
|
+
:schema="schemaId"
|
|
188
|
+
all-mode="readonly"
|
|
189
|
+
:disabled="!schemaId"
|
|
190
|
+
class="w-full"
|
|
191
|
+
@update:model-value="pickInstance"
|
|
192
|
+
/>
|
|
193
|
+
</template>
|
|
194
|
+
<DmsEyebrowLabel
|
|
195
|
+
class="mt-1"
|
|
196
|
+
:label="t('dms_database.data.scope.search')"
|
|
186
197
|
/>
|
|
187
|
-
<DmsEyebrow class="mt-1" :label="t('dms_database.data.scope.search')" />
|
|
188
198
|
<UInput
|
|
189
199
|
ref="filterInput"
|
|
190
200
|
v-model="filter"
|
|
@@ -213,10 +223,10 @@ onKeyStroke('t', (event) => {
|
|
|
213
223
|
|
|
214
224
|
<div class="flex min-h-0 flex-1 flex-col p-2">
|
|
215
225
|
<div class="flex items-center justify-between px-2 py-1">
|
|
216
|
-
<
|
|
226
|
+
<DmsEyebrowLabel
|
|
217
227
|
:label="t('dms_database.data.scope.tables', { count: tables.length })"
|
|
218
228
|
/>
|
|
219
|
-
<
|
|
229
|
+
<DmsEyebrowLabel :label="t('dms_database.data.scope.rows')" />
|
|
220
230
|
</div>
|
|
221
231
|
<nav class="min-h-0 flex-1 overflow-y-auto">
|
|
222
232
|
<div
|
|
@@ -291,6 +301,7 @@ onKeyStroke('t', (event) => {
|
|
|
291
301
|
</nav>
|
|
292
302
|
</div>
|
|
293
303
|
<footer
|
|
304
|
+
v-if="countsFailed || !lacks('instances')"
|
|
294
305
|
class="border-default text-dimmed flex items-center gap-1.5 border-t px-3 py-2 text-[11.5px]"
|
|
295
306
|
>
|
|
296
307
|
<UIcon
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DEFAULT_INSTANCE_VALUE,
|
|
5
5
|
useDataBrowserTabs,
|
|
6
6
|
} from '../build/composables/useDataBrowserTabs'
|
|
7
|
+
import { useGridAccess } from '../build/composables/useGridAccess'
|
|
7
8
|
import { useDatabaseSchemas } from '../build/composables/useDatabaseSchemas'
|
|
8
9
|
import {
|
|
9
10
|
browseListQuery,
|
|
@@ -20,13 +21,12 @@ import type { BrowserTab } from '../build/composables/useDataBrowserTabs'
|
|
|
20
21
|
import type {
|
|
21
22
|
ColumnFilterState,
|
|
22
23
|
GridColumn,
|
|
23
|
-
GridData,
|
|
24
24
|
} from '../build/composables/useDataBrowserGrid'
|
|
25
25
|
import { DATABASE_PAGES, tableAccess } from '../build/utils/databaseLinks'
|
|
26
26
|
import { type ColumnRole, isPrimaryKey } from '../build/utils/fieldTypes'
|
|
27
27
|
import {
|
|
28
28
|
DEFAULT_PRIMARY_KEY,
|
|
29
|
-
|
|
29
|
+
gridDataOf,
|
|
30
30
|
moveFocus,
|
|
31
31
|
type ColumnsResponse,
|
|
32
32
|
type ListResponse,
|
|
@@ -68,8 +68,15 @@ const { tabs: browserTabs, pinTab, openTab, replaceTab } = useDataBrowserTabs()
|
|
|
68
68
|
const { open: openDrawer } = useDrawer()
|
|
69
69
|
const { schemas } = useDatabaseSchemas()
|
|
70
70
|
|
|
71
|
+
const {
|
|
72
|
+
crossInstance,
|
|
73
|
+
readOnly,
|
|
74
|
+
showReferences,
|
|
75
|
+
canOpenQuery,
|
|
76
|
+
canSearchAllInstances,
|
|
77
|
+
} = useGridAccess(() => props.tab)
|
|
78
|
+
|
|
71
79
|
const state = grid.getState(props.tab.id)
|
|
72
|
-
const readOnly = computed(() => props.tab.instance === CROSS_INSTANCE_VALUE)
|
|
73
80
|
|
|
74
81
|
// --- data loading ---
|
|
75
82
|
const selection = computed(() => browseSelectionQuery(props.tab))
|
|
@@ -90,17 +97,9 @@ const loadError = computed(() => {
|
|
|
90
97
|
return error instanceof Error ? error.message : String(error)
|
|
91
98
|
})
|
|
92
99
|
|
|
93
|
-
const data = computed
|
|
100
|
+
const data = computed(() => {
|
|
94
101
|
const list = listRead.data.value
|
|
95
|
-
|
|
96
|
-
const meta = columnsRead.data.value
|
|
97
|
-
const primaryKey = list.primaryKey ?? meta?.primaryKey ?? null
|
|
98
|
-
return {
|
|
99
|
-
columns: columnsOf(meta, primaryKey, props.table),
|
|
100
|
-
rows: list.results ?? [],
|
|
101
|
-
total: list.total ?? 0,
|
|
102
|
-
primaryKey,
|
|
103
|
-
}
|
|
102
|
+
return list ? gridDataOf(list, columnsRead.data.value, props.table) : null
|
|
104
103
|
})
|
|
105
104
|
|
|
106
105
|
watch(data, (next) => {
|
|
@@ -127,7 +126,8 @@ const rows = computed(() => data.value?.rows ?? [])
|
|
|
127
126
|
const total = computed(() => data.value?.total ?? 0)
|
|
128
127
|
const rowIdKey = computed(() => data.value?.primaryKey ?? DEFAULT_PRIMARY_KEY)
|
|
129
128
|
const visibleColumns = computed(() =>
|
|
130
|
-
|
|
129
|
+
crossInstance.value ||
|
|
130
|
+
!columns.value.some((column) => column.name === '_instance')
|
|
131
131
|
? columns.value
|
|
132
132
|
: columns.value.filter((column) => column.name !== '_instance'),
|
|
133
133
|
)
|
|
@@ -227,7 +227,7 @@ function resizeColumn(name: string, width: number) {
|
|
|
227
227
|
// --- links out ---
|
|
228
228
|
function openInQueryConsole() {
|
|
229
229
|
const instance =
|
|
230
|
-
props.tab.instance === DEFAULT_INSTANCE_VALUE ||
|
|
230
|
+
props.tab.instance === DEFAULT_INSTANCE_VALUE || crossInstance.value
|
|
231
231
|
? undefined
|
|
232
232
|
: props.tab.instance
|
|
233
233
|
const source = `${tableAccess({ schema: props.tab.schema, table: props.tab.table, instance })}.slice(0, 100)`
|
|
@@ -475,6 +475,7 @@ function rowDrawerOptions(index: number) {
|
|
|
475
475
|
columns: visibleColumns.value,
|
|
476
476
|
table: props.table,
|
|
477
477
|
readOnly: readOnly.value,
|
|
478
|
+
showReferences: showReferences.value,
|
|
478
479
|
onStage: stage,
|
|
479
480
|
onReview: review,
|
|
480
481
|
},
|
|
@@ -502,7 +503,7 @@ function openRow(index: number) {
|
|
|
502
503
|
function rowKey(row: Record<string, unknown>, index: number): string | number {
|
|
503
504
|
const id = rowIdOf(row)
|
|
504
505
|
if (id === null) return index
|
|
505
|
-
return
|
|
506
|
+
return crossInstance.value ? `${String(row._instance ?? '')}::${id}` : id
|
|
506
507
|
}
|
|
507
508
|
|
|
508
509
|
const hasRefinements = computed(
|
|
@@ -534,6 +535,7 @@ useEventListener('keydown', (event: KeyboardEvent) => {
|
|
|
534
535
|
:table="tab.table"
|
|
535
536
|
:total="total"
|
|
536
537
|
:loading="loading"
|
|
538
|
+
:can-open-query="canOpenQuery"
|
|
537
539
|
@reload="reload"
|
|
538
540
|
@open-query="openInQueryConsole"
|
|
539
541
|
/>
|
|
@@ -546,7 +548,7 @@ useEventListener('keydown', (event: KeyboardEvent) => {
|
|
|
546
548
|
/>
|
|
547
549
|
|
|
548
550
|
<DataGridReadOnlyBanner
|
|
549
|
-
v-if="
|
|
551
|
+
v-if="crossInstance"
|
|
550
552
|
:table="tab.table"
|
|
551
553
|
:instances="namedInstances"
|
|
552
554
|
@switch-instance="switchInstance"
|
|
@@ -642,7 +644,7 @@ useEventListener('keydown', (event: KeyboardEvent) => {
|
|
|
642
644
|
:loading="loading"
|
|
643
645
|
:empty="rows.length === 0"
|
|
644
646
|
:has-refinements="hasRefinements"
|
|
645
|
-
:read-only="
|
|
647
|
+
:read-only="!canSearchAllInstances"
|
|
646
648
|
@reload="reload"
|
|
647
649
|
@clear-refinements="clearRefinements"
|
|
648
650
|
@search-all="switchInstance(CROSS_INSTANCE_VALUE)"
|
|
@@ -666,6 +668,8 @@ useEventListener('keydown', (event: KeyboardEvent) => {
|
|
|
666
668
|
v-model:page="state.page"
|
|
667
669
|
v-model:page-size="state.pageSize"
|
|
668
670
|
:total="total"
|
|
671
|
+
:capped="data?.capped"
|
|
672
|
+
:refined="hasRefinements"
|
|
669
673
|
/>
|
|
670
674
|
</div>
|
|
671
675
|
</template>
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
isStructured,
|
|
7
7
|
} from '../build/data/cellValues'
|
|
8
8
|
import type { StagedCell } from '../build/data/stagedEdits'
|
|
9
|
+
import { READ_ONLY_REASON } from '../build/data/readOnlyReason'
|
|
9
10
|
import type { ColumnRole } from '../build/utils/fieldTypes'
|
|
10
11
|
|
|
11
12
|
// One cell of the data grid. A staged cell is tinted, with the stored value
|
|
@@ -32,6 +33,7 @@ const emit = defineEmits<{
|
|
|
32
33
|
cancel: []
|
|
33
34
|
}>()
|
|
34
35
|
|
|
36
|
+
const readOnlyReason = inject(READ_ONLY_REASON, ref<string | null>(null))
|
|
35
37
|
const shown = computed(() => (props.staged ? props.staged.after : props.value))
|
|
36
38
|
const isNull = computed(() => shown.value === null || shown.value === undefined)
|
|
37
39
|
const isEmptyText = computed(() => shown.value === '')
|
|
@@ -83,7 +85,7 @@ function cancel() {
|
|
|
83
85
|
|
|
84
86
|
<template>
|
|
85
87
|
<td
|
|
86
|
-
class="border-default relative
|
|
88
|
+
class="border-default relative border-b border-r p-0 align-middle"
|
|
87
89
|
:class="[
|
|
88
90
|
invalid
|
|
89
91
|
? 'ring-error ring-2 ring-inset'
|
|
@@ -91,13 +93,14 @@ function cancel() {
|
|
|
91
93
|
? 'ring-primary ring-2 ring-inset'
|
|
92
94
|
: '',
|
|
93
95
|
staged ? 'bg-warning/10' : editing ? 'bg-primary/5' : '',
|
|
96
|
+
readOnlyReason ? 'cursor-not-allowed' : 'cursor-default',
|
|
94
97
|
]"
|
|
95
98
|
:title="
|
|
96
99
|
staged
|
|
97
100
|
? $t('dms_database.data.grid.staged_title', {
|
|
98
101
|
before: cellLabel(staged.before),
|
|
99
102
|
})
|
|
100
|
-
: undefined
|
|
103
|
+
: (readOnlyReason ?? undefined)
|
|
101
104
|
"
|
|
102
105
|
@click="emit('select')"
|
|
103
106
|
@dblclick="editable && emit('start-edit')"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DropdownMenuItem } from '@nuxt/ui'
|
|
3
|
+
import {
|
|
4
|
+
OWN_CONNECTION,
|
|
5
|
+
useDatabaseConnections,
|
|
6
|
+
type DatabaseConnection,
|
|
7
|
+
} from '../build/composables/useDatabaseConnections'
|
|
8
|
+
import { confirmLeave } from '#dms-ui/app/entries/composables/unsaved-changes/registry'
|
|
9
|
+
import { forgetBrowserTabs } from '../build/composables/useDataBrowserTabs'
|
|
10
|
+
import { useLockedPages } from '../build/composables/useLockedPages'
|
|
11
|
+
import { useSelectionRecheck } from '../build/composables/useSelectionRecheck'
|
|
12
|
+
import {
|
|
13
|
+
ONBOARDING_KEY,
|
|
14
|
+
type PublicOnboarding,
|
|
15
|
+
} from '../build/data/assistantOnboarding'
|
|
16
|
+
|
|
17
|
+
defineProps<{ collapsed?: boolean }>()
|
|
18
|
+
|
|
19
|
+
const { t } = useI18n()
|
|
20
|
+
const route = useDmsRoute()
|
|
21
|
+
const { connections, selected, select, recheck } = useDatabaseConnections()
|
|
22
|
+
const onboarding = inject<PublicOnboarding | null>(ONBOARDING_KEY, null)
|
|
23
|
+
useLockedPages(selected)
|
|
24
|
+
useSelectionRecheck(recheck)
|
|
25
|
+
|
|
26
|
+
const switching = ref(false)
|
|
27
|
+
|
|
28
|
+
function nameOf(connection: DatabaseConnection): string {
|
|
29
|
+
return connection.id === OWN_CONNECTION
|
|
30
|
+
? t('dms_database.connections.own')
|
|
31
|
+
: connection.label
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const selectedName = computed(() =>
|
|
35
|
+
selected.value ? nameOf(selected.value) : '',
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
async function pick(id: string) {
|
|
39
|
+
if (switching.value || id === selected.value?.id) return
|
|
40
|
+
switching.value = true
|
|
41
|
+
if (!(await confirmLeave()) || !(await select(id))) {
|
|
42
|
+
switching.value = false
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
forgetBrowserTabs()
|
|
46
|
+
window.location.assign(route.path)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const items = computed<DropdownMenuItem[][]>(() => {
|
|
50
|
+
const databases: DropdownMenuItem[] = connections.value.map((connection) => ({
|
|
51
|
+
label: nameOf(connection),
|
|
52
|
+
description: connection.engine ?? undefined,
|
|
53
|
+
type: 'checkbox',
|
|
54
|
+
checked: connection.id === selected.value?.id,
|
|
55
|
+
icon: connection.kind === 'own' ? 'i-ph-database' : 'i-ph-plugs-connected',
|
|
56
|
+
external: connection.kind === 'external',
|
|
57
|
+
onSelect: () => void pick(connection.id),
|
|
58
|
+
}))
|
|
59
|
+
if (onboarding?.isAvailable !== true) return [databases]
|
|
60
|
+
return [
|
|
61
|
+
databases,
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
label: t('dms_database.connections.switcher.connect'),
|
|
65
|
+
icon: 'i-ph-plus',
|
|
66
|
+
onSelect: () => onboarding.open('connect-database'),
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<div v-if="connections.length > 0" class="px-2 pb-2" data-database-switcher>
|
|
75
|
+
<UDropdownMenu
|
|
76
|
+
:items="items"
|
|
77
|
+
:content="{ align: 'start' }"
|
|
78
|
+
:ui="{ content: 'min-w-56' }"
|
|
79
|
+
>
|
|
80
|
+
<UButton
|
|
81
|
+
color="neutral"
|
|
82
|
+
variant="outline"
|
|
83
|
+
:block="!collapsed"
|
|
84
|
+
:icon="
|
|
85
|
+
selected?.kind === 'external'
|
|
86
|
+
? 'i-ph-plugs-connected'
|
|
87
|
+
: 'i-ph-database'
|
|
88
|
+
"
|
|
89
|
+
:trailing-icon="collapsed ? undefined : 'i-ph-caret-up-down'"
|
|
90
|
+
:label="collapsed ? undefined : selectedName"
|
|
91
|
+
:loading="switching"
|
|
92
|
+
:aria-label="`${t('dms_database.connections.switcher.label')}: ${selectedName}`"
|
|
93
|
+
/>
|
|
94
|
+
<template #item-trailing="{ item }">
|
|
95
|
+
<UBadge v-if="item.external" color="primary" variant="subtle" size="sm">
|
|
96
|
+
{{ t('dms_database.connections.external') }}
|
|
97
|
+
</UBadge>
|
|
98
|
+
</template>
|
|
99
|
+
</UDropdownMenu>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
@@ -319,7 +319,7 @@ const themeCompartment = new Compartment()
|
|
|
319
319
|
const placeholderCompartment = new Compartment()
|
|
320
320
|
const colorMode = useColorMode()
|
|
321
321
|
|
|
322
|
-
// Transparent surfaces so the editor blends into the
|
|
322
|
+
// Transparent surfaces so the editor blends into the DmsCardPanel (bg-default).
|
|
323
323
|
const baseTheme = EditorView.theme({
|
|
324
324
|
'&': { backgroundColor: 'transparent', height: '100%', fontSize: '13px' },
|
|
325
325
|
'&.cm-focused': { outline: 'none' },
|
|
@@ -444,7 +444,7 @@ defineExpose({ focus: () => view?.focus() })
|
|
|
444
444
|
</script>
|
|
445
445
|
|
|
446
446
|
<template>
|
|
447
|
-
<
|
|
447
|
+
<DmsCardPanel :padded="false" class="overflow-hidden">
|
|
448
448
|
<div
|
|
449
449
|
class="border-default flex flex-wrap items-center gap-2 border-b px-3.5 py-2.5"
|
|
450
450
|
>
|
|
@@ -524,7 +524,7 @@ defineExpose({ focus: () => view?.focus() })
|
|
|
524
524
|
<div
|
|
525
525
|
class="border-default text-dimmed flex flex-wrap items-center gap-2 border-t px-3.5 py-2 text-[11.5px]"
|
|
526
526
|
>
|
|
527
|
-
<
|
|
527
|
+
<DmsEyebrowLabel :label="t('dms_database.query.editor.insert')" />
|
|
528
528
|
<button
|
|
529
529
|
v-for="snippet in SNIPPETS"
|
|
530
530
|
:key="snippet.label"
|
|
@@ -550,5 +550,5 @@ defineExpose({ focus: () => view?.focus() })
|
|
|
550
550
|
}}
|
|
551
551
|
</span>
|
|
552
552
|
</div>
|
|
553
|
-
</
|
|
553
|
+
</DmsCardPanel>
|
|
554
554
|
</template>
|