From b7c25c327e38da9613dd4f81b8f331aeccc7d47c Mon Sep 17 00:00:00 2001 From: Aditya Hegde Date: Tue, 3 Oct 2023 18:02:31 +0530 Subject: [PATCH 1/2] Fix undefined path in project errors --- .../features/projects/ProjectDeploymentLogs.svelte | 8 +++++--- .../src/features/projects/getProjectErrors.ts | 8 ++++++-- .../entity-management/resource-invalidations.ts | 14 +++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/web-admin/src/features/projects/ProjectDeploymentLogs.svelte b/web-admin/src/features/projects/ProjectDeploymentLogs.svelte index 1a931f7ca7b..6c33d4fda3a 100644 --- a/web-admin/src/features/projects/ProjectDeploymentLogs.svelte +++ b/web-admin/src/features/projects/ProjectDeploymentLogs.svelte @@ -45,9 +45,11 @@ {error.message} - - {error.filePath} - + {#if error.filePath} + + {error.filePath} + + {/if} {/each} {/if} diff --git a/web-admin/src/features/projects/getProjectErrors.ts b/web-admin/src/features/projects/getProjectErrors.ts index e2cc8f94841..f6ed2fbab65 100644 --- a/web-admin/src/features/projects/getProjectErrors.ts +++ b/web-admin/src/features/projects/getProjectErrors.ts @@ -1,3 +1,4 @@ +import { MainResourceKinds } from "@rilldata/web-common/features/entity-management/resource-invalidations"; import { useProjectParser } from "@rilldata/web-common/features/entity-management/resource-selectors"; import { createRuntimeServiceListResources, @@ -20,9 +21,12 @@ export function getProjectErrors( projectParserResp.data?.projectParser?.state?.parseErrors ?? []; const resourceErrors: Array = resourcesResp.data?.resources - ?.filter((r) => !!r.meta.reconcileError) + ?.filter( + (r) => + !!r.meta.reconcileError && MainResourceKinds[r.meta.name.kind] + ) .map((r) => ({ - filePath: r.meta.filePaths[0], + filePath: r.meta.filePaths[0], // TODO: handle multiple files mapping to same resource message: r.meta.reconcileError, })) ?? []; return [...projectParserErrors, ...resourceErrors]; diff --git a/web-common/src/features/entity-management/resource-invalidations.ts b/web-common/src/features/entity-management/resource-invalidations.ts index 0b7cea704c9..930e4f5f560 100644 --- a/web-common/src/features/entity-management/resource-invalidations.ts +++ b/web-common/src/features/entity-management/resource-invalidations.ts @@ -17,29 +17,29 @@ import { runtime } from "@rilldata/web-common/runtime-client/runtime-store"; import type { QueryClient } from "@tanstack/svelte-query"; import { get } from "svelte/store"; -const MainResources: { +export const MainResourceKinds: { [kind in ResourceKind]?: true; } = { [ResourceKind.Source]: true, [ResourceKind.Model]: true, [ResourceKind.MetricsView]: true, }; -const UsedResources: { +const UsedResourceKinds: { [kind in ResourceKind]?: true; } = { [ResourceKind.ProjectParser]: true, - ...MainResources, + ...MainResourceKinds, }; export function invalidateResourceResponse( queryClient: QueryClient, res: V1WatchResourcesResponse ) { - // only process for the `ResourceKind` present in `UsedResources` - if (!UsedResources[res.name.kind]) return; + // only process for the `ResourceKind` present in `UsedResourceKinds` + if (!UsedResourceKinds[res.name.kind]) return; // for main resources only invalidate if it became idle if ( - MainResources[res.name.kind] && + MainResourceKinds[res.name.kind] && res.resource.meta.reconcileStatus !== V1ReconcileStatus.RECONCILE_STATUS_IDLE ) @@ -62,7 +62,7 @@ export function invalidateResourceResponse( } // only re-fetch list queries for kinds in `MainResources` - if (!MainResources[res.name.kind]) return; + if (!MainResourceKinds[res.name.kind]) return; resourcesStore.setResource(res.resource); return queryClient.refetchQueries( // we only use individual kind's queries From 761343098357699f2af9bc8568b36e6f1a94ca3c Mon Sep 17 00:00:00 2001 From: Aditya Hegde Date: Tue, 3 Oct 2023 18:05:09 +0530 Subject: [PATCH 2/2] Fix prettier --- web-admin/src/features/projects/dashboards.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/web-admin/src/features/projects/dashboards.ts b/web-admin/src/features/projects/dashboards.ts index f472c28ebd7..94fe845aa1e 100644 --- a/web-admin/src/features/projects/dashboards.ts +++ b/web-admin/src/features/projects/dashboards.ts @@ -3,12 +3,7 @@ import { ResourceKind, useFilteredResources, } from "@rilldata/web-common/features/entity-management/resource-selectors"; -import type { - V1CatalogEntry, - V1MetricsView, - V1MetricsViewSpec, - V1Resource, -} from "@rilldata/web-common/runtime-client"; +import type { V1Resource } from "@rilldata/web-common/runtime-client"; import Axios from "axios"; export interface DashboardListItem {