Skip to content

Commit

Permalink
tweak: autosave behavior in visual explore editor (#6208)
Browse files Browse the repository at this point in the history
* tweak: autosave behavior in visual explore editor

* remove unintended style
  • Loading branch information
briangregoryholmes authored Dec 5, 2024
1 parent 258151c commit fbda995
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions web-common/src/features/explores/ExploreEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
export let fileArtifact: FileArtifact;
export let autoSave: boolean;
export let lineBasedRuntimeErrors: LineStatus[];
export let forceLocalUpdates = false;
let editor: EditorView;
Expand All @@ -21,6 +22,7 @@
</script>

<Editor
{forceLocalUpdates}
bind:autoSave
bind:editor
onSave={(content) => {
Expand Down
2 changes: 2 additions & 0 deletions web-common/src/features/workspaces/ExploreWorkspace.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
{exploreName}
{fileArtifact}
{lineBasedRuntimeErrors}
forceLocalUpdates
/>
{:else if selectedView === "viz"}
{#if mainError}
Expand All @@ -127,6 +128,7 @@
</MetricsEditorContainer>

<VisualExploreEditing
autoSave={selectedView === "viz" || $autoSave}
slot="inspector"
exploreResource={exploreResource?.explore}
{metricsViewName}
Expand Down
14 changes: 11 additions & 3 deletions web-common/src/features/workspaces/VisualExploreEditing.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
export let exploreResource: V1Explore | undefined;
export let metricsViewName: string | undefined;
export let viewingDashboard: boolean;
export let autoSave: boolean;
export let switchView: () => void;
$: ({ instanceId } = $runtime);
$: ({ localContent, remoteContent, saveContent, path } = fileArtifact);
$: ({ localContent, remoteContent, saveContent, path, updateLocalContent } =
fileArtifact);
$: exploreSpec = exploreResource?.state?.validSpec;
Expand Down Expand Up @@ -241,7 +243,11 @@
killState();
await saveContent(parsedDocument.toString());
if (autoSave) {
await saveContent(parsedDocument.toString());
} else {
updateLocalContent(parsedDocument.toString(), true);
}
}
function killState() {
Expand Down Expand Up @@ -339,7 +345,9 @@

<Inspector filePath={path}>
<SidebarWrapper title="Edit dashboard">
<p class="text-slate-500 text-sm">Changes below will be auto-saved.</p>
{#if autoSave}
<p class="text-slate-500 text-sm">Changes below will be auto-saved.</p>
{/if}

<Input
hint="Shown in global header and when deployed to Rill Cloud"
Expand Down

1 comment on commit fbda995

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.