Skip to content

Commit

Permalink
Remove old canvas deprecated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
djbarnwal committed Dec 18, 2024
1 parent 871b1a8 commit f237dde
Show file tree
Hide file tree
Showing 39 changed files with 70 additions and 396 deletions.
2 changes: 2 additions & 0 deletions runtime/compilers/rillv1/parse_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func (p *Parser) parseComponentYAML(tmp *ComponentYAML) (*runtimev1.ComponentSpe
break
}


// TODO: Activate validation later when in prod
// if err := componentTemplateSchema.Validate(map[string]any{renderer: props}); err != nil {
// return nil, nil, fmt.Errorf(`failed to validate renderer %q: %w`, renderer, err)
// }
Expand Down
9 changes: 4 additions & 5 deletions web-admin/src/features/embeds/CanvasEmbed.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
export let instanceId: string;
export let canvasName: string;
// TODO: Remove later
let columns = 12;
let gap = 4;
$: canvasQuery = useResource(instanceId, canvasName, ResourceKind.Canvas);
$: canvas = $canvasQuery.data?.canvas.spec;
$: ({
items = [],
columns,
gap,
} = canvas || { items: [], columns: 24, gap: 2 });
$: ({ items = [] } = canvas || { items: [], columns: 24, gap: 2 });
</script>

<CanvasDashboardEmbed {canvasName} {columns} {items} {gap} />
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
$: canvas = $canvasQuery.data?.canvas.spec;
$: ({
items = [],
columns,
gap,
} = canvas || { items: [], columns: 24, gap: 2 });
// TODO: Remove later
let columns = 12;
let gap = 4;
$: ({ items = [] } = canvas || { items: [], columns: 24, gap: 2 });
</script>

<CanvasDashboardEmbed {canvasName} {columns} {items} {gap} />
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import CancelCircle from "@rilldata/web-common/components/icons/CancelCircle.svelte";
import { getRillTheme } from "@rilldata/web-common/features/canvas-components/render/vega-config";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import {
type EmbedOptions,
Expand All @@ -10,7 +9,8 @@
type VisualizationSpec,
} from "svelte-vega";
import { get } from "svelte/store";
import type { ExpressionFunction, VLTooltipFormatter } from "../types";
import type { ExpressionFunction, VLTooltipFormatter } from "./types";
import { getRillTheme } from "./vega-config";
import { VegaLiteTooltipHandler } from "./vega-tooltip";
export let data: Record<string, unknown> = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script lang="ts">
import CancelCircle from "@rilldata/web-common/components/icons/CancelCircle.svelte";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { get } from "svelte/store";
import { onDestroy } from "svelte";
import {
type EmbedOptions,
type SignalListeners,
Vega,
type View,
type VisualizationSpec,
type EmbedOptions,
} from "svelte-vega";
import type { ExpressionFunction, VLTooltipFormatter } from "../types";
import { VegaLiteTooltipHandler } from "./vega-tooltip";
import { onDestroy } from "svelte";
import { get } from "svelte/store";
import type { ExpressionFunction, VLTooltipFormatter } from "./types";
import { getRillTheme } from "./vega-config";
import { VegaLiteTooltipHandler } from "./vega-tooltip";
export let data: Record<string, unknown> = {};
export let spec: VisualizationSpec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TDDChart } from "@rilldata/web-common/features/dashboards/time-dimension-details/types";

