From 7fcebedcdd3e92886f2fdf390fa030593bc57fb5 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 2 Aug 2024 11:49:45 +0200 Subject: [PATCH] getConnectionLabel refactor --- packages/api/src/auth/authProvider.js | 4 ++++ packages/api/src/controllers/storage.js | 8 +++++++- .../{web/src/utility => tools/src}/getConnectionLabel.ts | 2 +- packages/tools/src/index.ts | 1 + packages/web/src/appobj/ConnectionAppObject.svelte | 2 +- packages/web/src/appobj/DatabaseAppObject.svelte | 3 +-- packages/web/src/appobj/DatabaseObjectAppObject.svelte | 3 +-- packages/web/src/appobj/SavedFileAppObject.svelte | 3 +-- packages/web/src/commands/CommandPalette.svelte | 3 +-- packages/web/src/commands/recentDatabaseSwitch.ts | 2 +- packages/web/src/commands/stdCommands.ts | 2 +- packages/web/src/impexp/FormConnectionSelect.svelte | 2 +- packages/web/src/modals/ExportDatabaseDumpModal.svelte | 2 +- packages/web/src/modals/ImportDatabaseDumpModal.svelte | 2 +- packages/web/src/perspectives/CustomJoinModal.svelte | 3 +-- packages/web/src/query/newQuery.ts | 2 +- packages/web/src/tabpanel/TabsPanel.svelte | 2 +- packages/web/src/tabs/ConnectionTab.svelte | 2 +- packages/web/src/utility/openElectronFile.ts | 2 +- packages/web/src/widgets/ConnectionList.svelte | 2 +- packages/web/src/widgets/StatusBar.svelte | 2 +- 21 files changed, 30 insertions(+), 24 deletions(-) rename packages/{web/src/utility => tools/src}/getConnectionLabel.ts (90%) diff --git a/packages/api/src/auth/authProvider.js b/packages/api/src/auth/authProvider.js index cbf32bf3..8d4b4c93 100644 --- a/packages/api/src/auth/authProvider.js +++ b/packages/api/src/auth/authProvider.js @@ -39,6 +39,10 @@ class AuthProviderBase { getAdditionalConfigProps() { return {}; } + + getLoginPageConnections() { + return null; + } } class OAuthProvider extends AuthProviderBase { diff --git a/packages/api/src/controllers/storage.js b/packages/api/src/controllers/storage.js index 9599dd0e..871b7ad2 100644 --- a/packages/api/src/controllers/storage.js +++ b/packages/api/src/controllers/storage.js @@ -4,11 +4,17 @@ module.exports = { return null; }, + getConnection_meta: true, async getConnection({ conid }) { return null; }, async loadSuperadminPermissions() { return []; - } + }, + + getConnectionsForLoginPage_meta: true, + async getConnectionsForLoginPage() { + return null; + }, }; diff --git a/packages/web/src/utility/getConnectionLabel.ts b/packages/tools/src/getConnectionLabel.ts similarity index 90% rename from packages/web/src/utility/getConnectionLabel.ts rename to packages/tools/src/getConnectionLabel.ts index 2350ecc8..061b7796 100644 --- a/packages/web/src/utility/getConnectionLabel.ts +++ b/packages/tools/src/getConnectionLabel.ts @@ -31,7 +31,7 @@ function getConnectionLabelCore(connection, { allowExplicitDatabase = true } = { return ''; } -export default function getConnectionLabel(connection, { allowExplicitDatabase = true, showUnsaved = false } = {}) { +export function getConnectionLabel(connection, { allowExplicitDatabase = true, showUnsaved = false } = {}) { const res = getConnectionLabelCore(connection, { allowExplicitDatabase }); if (res && showUnsaved && connection?.unsaved) { diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index f5e614e2..69e972ca 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -20,3 +20,4 @@ export * from './computeDiffRows'; export * from './preloadedRowsTools'; export * from './ScriptWriter'; export * from './getLogger'; +export * from './getConnectionLabel'; diff --git a/packages/web/src/appobj/ConnectionAppObject.svelte b/packages/web/src/appobj/ConnectionAppObject.svelte index 10021174..b5d97756 100644 --- a/packages/web/src/appobj/ConnectionAppObject.svelte +++ b/packages/web/src/appobj/ConnectionAppObject.svelte @@ -98,7 +98,6 @@ import openNewTab from '../utility/openNewTab'; import { getDatabaseMenuItems } from './DatabaseAppObject.svelte'; import getElectron from '../utility/getElectron'; - import getConnectionLabel from '../utility/getConnectionLabel'; import { getDatabaseList, useUsedApps } from '../utility/metadataLoaders'; import { getLocalStorage } from '../utility/storageCache'; import { apiCall, removeVolatileMapping } from '../utility/api'; @@ -106,6 +105,7 @@ import { closeMultipleTabs } from '../tabpanel/TabsPanel.svelte'; import AboutModal from '../modals/AboutModal.svelte'; import { tick } from 'svelte'; + import { getConnectionLabel } from 'dbgate-tools'; export let data; export let passProps; diff --git a/packages/web/src/appobj/DatabaseAppObject.svelte b/packages/web/src/appobj/DatabaseAppObject.svelte index 25227467..21c1ce65 100644 --- a/packages/web/src/appobj/DatabaseAppObject.svelte +++ b/packages/web/src/appobj/DatabaseAppObject.svelte @@ -340,7 +340,6 @@