Skip to content

Commit

Permalink
Don't show the "Source imported successfully" modal when unpacking ex…
Browse files Browse the repository at this point in the history
…ample projects (#6260)

* Don't show the "Source imported successfully" modal when unpacking example projects

* Review
  • Loading branch information
ericpgreen2 committed Dec 13, 2024
1 parent 1d52dc8 commit c7761a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { WatchRequestClient } from "@rilldata/web-common/runtime-client/watch-re
import { get } from "svelte/store";
import { connectorExplorerStore } from "../connectors/connector-explorer-store";
import { sourceImportedPath } from "../sources/sources-store";
import { isLeafResource } from "./dag-utils";

export class WatchResourcesClient {
public readonly client: WatchRequestClient<V1WatchResourcesResponse>;
Expand All @@ -34,7 +35,7 @@ export class WatchResourcesClient {
this.client.on("reconnect", () => this.invalidateAllRuntimeQueries());
}

private handleWatchResourceResponse(res: V1WatchResourcesResponse) {
private async handleWatchResourceResponse(res: V1WatchResourcesResponse) {
// Log resource status to the browser console during e2e tests. Currently, our e2e tests make assertions
// based on these logs. However, the e2e tests really should make UI-based assertions.
if (import.meta.env.VITE_PLAYWRIGHT_TEST) {
Expand Down Expand Up @@ -185,7 +186,8 @@ export class WatchResourcesClient {
// If it's a new source, show the "Source imported successfully" modal
const isNewSource =
res.name.kind === ResourceKind.Source &&
res.resource.meta.specVersion === "1";
res.resource.meta.specVersion === "1" &&
(await isLeafResource(res.resource, this.instanceId)); // Protects against existing projects reconciling anew
if (isNewSource) {
const filePath = res.resource?.meta?.filePaths?.[0] as string;
sourceImportedPath.set(filePath);
Expand Down
21 changes: 21 additions & 0 deletions web-common/src/features/entity-management/dag-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
getRuntimeServiceListResourcesQueryKey,
runtimeServiceListResources,
type V1Resource,
} from "@rilldata/web-common/runtime-client";
import { queryClient } from "../../lib/svelte-query/globalQueryClient";

export async function isLeafResource(resource: V1Resource, instanceId: string) {
const allResources = await queryClient.fetchQuery({
queryKey: getRuntimeServiceListResourcesQueryKey(instanceId, undefined),
queryFn: () => runtimeServiceListResources(instanceId, undefined),
});

if (!allResources || !allResources.resources) return false;

const hasDownstreamResource = allResources.resources.some((r: V1Resource) =>
r.meta?.refs?.some((ref) => ref.name === resource.meta?.name?.name),
);

return !hasDownstreamResource;
}
8 changes: 5 additions & 3 deletions web-common/src/features/welcome/ProjectCards.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import AddCircleOutline from "@rilldata/web-common/components/icons/AddCircleOutline.svelte";
import Subheading from "@rilldata/web-common/components/typography/Subheading.svelte";
import Card from "../../components/card/Card.svelte";
import CardDescription from "../../components/card/CardDescription.svelte";
Expand All @@ -9,11 +10,12 @@
BehaviourEventMedium,
} from "../../metrics/service/BehaviourEventTypes";
import { MetricsEventSpace } from "../../metrics/service/MetricsTypes";
import { createRuntimeServiceUnpackExample } from "../../runtime-client";
import {
createRuntimeServiceUnpackEmpty,
createRuntimeServiceUnpackExample,
} from "../../runtime-client";
import { runtime } from "../../runtime-client/runtime-store";
import { EMPTY_PROJECT_TITLE } from "./constants";
import AddCircleOutline from "@rilldata/web-common/components/icons/AddCircleOutline.svelte";
import { createRuntimeServiceUnpackEmpty } from "../../runtime-client";
const unpackExampleProject = createRuntimeServiceUnpackExample();
const unpackEmptyProject = createRuntimeServiceUnpackEmpty();
Expand Down

2 comments on commit c7761a4

@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.

@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.

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://675bc81759e03483c5320e46--rill-ui.netlify.app

Please sign in to comment.