// TODO: Consolidate with Canvas components types
/**
* Type definitions for common chart types supported by Vega
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
mouseLocationToBoundingRect,
placeElement,
} from "@rilldata/web-common/lib/place-element";
import type {
Alignment,
Location,
} from "@rilldata/web-common/lib/place-element";
import {
mouseLocationToBoundingRect,
placeElement,
} from "@rilldata/web-common/lib/place-element";
import type { View } from "svelte-vega";
import type { VLTooltipFormatter } from "../types";
import type { VLTooltipFormatter } from "./types";

const TOOLTIP_ID = "rill-vg-tooltip";

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<script lang="ts">
import CancelCircle from "@rilldata/web-common/components/icons/CancelCircle.svelte";
import {
chartPromptsStore,
ChartPromptStatus,
} from "@rilldata/web-common/features/canvas-components/prompt/chartPrompt";
import Spinner from "@rilldata/web-common/features/entity-management/Spinner.svelte";
import { EntityStatus } from "@rilldata/web-common/features/entity-management/types";
import { chartPromptsStore, ChartPromptStatus } from "./prompt/chartPrompt";
export let componentName: string;
export let isFetching: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { goto } from "$app/navigation";
import { Button } from "@rilldata/web-common/components/button";
import PanelCTA from "@rilldata/web-common/components/panel/PanelCTA.svelte";
import GenerateVegaSpecPrompt from "@rilldata/web-common/features/canvas-components/prompt/GenerateVegaSpecPrompt.svelte";
import {
extractFileName,
splitFolderAndFileName,
Expand All @@ -11,6 +10,7 @@
import { handleEntityRename } from "@rilldata/web-common/features/entity-management/ui-actions";
import { WorkspaceHeader } from "@rilldata/web-common/layout/workspace";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import GenerateVegaSpecPrompt from "./prompt/GenerateVegaSpecPrompt.svelte";
export let filePath: string;
export let hasUnsavedChanges: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { Button } from "@rilldata/web-common/components/button";
import RefreshIcon from "@rilldata/web-common/components/icons/RefreshIcon.svelte";
import { chartPromptsStore } from "@rilldata/web-common/features/canvas-components/prompt/chartPrompt";
import { createEventDispatcher } from "svelte";
import { chartPromptsStore } from "./chartPrompt";
export let entityName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import { Button } from "@rilldata/web-common/components/button";
import * as Dialog from "@rilldata/web-common/components/dialog-v2";
import Input from "@rilldata/web-common/components/forms/Input.svelte";
import ChartPromptHistoryDisplay from "@rilldata/web-common/features/canvas-components/prompt/ChartPromptHistoryDisplay.svelte";
import { createFullChartGenerator } from "@rilldata/web-common/features/canvas-components/prompt/generateChart";
import { useAllFileNames } from "@rilldata/web-common/features/entity-management/file-selectors";
import { getName } from "@rilldata/web-common/features/entity-management/name-utils";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { useQueryClient } from "@tanstack/svelte-query";
import ChartPromptHistoryDisplay from "./ChartPromptHistoryDisplay.svelte";
import { createFullChartGenerator } from "./generateChart";
export let open: boolean;
export let table: string = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { Button } from "@rilldata/web-common/components/button";
import * as Dialog from "@rilldata/web-common/components/dialog-v2";
import Input from "@rilldata/web-common/components/forms/Input.svelte";
import ChartPromptHistoryDisplay from "@rilldata/web-common/features/canvas-components/prompt/ChartPromptHistoryDisplay.svelte";
import { createChartGenerator } from "@rilldata/web-common/features/canvas-components/prompt/generateChart";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import ChartPromptHistoryDisplay from "./ChartPromptHistoryDisplay.svelte";
import { createChartGenerator } from "./generateChart";
export let open: boolean;
export let chart: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChartPromptStatus } from "@rilldata/web-common/features/canvas-components/prompt/chartPrompt";
import { type Readable, type Updater, writable } from "svelte/store";
import type { ChartPromptStatus } from "./chartPrompt";

export type ChartPromptState = {
charts: Record<string, ChartPromptStatus>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getChartYaml } from "@rilldata/web-common/features/canvas-components/chartYaml";
import { describe, expect, it } from "vitest";
import { getChartYaml } from "../chartYaml";

const VegaLiteSpec = `{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import { goto } from "$app/navigation";
import {
getChartYaml,
parseChartYaml,
} from "@rilldata/web-common/features/canvas-components/chartYaml";
import {
ChartPromptStatus,
chartPromptsStore,
} from "@rilldata/web-common/features/canvas-components/prompt/chartPrompt";
import { useComponent } from "@rilldata/web-common/features/canvas-components/selectors";
import { getFileAPIPathFromNameAndType } from "@rilldata/web-common/features/entity-management/entity-mappers";
import { EntityType } from "@rilldata/web-common/features/entity-management/types";
import {
Expand All @@ -18,6 +9,9 @@ import {
runtimeServicePutFile,
} from "@rilldata/web-common/runtime-client";
import { get } from "svelte/store";
import { getChartYaml, parseChartYaml } from "../chartYaml";
import { useComponent } from "../selectors";
import { ChartPromptStatus, chartPromptsStore } from "./chartPrompt";

export function createChartGenerator(
instanceId: string,
Expand Down
10 changes: 7 additions & 3 deletions web-common/src/features/canvas/Canvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
$: selectedIndex = $canvasStore?.selectedComponentIndex;
let showGrid = true;
// TODO: Remove later when we move to new tiling system
const columns = 24;
const gap = 1;
let spec: V1CanvasSpec = {
columns: 20,
gap: 4,
items: [],
};
$: ({
saveLocalContent: updateComponentFile,
autoSave,
Expand All @@ -25,7 +29,7 @@
$: spec = structuredClone($validSpecStore ?? spec);
$: ({ items = [], columns = 20, gap = 4, variables = [] } = spec);
$: ({ items = [], variables = [] } = spec);

Check failure on line 32 in web-common/src/features/canvas/Canvas.svelte

View workflow job for this annotation

GitHub Actions / build

'variables' is assigned a value but never used
async function handleDeleteEvent(
e: CustomEvent<{
Expand Down
11 changes: 1 addition & 10 deletions web-common/src/features/canvas/CanvasDashboardEmbed.svelte
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<script lang="ts">
import {
type V1CanvasItem,
type V1ComponentVariable,
} from "@rilldata/web-common/runtime-client";
import { type V1CanvasItem } from "@rilldata/web-common/runtime-client";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { setContext } from "svelte";
import Component from "./Component.svelte";
import * as defaults from "./constants";
import DashboardWrapper from "./DashboardWrapper.svelte";
import { canvasVariablesStore } from "./variables-store";
export let canvasName: string;
export let columns = 20;
export let items: V1CanvasItem[];
export let gap = 4;
export let chartView = false;
export let variables: V1ComponentVariable[] = [];
let contentRect: DOMRectReadOnly = new DOMRectReadOnly(0, 0, 0, 0);
setContext("rill::canvas:name", canvasName);
Expand All @@ -36,10 +31,6 @@
const bottom = Number(el.height) + Number(el.y);
return Math.max(max, bottom);
}, 0);
$: if (variables.length && canvasName) {
canvasVariablesStore.init(canvasName, variables);
}
</script>

<DashboardWrapper
Expand Down
37 changes: 16 additions & 21 deletions web-common/src/features/canvas/CanvasThemeProvider.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<script lang="ts">
// import { page } from "$app/stores";
// import { getStateManagers } from "@rilldata/web-common/features/canvas/state-managers/state-managers";
// import { setTheme } from "@rilldata/web-common/features/themes/actions";
// import { useTheme } from "@rilldata/web-common/features/themes/selectors";
// import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
// import { onMount } from "svelte";
import { page } from "$app/stores";
import { getCanvasStateManagers } from "@rilldata/web-common/features/canvas/state-managers/state-managers";
import { setTheme } from "@rilldata/web-common/features/themes/actions";
import { useTheme } from "@rilldata/web-common/features/themes/selectors";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { onMount } from "svelte";
// const { validSpecStore } = getStateManagers();
// $: themeFromUrl = $page.url.searchParams.get("theme");
const { validSpecStore } = getCanvasStateManagers();
$: themeFromUrl = $page.url.searchParams.get("theme");
// let theme: ReturnType<typeof useTheme>;
// $: themeName = themeFromUrl ?? $validSpecStore?.theme
// $: if (themeName) theme = useTheme($runtime.instanceId, themeName);
let theme: ReturnType<typeof useTheme>;
$: themeName = themeFromUrl ?? $validSpecStore?.theme;
$: if (themeName) theme = useTheme($runtime.instanceId, themeName);
// $: setTheme(
// $theme?.data?.theme?.spec ?? $validSpecStore?.embeddedTheme,
// );
$: setTheme($theme?.data?.theme?.spec ?? $validSpecStore?.embeddedTheme);
// onMount(() => {
// // Handle the case where we have data in cache but the dashboard is not mounted yet
// setTheme(
// $theme?.data?.theme?.spec ??
// $validSpecStore?.data?.explore?.embeddedTheme,
// );
// });
onMount(() => {
// Handle the case where we have data in cache but the dashboard is not mounted yet
setTheme($theme?.data?.theme?.spec ?? $validSpecStore?.embeddedTheme);
});
</script>

<slot />
Loading

0 comments on commit f237dde

Please sign in to comment.