refresh perspective command

This commit is contained in:
Jan Prochazka
2022-07-24 15:56:29 +02:00
parent 088ca231f3
commit 96106e6aac
3 changed files with 63 additions and 12 deletions

View File

@@ -1,10 +1,29 @@
<script lang="ts" context="module">
const getCurrentEditor = () => getActiveComponent('PerspectiveTab');
registerCommand({
id: 'perspective.refresh',
category: 'Perspective',
name: 'Refresh',
keyText: 'F5 | CtrlOrCommand+R',
toolbar: true,
isRelatedToTab: true,
icon: 'icon reload',
testEnabled: () => getCurrentEditor() != null,
onClick: () => getCurrentEditor().refresh(),
});
</script>
<script lang="ts">
import { PerspectiveCache } from 'dbgate-datalib';
import PerspectiveView from '../perspectives/PerspectiveView.svelte';
import usePerspectiveConfig from '../utility/usePerspectiveConfig';
import stableStringify from 'json-stable-stringify';
import { writable } from 'svelte/store';
import registerCommand from '../commands/registerCommand';
import createActivator, { getActiveComponent } from '../utility/createActivator';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
export let tabid;
export let conid;
@@ -12,18 +31,31 @@
export let schemaName;
export let pureName;
export const activator = createActivator('PerspectiveTab', true);
const config = usePerspectiveConfig(tabid);
const cache = new PerspectiveCache();
const loadedCounts = writable({});
export function refresh() {
cache.clear();
loadedCounts.set({});
}
</script>
<PerspectiveView
{conid}
{database}
{schemaName}
{pureName}
config={$config}
setConfig={config.update}
{cache}
{loadedCounts}
/>
<ToolStripContainer>
<PerspectiveView
{conid}
{database}
{schemaName}
{pureName}
config={$config}
setConfig={config.update}
{cache}
{loadedCounts}
/>
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="perspective.refresh" />
</svelte:fragment>
</ToolStripContainer>