diff --git a/app/src/mainMenuDefinition.js b/app/src/mainMenuDefinition.js index 40cc485d..bdb7aa87 100644 --- a/app/src/mainMenuDefinition.js +++ b/app/src/mainMenuDefinition.js @@ -9,9 +9,9 @@ module.exports = ({ editMenu }) => [ { command: 'new.queryDesign', hideDisabled: true }, { command: 'new.diagram', hideDisabled: true }, { command: 'new.perspective', hideDisabled: true }, - { command: 'new.freetable', hideDisabled: true }, { command: 'new.shell', hideDisabled: true }, { command: 'new.jsonl', hideDisabled: true }, + { command: 'new.modelTransform', hideDisabled: true }, { divider: true }, { command: 'file.open', hideDisabled: true }, { command: 'file.openArchive', hideDisabled: true }, diff --git a/packages/web/src/appobj/SavedFileAppObject.svelte b/packages/web/src/appobj/SavedFileAppObject.svelte index 89c468d6..23011a5b 100644 --- a/packages/web/src/appobj/SavedFileAppObject.svelte +++ b/packages/web/src/appobj/SavedFileAppObject.svelte @@ -81,6 +81,14 @@ currentConnection: true, }; + const modtrans: FileTypeHandler = { + icon: 'img transform', + format: 'text', + tabComponent: 'ModelTransformTab', + folder: 'modtrans', + currentConnection: false, + }; + export const SAVED_FILE_HANDLERS = { sql, shell, @@ -91,6 +99,7 @@ diagrams, perspectives, jobs, + modtrans, }; export const extractKey = data => data.file; diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index e9844321..abefa024 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -185,6 +185,50 @@ registerCommand({ findEngineDriver(getCurrentDatabase()?.connection, getExtensions())?.databaseEngineTypes?.includes('sql'), }); +if (isProApp()) { + registerCommand({ + id: 'new.modelTransform', + category: 'New', + icon: 'img transform', + name: 'Model transform', + menuName: 'New model transform', + onClick: () => { + openNewTab( + { + title: 'Model transform #', + icon: 'img transform', + tabComponent: 'ModelTransformTab', + }, + { + editor: JSON.stringify( + [ + { + transform: 'dataTypeMapperTransform', + arguments: ['json', 'nvarchar(max)'], + }, + { + transform: 'sqlTextReplacementTransform', + arguments: [ + { + oldval1: 'newval1', + oldval2: 'newval2', + }, + ], + }, + { + transform: 'autoIndexForeignKeysTransform', + arguments: [], + }, + ], + null, + 2 + ), + } + ); + }, + }); +} + registerCommand({ id: 'new.perspective', category: 'New', diff --git a/packages/web/src/icons/FontIcon.svelte b/packages/web/src/icons/FontIcon.svelte index 5aeca271..b501a0f4 100644 --- a/packages/web/src/icons/FontIcon.svelte +++ b/packages/web/src/icons/FontIcon.svelte @@ -283,6 +283,7 @@ 'img duplicator': 'mdi mdi-content-duplicate color-icon-green', 'img import': 'mdi mdi-database-import color-icon-green', 'img export': 'mdi mdi-database-export color-icon-green', + 'img transform': 'mdi mdi-rotate-orbit color-icon-blue', }; diff --git a/packages/web/src/widgets/SavedFilesList.svelte b/packages/web/src/widgets/SavedFilesList.svelte index 44d8da92..b487d03e 100644 --- a/packages/web/src/widgets/SavedFilesList.svelte +++ b/packages/web/src/widgets/SavedFilesList.svelte @@ -22,6 +22,7 @@ const diagramFiles = useFiles({ folder: 'diagrams' }); const jobFiles = useFiles({ folder: 'jobs' }); const perspectiveFiles = useFiles({ folder: 'perspectives' }); + const modelTransformFiles = useFiles({ folder: 'modtrans' }); $: files = [ ...($sqlFiles || []), @@ -33,13 +34,30 @@ ...($diagramFiles || []), ...($perspectiveFiles || []), ...($jobFiles || []), + ...($modelTransformFiles || []), ]; function handleRefreshFiles() { apiCall('files/refresh', { - folders: ['sql', 'shell', 'markdown', 'charts', 'query', 'sqlite', 'diagrams', 'perspectives', 'jobs'], + folders: [ + 'sql', + 'shell', + 'markdown', + 'charts', + 'query', + 'sqlite', + 'diagrams', + 'perspectives', + 'jobs', + 'modtrans', + ], }); } + + function dataFolderTitle(folder) { + if (folder == 'modtrans') return 'Model transforms'; + return _.startCase(folder); + } @@ -51,5 +69,5 @@ - _.startCase(data.folder)} {filter} /> + dataFolderTitle(data.folder)} {filter} />