handle invalid perspective format

This commit is contained in:
Jan Prochazka
2022-09-01 10:10:19 +02:00
parent e3b833927d
commit 3e83a69ef7

View File

@@ -45,6 +45,7 @@
import { registerFileCommands } from '../commands/stdCommands'; import { registerFileCommands } from '../commands/stdCommands';
import _ from 'lodash'; import _ from 'lodash';
import ToolStripSaveButton from '../buttons/ToolStripSaveButton.svelte'; import ToolStripSaveButton from '../buttons/ToolStripSaveButton.svelte';
import ErrorInfo from '../elements/ErrorInfo.svelte';
export let tabid; export let tabid;
export let conid; export let conid;
@@ -52,6 +53,8 @@
export let schemaName; export let schemaName;
export let pureName; export let pureName;
let isFormatError;
export const activator = createActivator('PerspectiveTab', true); export const activator = createActivator('PerspectiveTab', true);
$: connection = useConnectionInfo({ conid }); $: connection = useConnectionInfo({ conid });
@@ -88,7 +91,11 @@
const { editorState, editorValue, setEditorData } = useEditorData({ const { editorState, editorValue, setEditorData } = useEditorData({
tabid, tabid,
onInitialData: value => { onInitialData: value => {
if (!value.nodes) {
isFormatError = true;
} else {
dispatchModel({ type: 'reset', value }); dispatchModel({ type: 'reset', value });
}
invalidateCommands(); invalidateCommands();
}, },
}); });
@@ -110,6 +117,9 @@
</script> </script>
<ToolStripContainer> <ToolStripContainer>
{#if isFormatError}
<ErrorInfo message="Invalid perspective format, please create new perspective" alignTop />
{:else}
<PerspectiveView <PerspectiveView
{conid} {conid}
{database} {database}
@@ -132,6 +142,7 @@
{cache} {cache}
{loadedCounts} {loadedCounts}
/> />
{/if}
<svelte:fragment slot="toolstrip"> <svelte:fragment slot="toolstrip">
<ToolStripCommandButton <ToolStripCommandButton