From 35ed1ab061d77812d6d0bfa30788dbf7e957e92c Mon Sep 17 00:00:00 2001 From: Brian Holmes Date: Mon, 9 Dec 2024 12:00:40 -0500 Subject: [PATCH] fix: display parse errors on generic file workspaces --- .../metrics-views/editor/MetricsEditor.svelte | 6 ++-- .../editor/MetricsEditorContainer.svelte | 35 ------------------- .../workspaces/ExploreWorkspace.svelte | 6 ++-- .../workspace/WorkspaceEditorContainer.svelte | 34 +++++++++++++++--- .../(workspace)/files/[...file]/+page.svelte | 15 ++++++-- 5 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 web-common/src/features/metrics-views/editor/MetricsEditorContainer.svelte diff --git a/web-common/src/features/metrics-views/editor/MetricsEditor.svelte b/web-common/src/features/metrics-views/editor/MetricsEditor.svelte index e3ff9b8c351..ff9361c882f 100644 --- a/web-common/src/features/metrics-views/editor/MetricsEditor.svelte +++ b/web-common/src/features/metrics-views/editor/MetricsEditor.svelte @@ -10,9 +10,9 @@ import { FileArtifact } from "@rilldata/web-common/features/entity-management/file-artifact"; import { yamlSchema } from "codemirror-json-schema/yaml"; import type { JSONSchema7 } from "json-schema"; - import MetricsEditorContainer from "./MetricsEditorContainer.svelte"; import { createPlaceholder } from "./create-placeholder"; import metricsSchema from "./metrics-schema.json"; + import WorkspaceEditorContainer from "@rilldata/web-common/layout/workspace/WorkspaceEditorContainer.svelte"; export let filePath: string; export let metricsViewName: string; @@ -36,7 +36,7 @@ $: mainError = errors?.at(0); - + - + diff --git a/web-common/src/features/metrics-views/editor/MetricsEditorContainer.svelte b/web-common/src/features/metrics-views/editor/MetricsEditorContainer.svelte deleted file mode 100644 index 4d774d63510..00000000000 --- a/web-common/src/features/metrics-views/editor/MetricsEditorContainer.svelte +++ /dev/null @@ -1,35 +0,0 @@ - - - - -
-
- -
- - {#if error && showError} -
-
- {error.message} -
-
- {/if} -
diff --git a/web-common/src/features/workspaces/ExploreWorkspace.svelte b/web-common/src/features/workspaces/ExploreWorkspace.svelte index 921777f3921..8a6615a1a04 100644 --- a/web-common/src/features/workspaces/ExploreWorkspace.svelte +++ b/web-common/src/features/workspaces/ExploreWorkspace.svelte @@ -17,12 +17,12 @@ import { workspaces } from "@rilldata/web-common/layout/workspace/workspace-stores"; import ViewSelector from "@rilldata/web-common/features/visual-editing/ViewSelector.svelte"; import VisualExploreEditing from "./VisualExploreEditing.svelte"; - import MetricsEditorContainer from "../metrics-views/editor/MetricsEditorContainer.svelte"; import { mapParseErrorsToLines } from "../metrics-views/errors"; import ErrorPage from "@rilldata/web-common/components/ErrorPage.svelte"; import { createRuntimeServiceGetExplore } from "@rilldata/web-common/runtime-client"; import Spinner from "../entity-management/Spinner.svelte"; import DashboardWithProviders from "../dashboards/workspace/DashboardWithProviders.svelte"; + import WorkspaceEditorContainer from "@rilldata/web-common/layout/workspace/WorkspaceEditorContainer.svelte"; export let fileArtifact: FileArtifact; @@ -98,7 +98,7 @@ - {/if} {/if} - + - + + +
+
+ +
+ + {#if error && showError} +
+
+ {error.message} +
+
+ {/if}
diff --git a/web-local/src/routes/(application)/(workspace)/files/[...file]/+page.svelte b/web-local/src/routes/(application)/(workspace)/files/[...file]/+page.svelte index 76d4817a42c..d92d414af35 100644 --- a/web-local/src/routes/(application)/(workspace)/files/[...file]/+page.svelte +++ b/web-local/src/routes/(application)/(workspace)/files/[...file]/+page.svelte @@ -18,6 +18,8 @@ import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient.js"; import { onMount } from "svelte"; import { runtime } from "@rilldata/web-common/runtime-client/runtime-store"; + import type { PageData } from "./$types"; + import { mapParseErrorsToLines } from "@rilldata/web-common/features/metrics-views/errors"; const workspaces = new Map([ [ResourceKind.Source, SourceWorkspace], @@ -30,7 +32,7 @@ [undefined, null], ]); - export let data; + export let data: PageData; let editor: EditorView; @@ -44,7 +46,9 @@ resourceName, inferredResourceKind, path, + remoteContent, getResource, + getAllErrors, } = fileArtifact); $: resourceKind = $resourceName?.kind; @@ -60,6 +64,13 @@ ? [customYAMLwithJSONandSQL] : getExtensionsForFile(path); + $: allErrorsQuery = getAllErrors(queryClient, instanceId); + $: allErrors = $allErrorsQuery; + + $: errors = mapParseErrorsToLines(allErrors, $remoteContent ?? ""); + + $: mainError = errors?.at(0); + onMount(() => { expandDirectory(path); // TODO: Focus on the code editor @@ -93,7 +104,7 @@ filePath={path} hasUnsavedChanges={$hasUnsavedChanges} /> - +