Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpgreen2 committed Dec 13, 2024
1 parent 77e5775 commit 7da9129
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
*/
async function handleAddSource() {
addSourceModal.open();
featureFlags.set(true, "sourceImportedModal");
await behaviourEvent?.fireSourceTriggerEvent(
BehaviourEventAction.SourceAdd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<V1WatchResourcesResponse>;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
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;
}
1 change: 0 additions & 1 deletion web-common/src/features/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type FeatureFlagKey = keyof Omit<FeatureFlags, "set">;
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);
Expand Down
2 changes: 0 additions & 2 deletions web-common/src/features/welcome/ProjectCards.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -102,7 +101,6 @@
disabled={!!selectedProjectName}
isLoading={selectedProjectName === example.name}
on:click={async () => {
featureFlags.set(false, "sourceImportedModal");
await unpackProject(example);
}}
>
Expand Down

0 comments on commit 7da9129

Please sign in to comment.