mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 03:36:01 +00:00
save archive algorithm
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
<script lang="ts" context="module">
|
||||
export const matchingProps = ['archiveFile', 'archiveFolder', 'jslid'];
|
||||
|
||||
const getCurrentEditor = () => getActiveComponent('ArchiveFileTab');
|
||||
|
||||
registerCommand({
|
||||
id: 'archiveFile.save',
|
||||
group: 'save',
|
||||
category: 'Archive file',
|
||||
name: 'Save',
|
||||
toolbar: true,
|
||||
isRelatedToTab: true,
|
||||
icon: 'icon save',
|
||||
testEnabled: () => getCurrentEditor()?.canSave(),
|
||||
onClick: () => getCurrentEditor().save(),
|
||||
});
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -10,12 +24,18 @@
|
||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||
import invalidateCommands from '../commands/invalidateCommands';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import runCommand from '../commands/runCommand';
|
||||
|
||||
import JslDataGrid from '../datagrid/JslDataGrid.svelte';
|
||||
import useEditorData from '../query/useEditorData';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { markTabSaved, markTabUnsaved } from '../utility/common';
|
||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||
import createUndoReducer from '../utility/createUndoReducer';
|
||||
|
||||
export const activator = createActivator('ArchiveFileTab', true);
|
||||
|
||||
export let archiveFolder = undefined;
|
||||
export let archiveFile = undefined;
|
||||
export let jslid = undefined;
|
||||
@@ -45,6 +65,20 @@
|
||||
markTabSaved(tabid);
|
||||
}
|
||||
}
|
||||
|
||||
export async function save() {
|
||||
await apiCall('archive/save-change-set', {
|
||||
folder: archiveFolder,
|
||||
file: archiveFile,
|
||||
changeSet: $changeSetStore.value,
|
||||
});
|
||||
dispatchChangeSet({ type: 'reset', value: createChangeSet() });
|
||||
runCommand('dataGrid.refresh');
|
||||
}
|
||||
|
||||
export function canSave() {
|
||||
return changeSetContainsChanges($changeSetStore?.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<ToolStripContainer>
|
||||
@@ -58,5 +92,6 @@
|
||||
<svelte:fragment slot="toolstrip">
|
||||
<ToolStripCommandButton command="dataGrid.refresh" />
|
||||
<ToolStripExportButton command="jslTableGrid.export" {quickExportHandlerRef} />
|
||||
<ToolStripCommandButton command="archiveFile.save" />
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
|
||||
Reference in New Issue
Block a user