Skip to content

Commit

Permalink
Fix "Source imported successfully" modal (#6235)
Browse files Browse the repository at this point in the history
* Fix "Source imported successfully" modal

* Fix test
  • Loading branch information
ericpgreen2 committed Dec 10, 2024
1 parent 04eed6c commit 1d52dc8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 93 deletions.
10 changes: 10 additions & 0 deletions web-common/src/features/entity-management/WatchResourcesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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 { sourceImportedPath } from "../sources/sources-store";

export class WatchResourcesClient {
public readonly client: WatchRequestClient<V1WatchResourcesResponse>;
Expand Down Expand Up @@ -181,6 +182,15 @@ export class WatchResourcesClient {
// The following invalidations are only needed if the Source/Model has an active table
if (!connectorName || !tableName) return;

// If it's a new source, show the "Source imported successfully" modal
const isNewSource =
res.name.kind === ResourceKind.Source &&
res.resource.meta.specVersion === "1";
if (isNewSource) {
const filePath = res.resource?.meta?.filePaths?.[0] as string;
sourceImportedPath.set(filePath);
}

// Invalidate the model partitions query
if ((res.name.kind as ResourceKind) === ResourceKind.Model) {
void queryClient.invalidateQueries(
Expand Down
5 changes: 0 additions & 5 deletions web-common/src/features/sources/modal/FileDrop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import Overlay from "@rilldata/web-common/components/overlay/Overlay.svelte";
import { getFilePathFromNameAndType } from "@rilldata/web-common/features/entity-management/entity-mappers";
import { EntityType } from "@rilldata/web-common/features/entity-management/types";
import { checkSourceImported } from "@rilldata/web-common/features/sources/source-imported-utils";
import { createRuntimeServiceUnpackEmpty } from "@rilldata/web-common/runtime-client";
import { useQueryClient } from "@tanstack/svelte-query";
import { runtime } from "../../../runtime-client/runtime-store";
import { EMPTY_PROJECT_TITLE } from "../../welcome/constants";
import { isProjectInitialized } from "../../welcome/is-project-initialized";
Expand All @@ -15,8 +13,6 @@
export let showDropOverlay: boolean;
const queryClient = useQueryClient();
$: ({ instanceId } = $runtime);
const unpackEmptyProject = createRuntimeServiceUnpackEmpty();
Expand Down Expand Up @@ -55,7 +51,6 @@
tableName,
EntityType.Table,
);
await checkSourceImported(queryClient, newFilePath);
await goto(`/files${newFilePath}`);
} catch (err) {
console.error(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
openFileUploadDialog,
uploadTableFiles,
} from "@rilldata/web-common/features/sources/modal/file-upload";
import { checkSourceImported } from "@rilldata/web-common/features/sources/source-imported-utils";
import { overlay } from "@rilldata/web-common/layout/overlay-store";
import { createRuntimeServiceUnpackEmpty } from "@rilldata/web-common/runtime-client";
import { useQueryClient } from "@tanstack/svelte-query";
import { createEventDispatcher } from "svelte";
import { runtime } from "../../../runtime-client/runtime-store";
import { EMPTY_PROJECT_TITLE } from "../../welcome/constants";
Expand All @@ -19,7 +17,6 @@
import { createSource } from "./createSource";
const dispatch = createEventDispatcher();
const queryClient = useQueryClient();
$: ({ instanceId } = $runtime);
Expand Down Expand Up @@ -55,7 +52,6 @@
tableName,
EntityType.Table,
);
await checkSourceImported(queryClient, newFilePath);
await goto(`/files${newFilePath}`);
} catch (err) {
console.error(err);
Expand Down
3 changes: 0 additions & 3 deletions web-common/src/features/sources/modal/submitAddDataForm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { goto, invalidate } from "$app/navigation";
import { getScreenNameFromPage } from "@rilldata/web-common/features/file-explorer/telemetry";
import { checkSourceImported } from "@rilldata/web-common/features/sources/source-imported-utils";
import type { QueryClient } from "@tanstack/query-core";
import { get } from "svelte/store";
import { behaviourEvent } from "../../../metrics/initMetrics";
Expand Down Expand Up @@ -116,8 +115,6 @@ export async function submitAddDataForm(
createOnly: false,
});

await checkSourceImported(queryClient, newSourceFilePath);

await goto(`/files/${newSourceFilePath}`);

return;
Expand Down
81 changes: 0 additions & 81 deletions web-common/src/features/sources/source-imported-utils.ts

This file was deleted.

2 comments on commit 1d52dc8

@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://675911a397c20cf92a5630cf--rill-ui.netlify.app

Please sign in to comment.