Skip to content

Commit

Permalink
Invalidate OLAP table list when a new source/model is added (#4724)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde authored Apr 26, 2024
1 parent f6f1dc3 commit 039d5a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions web-common/src/features/entity-management/file-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class FileArtifact {
*/
public lastStateUpdatedOn: string | undefined;

public isNew = true;

public constructor(filePath: string) {
this.path = filePath;
}
Expand All @@ -58,6 +60,7 @@ export class FileArtifact {
V1ReconcileStatus.RECONCILE_STATUS_RUNNING,
);
this.renaming = !!resource.meta?.renamedFrom;
this.isNew = false;
}

public updateReconciling(resource: V1Resource) {
Expand Down Expand Up @@ -284,6 +287,14 @@ export class FileArtifacts {
});
}

public isNew(resource: V1Resource) {
return (
resource.meta?.filePaths?.some((filePath) => {
return this.artifacts[filePath].isNew;
}) ?? false
);
}

public wasRenaming(resource: V1Resource) {
const finishedRename = !resource.meta?.renamedFrom;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ async function invalidateResource(
)
return;

if (fileArtifacts.wasRenaming(resource)) {
if (
fileArtifacts.wasRenaming(resource) ||
(fileArtifacts.isNew(resource) &&
(resource.meta.name?.kind === ResourceKind.Source ||
resource.meta.name?.kind === ResourceKind.Model))
) {
void queryClient.invalidateQueries(
getConnectorServiceOLAPListTablesQueryKey(),
);
Expand Down

1 comment on commit 039d5a9

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

Please sign in to comment.