Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { directoryState } from "../file-explorer/directory-store";
import { createResourceFile } from "../file-explorer/new-files";
import { addSourceModal } from "../sources/modal/add-source-visibility";
import CreateExploreDialog from "./CreateExploreDialog.svelte";
import { removeLeadingSlash } from "./entity-mappers";
import {
useDirectoryNamesInDirectory,
Expand All @@ -34,7 +35,6 @@
resourceIconMapping,
} from "./resource-icon-mapping";
import { ResourceKind, useFilteredResources } from "./resource-selectors";
import CreateExploreDialog from "./CreateExploreDialog.svelte";

let active = false;
let showExploreDialog = false;
Expand Down
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
Loading