From 8928510fb5426c4a997674afebf0ca020271e11b Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 19 Jan 2024 18:03:20 +0100 Subject: [PATCH 01/16] refactor: use Record to type objects --- README.md | 12 +--------- src/common/interfaces/antares.ts | 2 +- src/common/interfaces/exporter.ts | 2 +- src/common/interfaces/tableApis.ts | 23 +++++++++---------- src/common/libs/sqlUtils.ts | 6 ++--- src/common/shortcuts.ts | 2 +- src/main/ipc-handlers/connection.ts | 2 +- src/main/ipc-handlers/database.ts | 2 +- src/main/ipc-handlers/functions.ts | 2 +- src/main/ipc-handlers/index.ts | 2 +- src/main/ipc-handlers/routines.ts | 2 +- src/main/ipc-handlers/schedulers.ts | 2 +- src/main/ipc-handlers/schema.ts | 2 +- src/main/ipc-handlers/tables.ts | 16 ++++++------- src/main/ipc-handlers/triggers.ts | 2 +- src/main/ipc-handlers/users.ts | 2 +- src/main/ipc-handlers/views.ts | 2 +- src/main/libs/clients/BaseClient.ts | 2 +- src/main/libs/clients/FirebirdSQLClient.ts | 2 +- src/main/libs/clients/MySQLClient.ts | 4 ++-- src/main/libs/clients/PostgreSQLClient.ts | 6 ++--- src/main/libs/clients/SQLiteClient.ts | 2 +- src/main/libs/exporters/sql/MysqlExporter.ts | 2 +- .../libs/exporters/sql/PostgreSQLExporter.ts | 4 ++-- src/renderer/components/FakerSelect.vue | 2 +- .../components/ModalAskParameters.vue | 2 +- src/renderer/components/ModalExportSchema.vue | 2 +- src/renderer/components/ModalFakerRows.vue | 6 ++--- .../components/ModalProcessesListRow.vue | 2 +- .../components/TheNotificationsBoard.vue | 2 +- src/renderer/components/Workspace.vue | 2 +- .../WorkspaceAddConnectionPanel.vue | 4 ++-- .../WorkspaceEditConnectionPanel.vue | 4 ++-- .../components/WorkspaceTabPropsTable.vue | 2 +- .../WorkspaceTabPropsTableForeignModal.vue | 2 +- src/renderer/composables/useFilters.ts | 2 +- src/renderer/i18n/supported-locales.ts | 2 +- src/renderer/ipc-api/Tables.ts | 6 ++--- src/renderer/stores/history.ts | 2 +- src/renderer/stores/workspaces.ts | 4 ++-- 40 files changed, 70 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 6dd56761..c14aa878 100644 --- a/README.md +++ b/README.md @@ -71,17 +71,6 @@ On macOS you can run `.dmg` distribution following [this guide](https://support. [Download on Flathub](https://flathub.org/apps/it.fabiodistasio.AntaresSQL) [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/antares) [![Get it from AUR](https://raw.githubusercontent.com/antares-sql/antares/master/docs/aur-badge.svg)](https://aur.archlinux.org/packages/antares-sql-bin) [](https://www.microsoft.com/p/antares-sql-client/9nhtb9sq51r1?cid=storebadge&ocid=badge&rtc=1&activetab=pivot:overviewtab) 🚀 **[Other Downloads](https://github.com/antares-sql/antares/releases/latest)** -## Coming soon - -This is a roadmap with major features will come in near future. - -- Database tools. -- Users management (add/edit/delete). -- More context menu shortcuts. -- More keyboard shortcuts. -- Support for other databases. -- Apple Silicon distribution - ## Currently supported ### Databases @@ -90,6 +79,7 @@ This is a roadmap with major features will come in near future. - [x] PostgreSQL - [x] SQLite - [x] Firebird SQL +- [ ] DuckDB - [ ] SQL Server - [ ] More... diff --git a/src/common/interfaces/antares.ts b/src/common/interfaces/antares.ts index 7d80506b..1a72af62 100644 --- a/src/common/interfaces/antares.ts +++ b/src/common/interfaces/antares.ts @@ -363,7 +363,7 @@ export interface QueryBuilderObject { offset: number; join: string[]; update: string[]; - insert: {[key: string]: string | boolean | number }[]; + insert: Record[]; delete: boolean; } diff --git a/src/common/interfaces/exporter.ts b/src/common/interfaces/exporter.ts index 10a180f1..8ac30e66 100644 --- a/src/common/interfaces/exporter.ts +++ b/src/common/interfaces/exporter.ts @@ -13,7 +13,7 @@ export interface ExportOptions { includeContent: boolean; includeDropStatement: boolean; }[]; - includes: {[key: string]: boolean}; + includes: Record; outputFormat: 'sql' | 'sql.zip'; outputFile: string; sqlInsertAfter: number; diff --git a/src/common/interfaces/tableApis.ts b/src/common/interfaces/tableApis.ts index bbfbdabe..9cee0808 100644 --- a/src/common/interfaces/tableApis.ts +++ b/src/common/interfaces/tableApis.ts @@ -18,7 +18,7 @@ export interface TableDeleteParams { primary?: string; field: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any - rows: {[key: string]: any}; + rows: Record; } export type TableFilterOperator = '=' | '!=' | '>' | '<' | '>=' | '<=' | 'IN' | 'NOT IN' | 'LIKE' | 'NOT LIKE' | 'RLIKE' | 'NOT RLIKE' | 'BETWEEN' | 'IS NULL' | 'IS NOT NULL' @@ -35,17 +35,16 @@ export interface InsertRowsParams { uid: string; schema: string; table: string; - row: {[key: string]: { - group: string; - method: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - params: any; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - value: any; - length: number; - }; - }; + row: Record; repeat: number; - fields: {[key: string]: string}; + fields: Record; locale: UsableLocale; } diff --git a/src/common/libs/sqlUtils.ts b/src/common/libs/sqlUtils.ts index d1f764f0..44d4a2ad 100644 --- a/src/common/libs/sqlUtils.ts +++ b/src/common/libs/sqlUtils.ts @@ -41,7 +41,7 @@ export const escapeAndQuote = (val: string, client: ClientCode) => { const { stringsWrapper: sw } = customizations[client]; // eslint-disable-next-line no-control-regex const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g; - const CHARS_ESCAPE_MAP: {[key: string]: string} = { + const CHARS_ESCAPE_MAP: Record = { '\0': '\\0', '\b': '\\b', '\t': '\\t', @@ -153,9 +153,9 @@ export const valueToSqlString = (args: { }; export const jsonToSqlInsert = (args: { - json: { [key: string]: any}[]; + json: Record[]; client: ClientCode; - fields: { [key: string]: {type: string; datePrecision: number}}; + fields: Record; table: string; options?: {sqlInsertAfter: number; sqlInsertDivider: 'bytes' | 'rows'}; }) => { diff --git a/src/common/shortcuts.ts b/src/common/shortcuts.ts index b3436e62..d929af75 100644 --- a/src/common/shortcuts.ts +++ b/src/common/shortcuts.ts @@ -1,4 +1,4 @@ -export const shortcutEvents: { [key: string]: { l18n: string; l18nParam?: string | number; context?: 'tab' }} = { +export const shortcutEvents: Record = { 'run-or-reload': { l18n: 'application.runOrReload', context: 'tab' }, 'open-new-tab': { l18n: 'application.openNewTab', context: 'tab' }, 'close-tab': { l18n: 'application.closeTab', context: 'tab' }, diff --git a/src/main/ipc-handlers/connection.ts b/src/main/ipc-handlers/connection.ts index fa87cbeb..1b4c042b 100644 --- a/src/main/ipc-handlers/connection.ts +++ b/src/main/ipc-handlers/connection.ts @@ -6,7 +6,7 @@ import { SslOptions } from 'mysql2'; import { ClientsFactory } from '../libs/ClientsFactory'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('test-connection', async (event, conn: antares.ConnectionParams) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/database.ts b/src/main/ipc-handlers/database.ts index 4aaf721f..13b56a16 100644 --- a/src/main/ipc-handlers/database.ts +++ b/src/main/ipc-handlers/database.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-databases', async (event, uid) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/functions.ts b/src/main/ipc-handlers/functions.ts index b8675b2e..d7574de5 100644 --- a/src/main/ipc-handlers/functions.ts +++ b/src/main/ipc-handlers/functions.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-function-informations', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/index.ts b/src/main/ipc-handlers/index.ts index 36bb0bd1..cb0762da 100644 --- a/src/main/ipc-handlers/index.ts +++ b/src/main/ipc-handlers/index.ts @@ -13,7 +13,7 @@ import updates from './updates'; import users from './users'; import views from './views'; -const connections: {[key: string]: antares.Client} = {}; +const connections: Record = {}; export default () => { connection(connections); diff --git a/src/main/ipc-handlers/routines.ts b/src/main/ipc-handlers/routines.ts index efcb2046..d380c995 100644 --- a/src/main/ipc-handlers/routines.ts +++ b/src/main/ipc-handlers/routines.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-routine-informations', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/schedulers.ts b/src/main/ipc-handlers/schedulers.ts index f7340202..9ace8866 100644 --- a/src/main/ipc-handlers/schedulers.ts +++ b/src/main/ipc-handlers/schedulers.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-scheduler-informations', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/schema.ts b/src/main/ipc-handlers/schema.ts index 0f4f84ee..abda30ce 100644 --- a/src/main/ipc-handlers/schema.ts +++ b/src/main/ipc-handlers/schema.ts @@ -6,7 +6,7 @@ import { Worker } from 'worker_threads'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { let exporter: Worker = null; let importer: Worker = null; diff --git a/src/main/ipc-handlers/tables.ts b/src/main/ipc-handlers/tables.ts index 751846de..c0412c8d 100644 --- a/src/main/ipc-handlers/tables.ts +++ b/src/main/ipc-handlers/tables.ts @@ -10,7 +10,7 @@ import * as moment from 'moment'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-table-columns', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; @@ -249,7 +249,7 @@ export default (connections: {[key: string]: antares.Client}) => { if (params.primary) { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const idString = params.rows.map((row: {[key: string]: any}) => { + const idString = params.rows.map((row: Record) => { const fieldName = Object.keys(row)[0].includes('.') ? `${params.table}.${params.primary}` : params.primary; return typeof row[fieldName] === 'string' @@ -304,10 +304,10 @@ export default (connections: {[key: string]: antares.Client}) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; try { // TODO: move to client classes - const rows: {[key: string]: string | number | boolean | Date | Buffer}[] = []; + const rows: Record[] = []; for (let i = 0; i < +params.repeat; i++) { - const insertObj: {[key: string]: string | number | boolean | Date | Buffer} = {}; + const insertObj: Record = {}; for (const key in params.row) { const type = params.fields[key]; @@ -367,7 +367,7 @@ export default (connections: {[key: string]: antares.Client}) => { insertObj[key] = escapedParam; } else { // Faker value - const parsedParams: {[key: string]: string | number | boolean | Date | Buffer} = {}; + const parsedParams: Record = {}; let fakeValue; if (params.locale) @@ -437,12 +437,12 @@ export default (connections: {[key: string]: antares.Client}) => { if (description) query.select(`LEFT(${description}, 20) AS foreign_description`); - const results = await query.run<{[key: string]: string}>(); + const results = await query.run>(); - const parsedResults: {[key: string]: string}[] = []; + const parsedResults: Record[] = []; for (const row of results.rows) { - const remappedRow: {[key: string]: string} = {}; + const remappedRow: Record = {}; for (const key in row) remappedRow[key.toLowerCase()] = row[key];// Thanks Firebird -.- diff --git a/src/main/ipc-handlers/triggers.ts b/src/main/ipc-handlers/triggers.ts index 415325a3..08ed7054 100644 --- a/src/main/ipc-handlers/triggers.ts +++ b/src/main/ipc-handlers/triggers.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-trigger-informations', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/users.ts b/src/main/ipc-handlers/users.ts index e6a4fe34..56c777dd 100644 --- a/src/main/ipc-handlers/users.ts +++ b/src/main/ipc-handlers/users.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-users', async (event, uid) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/ipc-handlers/views.ts b/src/main/ipc-handlers/views.ts index 0f64b901..128be228 100644 --- a/src/main/ipc-handlers/views.ts +++ b/src/main/ipc-handlers/views.ts @@ -3,7 +3,7 @@ import { ipcMain } from 'electron'; import { validateSender } from '../libs/misc/validateSender'; -export default (connections: {[key: string]: antares.Client}) => { +export default (connections: Record) => { ipcMain.handle('get-view-informations', async (event, params) => { if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; diff --git a/src/main/libs/clients/BaseClient.ts b/src/main/libs/clients/BaseClient.ts index 2e85997a..22bd63d9 100644 --- a/src/main/libs/clients/BaseClient.ts +++ b/src/main/libs/clients/BaseClient.ts @@ -136,7 +136,7 @@ export abstract class BaseClient { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - insert (arr: {[key: string]: any}[]) { + insert (arr: Record[]) { this._query.insert = [...this._query.insert, ...arr]; return this; } diff --git a/src/main/libs/clients/FirebirdSQLClient.ts b/src/main/libs/clients/FirebirdSQLClient.ts index a802d152..9baece61 100644 --- a/src/main/libs/clients/FirebirdSQLClient.ts +++ b/src/main/libs/clients/FirebirdSQLClient.ts @@ -13,7 +13,7 @@ export class FirebirdSQLClient extends BaseClient { protected _connection?: firebird.Database | firebird.ConnectionPool; _params: firebird.Options; - private _types: {[key: number]: string} ={ + private _types: Record ={ 452: 'CHAR', // Array of char 448: 'VARCHAR', 500: 'SMALLINT', diff --git a/src/main/libs/clients/MySQLClient.ts b/src/main/libs/clients/MySQLClient.ts index 45269206..101b190a 100644 --- a/src/main/libs/clients/MySQLClient.ts +++ b/src/main/libs/clients/MySQLClient.ts @@ -15,7 +15,7 @@ export class MySQLClient extends BaseClient { _connection?: mysql.Connection | mysql.Pool; _params: mysql.ConnectionOptions & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean}; - private types: {[key: number]: string} = { + private types: Record = { 0: 'DECIMAL', 1: 'TINYINT', 2: 'SMALLINT', @@ -582,7 +582,7 @@ export class MySQLClient extends BaseClient { } }) .filter(Boolean) - .reduce((acc: {[key: string]: { name: string; type: string; length: string; default: string}}, curr) => { + .reduce((acc: Record, curr) => { acc[curr.name] = curr; return acc; }, {}); diff --git a/src/main/libs/clients/PostgreSQLClient.ts b/src/main/libs/clients/PostgreSQLClient.ts index b5ed3b67..5b192b04 100644 --- a/src/main/libs/clients/PostgreSQLClient.ts +++ b/src/main/libs/clients/PostgreSQLClient.ts @@ -88,8 +88,8 @@ export class PostgreSQLClient extends BaseClient { private _keepaliveTimer: NodeJS.Timer; private _keepaliveMs: number; protected _connection?: pg.Client | pg.Pool; - private types: {[key: string]: string} = {}; - private _arrayTypes: {[key: string]: string} = { + private types: Record = {}; + private _arrayTypes: Record = { _int2: 'SMALLINT', _int4: 'INTEGER', _int8: 'BIGINT', @@ -656,7 +656,7 @@ export class PostgreSQLClient extends BaseClient { let createSql = ''; const sequences = []; const columnsSql = []; - const arrayTypes: {[key: string]: string} = { + const arrayTypes: Record = { _int2: 'smallint', _int4: 'integer', _int8: 'bigint', diff --git a/src/main/libs/clients/SQLiteClient.ts b/src/main/libs/clients/SQLiteClient.ts index eff98062..eb1743b7 100644 --- a/src/main/libs/clients/SQLiteClient.ts +++ b/src/main/libs/clients/SQLiteClient.ts @@ -658,7 +658,7 @@ export class SQLiteClient extends BaseClient { let queryAllResult: any[]; let affectedRows; let fields; - const detectedTypes: {[key: string]: string} = {}; + const detectedTypes: Record = {}; try { const stmt = connection.prepare(query); diff --git a/src/main/libs/exporters/sql/MysqlExporter.ts b/src/main/libs/exporters/sql/MysqlExporter.ts index 469f5844..adc4afd3 100644 --- a/src/main/libs/exporters/sql/MysqlExporter.ts +++ b/src/main/libs/exporters/sql/MysqlExporter.ts @@ -354,7 +354,7 @@ CREATE TABLE \`${view.Name}\`( escapeAndQuote (val: string) { // eslint-disable-next-line no-control-regex const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g; - const CHARS_ESCAPE_MAP: {[key: string]: string} = { + const CHARS_ESCAPE_MAP: Record = { '\0': '\\0', '\b': '\\b', '\t': '\\t', diff --git a/src/main/libs/exporters/sql/PostgreSQLExporter.ts b/src/main/libs/exporters/sql/PostgreSQLExporter.ts index b54c9a72..b13c27ba 100644 --- a/src/main/libs/exporters/sql/PostgreSQLExporter.ts +++ b/src/main/libs/exporters/sql/PostgreSQLExporter.ts @@ -59,7 +59,7 @@ SET row_security = off;\n\n\n`; let createSql = ''; const sequences = []; const columnsSql = []; - const arrayTypes: {[key: string]: string} = { + const arrayTypes: Record = { _int2: 'smallint', _int4: 'integer', _int8: 'bigint', @@ -440,7 +440,7 @@ SET row_security = off;\n\n\n`; escapeAndQuote (val: string) { // eslint-disable-next-line no-control-regex const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g; - const CHARS_ESCAPE_MAP: {[key: string]: string} = { + const CHARS_ESCAPE_MAP: Record = { '\0': '\\0', '\b': '\\b', '\t': '\\t', diff --git a/src/renderer/components/FakerSelect.vue b/src/renderer/components/FakerSelect.vue index bce178ca..8908d918 100644 --- a/src/renderer/components/FakerSelect.vue +++ b/src/renderer/components/FakerSelect.vue @@ -113,7 +113,7 @@ const selectedGroup: Ref = ref('manual'); const selectedMethod: Ref = ref(''); const selectedValue: Ref = ref(''); const debounceTimeout: Ref = ref(null); -const methodParams: Ref<{[key: string]: string}> = ref({}); +const methodParams: Ref> = ref({}); const enumArray: Ref = ref(null); const fakerGroups = computed(() => { diff --git a/src/renderer/components/ModalAskParameters.vue b/src/renderer/components/ModalAskParameters.vue index df66b6f7..c6204a8b 100644 --- a/src/renderer/components/ModalAskParameters.vue +++ b/src/renderer/components/ModalAskParameters.vue @@ -73,7 +73,7 @@ const props = defineProps({ const emit = defineEmits(['confirm', 'close']); const firstInput: Ref = ref(null); -const values: Ref<{[key: string]: string}> = ref({}); +const values: Ref> = ref({}); const inParameters = computed(() => { return props.localRoutine.parameters.filter(param => param.context === 'IN'); diff --git a/src/renderer/components/ModalExportSchema.vue b/src/renderer/components/ModalExportSchema.vue index 70efb786..1d8d2c62 100644 --- a/src/renderer/components/ModalExportSchema.vue +++ b/src/renderer/components/ModalExportSchema.vue @@ -327,7 +327,7 @@ const tables: Ref<{ }[]> = ref([]); const options: Ref> = ref({ schema: selectedSchema.value, - includes: {} as {[key: string]: boolean}, + includes: {} as Record, outputFormat: 'sql' as 'sql' | 'sql.zip', sqlInsertAfter: 250, sqlInsertDivider: 'bytes' as 'bytes' | 'rows' diff --git a/src/renderer/components/ModalFakerRows.vue b/src/renderer/components/ModalFakerRows.vue index a28aec12..f92771a2 100644 --- a/src/renderer/components/ModalFakerRows.vue +++ b/src/renderer/components/ModalFakerRows.vue @@ -142,7 +142,7 @@ const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore); const { trapRef } = useFocusTrap({ disableAutofocus: true }); // eslint-disable-next-line @typescript-eslint/no-explicit-any -const localRow: Ref<{[key: string]: any}> = ref({}); +const localRow: Ref> = ref({}); const fieldsToExclude = ref([]); const nInserts = ref(1); const isInserting = ref(false); @@ -225,7 +225,7 @@ const insertRows = async () => { delete rowToInsert[key]; }); - const fieldTypes: {[key: string]: string} = {}; + const fieldTypes: Record = {}; props.fields.forEach(field => { fieldTypes[field.name] = field.type; }); @@ -290,7 +290,7 @@ onMounted(() => { } }, 50); - const rowObj: {[key: string]: unknown} = {}; + const rowObj: Record = {}; if (!props.rowToDuplicate) { // Set default values diff --git a/src/renderer/components/ModalProcessesListRow.vue b/src/renderer/components/ModalProcessesListRow.vue index 54214698..32b50e2a 100644 --- a/src/renderer/components/ModalProcessesListRow.vue +++ b/src/renderer/components/ModalProcessesListRow.vue @@ -67,7 +67,7 @@ const props = defineProps({ const emit = defineEmits(['select-row', 'contextmenu', 'stop-refresh']); -const isInlineEditor: Ref<{[key: string]: boolean}> = ref({}); +const isInlineEditor: Ref> = ref({}); const isInfoModal = ref(false); const editorMode = ref('sql'); diff --git a/src/renderer/components/TheNotificationsBoard.vue b/src/renderer/components/TheNotificationsBoard.vue index 93d21b41..e8268e29 100644 --- a/src/renderer/components/TheNotificationsBoard.vue +++ b/src/renderer/components/TheNotificationsBoard.vue @@ -32,7 +32,7 @@ const { removeNotification } = notificationsStore; const { notifications } = storeToRefs(notificationsStore); const { notificationsTimeout } = storeToRefs(settingsStore); -const timeouts: Ref<{[key: string]: NodeJS.Timeout}> = ref({}); +const timeouts: Ref> = ref({}); const latestNotifications = computed(() => notifications.value.slice(0, 10)); diff --git a/src/renderer/components/Workspace.vue b/src/renderer/components/Workspace.vue index c96ce699..5ec20e0d 100644 --- a/src/renderer/components/Workspace.vue +++ b/src/renderer/components/Workspace.vue @@ -695,7 +695,7 @@ const openAsPermanentTab = (tab: WorkspaceTab) => { routine: 'routine-props', procedure: 'routine-props', scheduler: 'scheduler-props' - } as {[key: string]: string}; + } as Record; newTab({ uid: props.connection.uid, diff --git a/src/renderer/components/WorkspaceAddConnectionPanel.vue b/src/renderer/components/WorkspaceAddConnectionPanel.vue index 3e0278a8..3a8f869c 100644 --- a/src/renderer/components/WorkspaceAddConnectionPanel.vue +++ b/src/renderer/components/WorkspaceAddConnectionPanel.vue @@ -572,11 +572,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name: const { files } = event.target; if (!files.length) return; - (connection.value as unknown as {[key: string]: string})[name] = files[0].path as string; + (connection.value as unknown as Record)[name] = files[0].path as string; }; const pathClear = (name: keyof ConnectionParams) => { - (connection.value as unknown as {[key: string]: string})[name] = ''; + (connection.value as unknown as Record)[name] = ''; }; setDefaults(); diff --git a/src/renderer/components/WorkspaceEditConnectionPanel.vue b/src/renderer/components/WorkspaceEditConnectionPanel.vue index 6f5d28f6..4a4ab1e5 100644 --- a/src/renderer/components/WorkspaceEditConnectionPanel.vue +++ b/src/renderer/components/WorkspaceEditConnectionPanel.vue @@ -569,11 +569,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name: const { files } = event.target; if (!files.length) return; - (localConnection.value as unknown as {[key: string]: string})[name] = files[0].path; + (localConnection.value as unknown as Record)[name] = files[0].path; }; const pathClear = (name: keyof ConnectionParams) => { - (localConnection.value as unknown as {[key: string]: string})[name] = ''; + (localConnection.value as unknown as Record)[name] = ''; }; localConnection.value = JSON.parse(JSON.stringify(props.connection)); diff --git a/src/renderer/components/WorkspaceTabPropsTable.vue b/src/renderer/components/WorkspaceTabPropsTable.vue index fe031eea..fe50c52b 100644 --- a/src/renderer/components/WorkspaceTabPropsTable.vue +++ b/src/renderer/components/WorkspaceTabPropsTable.vue @@ -382,7 +382,7 @@ const getFieldsData = async () => { if (status === 'success') { const indexesObj = response .filter((index: TableIndex) => index.type !== 'FOREIGN KEY') - .reduce((acc: {[key: string]: TableIndex[]}, curr: TableIndex) => { + .reduce((acc: Record, curr: TableIndex) => { acc[curr.name] = acc[curr.name] || []; acc[curr.name].push(curr); return acc; diff --git a/src/renderer/components/WorkspaceTabPropsTableForeignModal.vue b/src/renderer/components/WorkspaceTabPropsTableForeignModal.vue index 8743825e..4a76b842 100644 --- a/src/renderer/components/WorkspaceTabPropsTableForeignModal.vue +++ b/src/renderer/components/WorkspaceTabPropsTableForeignModal.vue @@ -258,7 +258,7 @@ const indexesPanel: Ref = ref(null); const foreignProxy = ref([]); const selectedForeignID = ref(''); const modalInnerHeight = ref(400); -const refFields = ref({} as {[key: string]: TableField[]}); +const refFields = ref({} as Record); const foreignActions = computed(() => props.workspace.customizations.foreignActions); const selectedForeignObj = computed(() => foreignProxy.value.find(foreign => foreign._antares_id === selectedForeignID.value)); diff --git a/src/renderer/composables/useFilters.ts b/src/renderer/composables/useFilters.ts index 3a4a08b2..b43ab73f 100644 --- a/src/renderer/composables/useFilters.ts +++ b/src/renderer/composables/useFilters.ts @@ -28,7 +28,7 @@ export function useFilters () { return `(${num})`; }; - const parseKeys = (keys: {[key: number]: string}[]) => { + const parseKeys = (keys: Record[]) => { const isMacOS = process.platform === 'darwin'; return (keys as string[]).map(k => ( k.split('+') diff --git a/src/renderer/i18n/supported-locales.ts b/src/renderer/i18n/supported-locales.ts index 08fda12d..25ae32de 100644 --- a/src/renderer/i18n/supported-locales.ts +++ b/src/renderer/i18n/supported-locales.ts @@ -1,4 +1,4 @@ -export const localesNames: {[key: string]: string} = { +export const localesNames: Record = { 'en-US': 'English', 'it-IT': 'Italiano', 'ar-SA': 'العربية', diff --git a/src/renderer/ipc-api/Tables.ts b/src/renderer/ipc-api/Tables.ts index d67a8512..6a432c91 100644 --- a/src/renderer/ipc-api/Tables.ts +++ b/src/renderer/ipc-api/Tables.ts @@ -64,7 +64,7 @@ export default class { primary?: string; field: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any - rows: {[key: string]: any}; + rows: Record; }): Promise { return ipcRenderer.invoke('delete-table-rows', unproxify(params)); } @@ -73,9 +73,9 @@ export default class { uid: string; schema: string; table: string; - row: {[key: string]: string | number | boolean | Date | Buffer}; + row: Record; repeat: number; - fields: {[key: string]: string}; + fields: Record; locale: string; }): Promise { return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params)); diff --git a/src/renderer/stores/history.ts b/src/renderer/stores/history.ts index effd4822..a070adc2 100644 --- a/src/renderer/stores/history.ts +++ b/src/renderer/stores/history.ts @@ -13,7 +13,7 @@ export interface HistoryRecord { export const useHistoryStore = defineStore('history', { state: () => ({ - history: persistentStore.get('history', {}) as {[key: string]: HistoryRecord[]}, + history: persistentStore.get('history', {}) as Record, favorites: persistentStore.get('favorites', {}) }), getters: { diff --git a/src/renderer/stores/workspaces.ts b/src/renderer/stores/workspaces.ts index da671545..d23c75e9 100644 --- a/src/renderer/stores/workspaces.ts +++ b/src/renderer/stores/workspaces.ts @@ -86,11 +86,11 @@ export interface Workspace { arch: string; os: string; }; - engines?: {[key: string]: string | boolean | number}[]; + engines?: Record[]; } const persistentStore = new Store({ name: 'tabs' }); -const tabIndex: {[key: string]: number} = {}; +const tabIndex: Record = {}; export const useWorkspacesStore = defineStore('workspaces', { state: () => ({ From bb36e98bebc5e1e55735e98d272428df2ab682e8 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 20 Jan 2024 10:11:49 +0100 Subject: [PATCH 02/16] perf(UI): improved notes, fixes #746 --- src/renderer/components/ScratchpadNote.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/ScratchpadNote.vue b/src/renderer/components/ScratchpadNote.vue index e958bb41..a4c4c54e 100644 --- a/src/renderer/components/ScratchpadNote.vue +++ b/src/renderer/components/ScratchpadNote.vue @@ -256,9 +256,9 @@ const highlightWord = (string: string) => { code, pre { max-width: 100%; + width: 100%; display: inline-block; font-size: 100%; - // color: $primary-color; opacity: 0.8; font-weight: 600; white-space: break-spaces; @@ -342,6 +342,8 @@ const highlightWord = (string: string) => { diff --git a/src/renderer/components/ModalNoteEdit.vue b/src/renderer/components/ModalNoteEdit.vue index 5f8d1fd2..e63c4fc8 100644 --- a/src/renderer/components/ModalNoteEdit.vue +++ b/src/renderer/components/ModalNoteEdit.vue @@ -1,6 +1,6 @@ From 8500fc40a1ddc0bd2353f1ee3595eba2875a6bb0 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Mon, 26 Feb 2024 18:17:15 +0100 Subject: [PATCH 16/16] refactor: improved note tab selection --- src/renderer/stores/application.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/renderer/stores/application.ts b/src/renderer/stores/application.ts index 5250aba1..14f6658f 100644 --- a/src/renderer/stores/application.ts +++ b/src/renderer/stores/application.ts @@ -55,10 +55,9 @@ export const useApplicationStore = defineStore('application', { }, showScratchpad (tag?: string) { this.isScratchpad = true; - if (tag) { - const { selectedTag } = storeToRefs(useScratchpadStore()); - selectedTag.value = tag; - } + if (!tag) tag = 'all'; + const { selectedTag } = storeToRefs(useScratchpadStore()); + selectedTag.value = tag; }, hideScratchpad () { this.isScratchpad = false;