diff --git a/web-common/src/features/entity-management/AddAssetButton.svelte b/web-common/src/features/entity-management/AddAssetButton.svelte index e31119eaeff..49630a071f3 100644 --- a/web-common/src/features/entity-management/AddAssetButton.svelte +++ b/web-common/src/features/entity-management/AddAssetButton.svelte @@ -85,7 +85,6 @@ */ async function handleAddSource() { addSourceModal.open(); - featureFlags.set(true, "sourceImportedModal"); await behaviourEvent?.fireSourceTriggerEvent( BehaviourEventAction.SourceAdd, diff --git a/web-common/src/features/entity-management/WatchResourcesClient.ts b/web-common/src/features/entity-management/WatchResourcesClient.ts index 3815c7892d9..3f1245cef18 100644 --- a/web-common/src/features/entity-management/WatchResourcesClient.ts +++ b/web-common/src/features/entity-management/WatchResourcesClient.ts @@ -21,8 +21,8 @@ import { runtime } from "@rilldata/web-common/runtime-client/runtime-store"; import { WatchRequestClient } from "@rilldata/web-common/runtime-client/watch-request-client"; import { get } from "svelte/store"; import { connectorExplorerStore } from "../connectors/connector-explorer-store"; -import { featureFlags } from "../feature-flags"; import { sourceImportedPath } from "../sources/sources-store"; +import { isLeafResource } from "./dag-utils"; export class WatchResourcesClient { public readonly client: WatchRequestClient; @@ -35,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) { @@ -186,11 +186,9 @@ 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"; - const showSourceImportedModal = get( - featureFlags.sourceImportedModal, - ); // This will be false when unpacking example projects - if (isNewSource && showSourceImportedModal) { + 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); } diff --git a/web-common/src/features/entity-management/dag-utils.ts b/web-common/src/features/entity-management/dag-utils.ts new file mode 100644 index 00000000000..005e1e16368 --- /dev/null +++ b/web-common/src/features/entity-management/dag-utils.ts @@ -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; +} diff --git a/web-common/src/features/feature-flags.ts b/web-common/src/features/feature-flags.ts index 9fda4a50fb7..fca78de3634 100644 --- a/web-common/src/features/feature-flags.ts +++ b/web-common/src/features/feature-flags.ts @@ -30,7 +30,6 @@ type FeatureFlagKey = keyof Omit; class FeatureFlags { adminServer = new FeatureFlag("rill", false); readOnly = new FeatureFlag("rill", false); - sourceImportedModal = new FeatureFlag("rill", true); ai = new FeatureFlag("user", !import.meta.env.VITE_PLAYWRIGHT_TEST); exports = new FeatureFlag("user", true); diff --git a/web-common/src/features/welcome/ProjectCards.svelte b/web-common/src/features/welcome/ProjectCards.svelte index 77412a58f27..192343b5f80 100644 --- a/web-common/src/features/welcome/ProjectCards.svelte +++ b/web-common/src/features/welcome/ProjectCards.svelte @@ -15,7 +15,6 @@ createRuntimeServiceUnpackExample, } from "../../runtime-client"; import { runtime } from "../../runtime-client/runtime-store"; - import { featureFlags } from "../feature-flags"; import { EMPTY_PROJECT_TITLE } from "./constants"; const unpackExampleProject = createRuntimeServiceUnpackExample(); @@ -102,7 +101,6 @@ disabled={!!selectedProjectName} isLoading={selectedProjectName === example.name} on:click={async () => { - featureFlags.set(false, "sourceImportedModal"); await unpackProject(example); }} >