From 68673a2d1741d6abaf328f79299c91b6d30a46d5 Mon Sep 17 00:00:00 2001 From: Dhiraj Kumar Date: Sat, 4 Jan 2025 00:28:05 +0530 Subject: [PATCH] Review --- .../canvas/components/charts/types.ts | 2 +- .../features/canvas/components/charts/util.ts | 6 +- .../canvas/inspector/ChartTypeSelector.svelte | 4 +- .../StateManagersProvider.svelte | 12 +- .../canvas/stores/CanvasStateProvider.svelte | 15 --- .../features/canvas/stores/syncCanvasState.ts | 5 +- .../workspaces/CanvasWorkspace.svelte | 105 +++++++++--------- .../routes/(viz)/canvas/[name]/+page.svelte | 17 ++- 8 files changed, 76 insertions(+), 90 deletions(-) delete mode 100644 web-common/src/features/canvas/stores/CanvasStateProvider.svelte diff --git a/web-common/src/features/canvas/components/charts/types.ts b/web-common/src/features/canvas/components/charts/types.ts index 84e54474cbe..4ab51c96bb2 100644 --- a/web-common/src/features/canvas/components/charts/types.ts +++ b/web-common/src/features/canvas/components/charts/types.ts @@ -21,7 +21,7 @@ export interface ChartConfig { export type ChartType = "line_chart" | "bar_chart" | "stacked_bar"; export interface ChartMetadata { - id: ChartType; + type: ChartType; icon: ComponentType; title: string; } diff --git a/web-common/src/features/canvas/components/charts/util.ts b/web-common/src/features/canvas/components/charts/util.ts index 1e8f5e69595..b4f9e0b06d8 100644 --- a/web-common/src/features/canvas/components/charts/util.ts +++ b/web-common/src/features/canvas/components/charts/util.ts @@ -25,7 +25,7 @@ export function generateSpec( } export const chartMetadata: ChartMetadata[] = [ - { id: "line_chart", title: "Line", icon: LineChart }, - { id: "bar_chart", title: "Bar", icon: BarChart }, - { id: "stacked_bar", title: "Stacked Bar", icon: StackedBar }, + { type: "line_chart", title: "Line", icon: LineChart }, + { type: "bar_chart", title: "Bar", icon: BarChart }, + { type: "stacked_bar", title: "Stacked Bar", icon: StackedBar }, ]; diff --git a/web-common/src/features/canvas/inspector/ChartTypeSelector.svelte b/web-common/src/features/canvas/inspector/ChartTypeSelector.svelte index 9cf4b78ce4b..81ad27ece35 100644 --- a/web-common/src/features/canvas/inspector/ChartTypeSelector.svelte +++ b/web-common/src/features/canvas/inspector/ChartTypeSelector.svelte @@ -13,7 +13,7 @@ export let component: CanvasComponentObj; async function selectChartType(chartType: ChartMetadata) { - component.updateChartType(chartType.id); + component.updateChartType(chartType.type); } @@ -26,7 +26,7 @@ square small type="secondary" - selected={componentType === chart.id} + selected={componentType === chart.type} on:click={() => selectChartType(chart)} > diff --git a/web-common/src/features/canvas/state-managers/StateManagersProvider.svelte b/web-common/src/features/canvas/state-managers/StateManagersProvider.svelte index fa4f11ce50f..df368c764c2 100644 --- a/web-common/src/features/canvas/state-managers/StateManagersProvider.svelte +++ b/web-common/src/features/canvas/state-managers/StateManagersProvider.svelte @@ -1,4 +1,6 @@ - +{#if canvasStoreReady.isFetching} +
+ +
+{:else} + +{/if} diff --git a/web-common/src/features/canvas/stores/CanvasStateProvider.svelte b/web-common/src/features/canvas/stores/CanvasStateProvider.svelte deleted file mode 100644 index 534aefe2dfb..00000000000 --- a/web-common/src/features/canvas/stores/CanvasStateProvider.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - -{#if canvasStoreReady.isFetching} -
- -
-{:else} - -{/if} diff --git a/web-common/src/features/canvas/stores/syncCanvasState.ts b/web-common/src/features/canvas/stores/syncCanvasState.ts index ed55ba08ce0..28e47e17b5f 100644 --- a/web-common/src/features/canvas/stores/syncCanvasState.ts +++ b/web-common/src/features/canvas/stores/syncCanvasState.ts @@ -1,9 +1,6 @@ -import type { StateManagers } from "@rilldata/web-common/features/canvas/state-managers/state-managers"; import { canvasEntities } from "@rilldata/web-common/features/canvas/stores/canvas-entities"; -import { get } from "svelte/store"; -export function createCanvasStateSync(ctx: StateManagers) { - const canvasName = get(ctx.canvasName); +export function createCanvasStateSync(canvasName: string) { if (canvasEntities.hasCanvas(canvasName)) { // TODO: Add sync method if required return { isFetching: false, error: false }; diff --git a/web-common/src/features/workspaces/CanvasWorkspace.svelte b/web-common/src/features/workspaces/CanvasWorkspace.svelte index 5ab7782aa48..ccb80a45e28 100644 --- a/web-common/src/features/workspaces/CanvasWorkspace.svelte +++ b/web-common/src/features/workspaces/CanvasWorkspace.svelte @@ -10,7 +10,6 @@ import VisualCanvasEditing from "@rilldata/web-common/features/canvas/inspector/VisualCanvasEditing.svelte"; import { useDefaultMetrics } from "@rilldata/web-common/features/canvas/selector"; import StateManagersProvider from "@rilldata/web-common/features/canvas/state-managers/StateManagersProvider.svelte"; - import CanvasStateProvider from "@rilldata/web-common/features/canvas/stores/CanvasStateProvider.svelte"; import DelayedSpinner from "@rilldata/web-common/features/entity-management/DelayedSpinner.svelte"; import { getNameFromFile } from "@rilldata/web-common/features/entity-management/entity-mappers"; import type { FileArtifact } from "@rilldata/web-common/features/entity-management/file-artifact"; @@ -127,62 +126,60 @@ {#if canvasResource && fileArtifact} {#key canvasName} - - - - -
- 0 || resourceIsReconciling} - reconciling={resourceIsReconciling} + + + +
+ 0 || resourceIsReconciling} + reconciling={resourceIsReconciling} + /> + + + +
+
+ + + {#if selectedView === "code"} + + {:else if selectedView === "viz"} + {#if mainError} + - - - -
-
- - - {#if selectedView === "code"} - - {:else if selectedView === "viz"} - {#if mainError} - - {:else if canvasResource} - - {/if} + {:else if canvasResource} + {/if} - + {/if} + - -
-
-
+ + +
{/key} {:else if allErrors.length} diff --git a/web-local/src/routes/(viz)/canvas/[name]/+page.svelte b/web-local/src/routes/(viz)/canvas/[name]/+page.svelte index bd5418bb05e..c02204b58ce 100644 --- a/web-local/src/routes/(viz)/canvas/[name]/+page.svelte +++ b/web-local/src/routes/(viz)/canvas/[name]/+page.svelte @@ -2,7 +2,6 @@ import CanvasDashboardEmbed from "@rilldata/web-common/features/canvas/CanvasDashboardEmbed.svelte"; import CanvasThemeProvider from "@rilldata/web-common/features/canvas/CanvasThemeProvider.svelte"; import StateManagersProvider from "@rilldata/web-common/features/canvas/state-managers/StateManagersProvider.svelte"; - import CanvasStateProvider from "@rilldata/web-common/features/canvas/stores/CanvasStateProvider.svelte"; import type { PageData } from "./$types"; export let data: PageData; @@ -13,13 +12,11 @@ - - - - - + + +