From 7fc01227e7d096d9febc02964dcecb191e909f5f Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 4 Jun 2022 18:37:16 +0200 Subject: [PATCH] refactor: ts and composition api on more components --- package-lock.json | 4 +- src/common/customizations/index.ts | 6 + src/main/ipc-handlers/tables.ts | 17 +- src/main/ipc-handlers/updates.ts | 4 +- src/renderer/components/BaseSelect.vue | 22 +- src/renderer/components/ModalHistory.vue | 13 +- src/renderer/components/QueryEditor.vue | 594 ++++++++-------- src/renderer/components/SettingBarContext.vue | 125 ++-- .../components/TheNotificationsBoard.vue | 2 +- src/renderer/components/TheScratchpad.vue | 2 +- src/renderer/components/TheSettingBar.vue | 2 +- src/renderer/components/Workspace.vue | 396 +++++------ .../WorkspaceAddConnectionPanel.vue | 411 +++++------ .../WorkspaceEditConnectionPanel.vue | 356 +++++----- .../components/WorkspaceEmptyState.vue | 67 +- .../components/WorkspaceExploreBar.vue | 670 +++++++----------- .../components/WorkspaceExploreBarSchema.vue | 2 + .../components/WorkspaceTabPropsTableRow.vue | 2 +- src/renderer/components/WorkspaceTabQuery.vue | 2 +- src/renderer/i18n/{ru-RU.js => ru-RU.ts} | 0 src/renderer/index.ts | 2 +- src/renderer/stores/application.ts | 2 +- src/renderer/stores/connections.ts | 2 +- src/renderer/stores/settings.ts | 3 +- src/renderer/stores/workspaces.ts | 26 +- 25 files changed, 1256 insertions(+), 1476 deletions(-) rename src/renderer/i18n/{ru-RU.js => ru-RU.ts} (100%) diff --git a/package-lock.json b/package-lock.json index bc7fa963..ca5020af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "antares", - "version": "0.5.4", + "version": "0.5.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "antares", - "version": "0.5.4", + "version": "0.5.5", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/src/common/customizations/index.ts b/src/common/customizations/index.ts index 2a8f3726..52dbe6fc 100644 --- a/src/common/customizations/index.ts +++ b/src/common/customizations/index.ts @@ -1,10 +1,16 @@ import * as mysql from 'common/customizations/mysql'; import * as postgresql from 'common/customizations/postgresql'; import * as sqlite from 'common/customizations/sqlite'; +import { Customizations } from 'common/interfaces/customizations'; export default { maria: mysql.customizations, mysql: mysql.customizations, pg: postgresql.customizations, sqlite: sqlite.customizations +} as { + maria: Customizations; + mysql: Customizations; + pg: Customizations; + sqlite: Customizations; }; diff --git a/src/main/ipc-handlers/tables.ts b/src/main/ipc-handlers/tables.ts index 7ded1d4a..66a09be3 100644 --- a/src/main/ipc-handlers/tables.ts +++ b/src/main/ipc-handlers/tables.ts @@ -104,8 +104,6 @@ export default (connections: {[key: string]: antares.Client}) => { escapedParam = `"${sqlEscaper(params.content)}"`; break; case 'pg': - escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`; - break; case 'sqlite': escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`; break; @@ -248,8 +246,7 @@ export default (connections: {[key: string]: antares.Client}) => { ipcMain.handle('insert-table-rows', async (event, params) => { try { // TODO: move to client classes - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const insertObj: {[key: string]: any} = {}; + const insertObj: {[key: string]: string | number | boolean | Date | Buffer} = {}; for (const key in params.row) { const type = params.fields[key]; let escapedParam; @@ -318,12 +315,10 @@ export default (connections: {[key: string]: antares.Client}) => { ipcMain.handle('insert-table-fake-rows', async (event, params: InsertRowsParams) => { try { // TODO: move to client classes - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const rows: {[key: string]: any}[] = []; + const rows: {[key: string]: string | number | boolean | Date | Buffer}[] = []; for (let i = 0; i < +params.repeat; i++) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const insertObj: {[key: string]: any} = {}; + const insertObj: {[key: string]: string | number | boolean | Date | Buffer} = {}; for (const key in params.row) { const type = params.fields[key]; @@ -341,6 +336,7 @@ export default (connections: {[key: string]: antares.Client}) => { escapedParam = `"${sqlEscaper(params.row[key].value)}"`; break; case 'pg': + case 'sqlite': escapedParam = `'${params.row[key].value.replaceAll('\'', '\'\'')}'`; break; } @@ -381,8 +377,7 @@ export default (connections: {[key: string]: antares.Client}) => { insertObj[key] = escapedParam; } else { // Faker value - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const parsedParams: {[key: string]: any} = {}; + const parsedParams: {[key: string]: string | number | boolean | Date | Buffer} = {}; let fakeValue; if (params.locale) @@ -402,7 +397,7 @@ export default (connections: {[key: string]: antares.Client}) => { if (typeof fakeValue === 'string') { if (params.row[key].length) - fakeValue = fakeValue.substr(0, params.row[key].length); + fakeValue = fakeValue.substring(0, params.row[key].length); fakeValue = `'${sqlEscaper(fakeValue)}'`; } else if ([...DATE, ...DATETIME].includes(type)) diff --git a/src/main/ipc-handlers/updates.ts b/src/main/ipc-handlers/updates.ts index b509d549..64a1175d 100644 --- a/src/main/ipc-handlers/updates.ts +++ b/src/main/ipc-handlers/updates.ts @@ -1,7 +1,7 @@ import { ipcMain } from 'electron'; import { autoUpdater } from 'electron-updater'; -import Store from 'electron-store'; -const persistentStore = new Store({ name: 'settings' }); +import * as Store from 'electron-store'; +const persistentStore = new Store({ name: 'settings', clearInvalidConfig: true }); const isMacOS = process.platform === 'darwin'; let mainWindow: Electron.IpcMainEvent; diff --git a/src/renderer/components/BaseSelect.vue b/src/renderer/components/BaseSelect.vue index 9b17e211..b3352d96 100644 --- a/src/renderer/components/BaseSelect.vue +++ b/src/renderer/components/BaseSelect.vue @@ -37,6 +37,8 @@ v-if="isOpen" ref="optionList" :class="`select__list-wrapper ${dropdownClass ? dropdownClass : '' }`" + @mousedown="isMouseDown = true" + @mouseup="handleMouseUpEvent()" >