Skip to content

Commit a279500

Browse files
authored
Pass workspaceId to Tables iframe via parentData for dashboard filtering (#1609)
Part of OPS-3008.
1 parent e2ec003 commit a279500

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

  • packages/react-ui/src/app/routes/openops-tables

packages/react-ui/src/app/routes/openops-tables/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,30 @@ import { t } from 'i18next';
22
import { useLocation } from 'react-router-dom';
33

44
import { flagsHooks } from '@/app/common/hooks/flags-hooks';
5+
import { platformHooks } from '@/app/common/hooks/platform-hooks';
6+
import { projectHooks } from '@/app/common/hooks/project-hooks';
57
import { useDefaultSidebarState } from '@/app/common/hooks/use-default-sidebar-state';
68
import { useCandu } from '@/app/features/extensions/candu/use-candu';
79
import { FlagId } from '@openops/shared';
810

911
const OpenOpsTablesPage = () => {
1012
useDefaultSidebarState('minimized');
1113
const { isCanduEnabled, canduClientToken, canduUserId } = useCandu();
12-
const parentData = encodeURIComponent(
13-
JSON.stringify({ isCanduEnabled, userId: canduUserId, canduClientToken }),
14-
);
14+
const { project } = projectHooks.useCurrentProject();
15+
const { platform: organization } = platformHooks.useCurrentPlatform();
16+
17+
// TODO: Remove type assertion and remove organization?.tablesWorkspaceId fallback once Phase 1 is complete
18+
const workspaceId =
19+
(project as any)?.tablesWorkspaceId ?? organization?.tablesWorkspaceId;
20+
21+
const parentDataObj = {
22+
userId: canduUserId ?? undefined,
23+
canduClientToken: canduClientToken ?? undefined,
24+
...(isCanduEnabled && { isCanduEnabled: true }),
25+
...(workspaceId !== undefined && { workspaceId }),
26+
};
27+
28+
const parentData = encodeURIComponent(JSON.stringify(parentDataObj));
1529

1630
const location = useLocation();
1731
const params = new URLSearchParams(location.search);

0 commit comments

Comments
 (0)