From 4a8c8ea2ce2d792f045abc77f077dca123dc398d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Tue, 5 Nov 2024 12:06:17 +0100 Subject: [PATCH 1/2] Always fetch access requests from root cluster --- .../useAccessRequests.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx b/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx index aa895d2b044d0..b203f2219587c 100644 --- a/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx +++ b/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx @@ -45,11 +45,7 @@ export default function useAccessRequests(doc: types.DocumentAccessRequests) { const ctx = useAppContext(); ctx.clustersService.useState(); - const { - localClusterUri: clusterUri, - rootClusterUri, - documentsService, - } = useWorkspaceContext(); + const { rootClusterUri, documentsService } = useWorkspaceContext(); const assumed = ctx.clustersService.getAssumedRequests(rootClusterUri); const loggedInUser = useWorkspaceLoggedInUser(); @@ -74,12 +70,14 @@ export default function useAccessRequests(doc: types.DocumentAccessRequests) { const getRequests = async () => { try { - const response = await retryWithRelogin(ctx, clusterUri, async () => { - const { response } = await ctx.tshd.getAccessRequests({ clusterUri }); + const response = await retryWithRelogin(ctx, rootClusterUri, async () => { + const { response } = await ctx.tshd.getAccessRequests({ + clusterUri: rootClusterUri, + }); return response.requests; }); setAttempt({ status: 'success' }); - // transform tshd access request to the webui access request and add flags + // Transform tshd access request to the webui access request and add flags. const requests = response.map(r => makeUiAccessRequest(r)); setAccessRequests(requests); } catch (err) { @@ -91,11 +89,11 @@ export default function useAccessRequests(doc: types.DocumentAccessRequests) { }; useEffect(() => { - // only fetch when visitng RequestList + // Only fetch when visiting RequestList. if (doc.state === 'browsing') { getRequests(); } - }, [doc.state, clusterUri]); + }, [doc.state]); useEffect(() => { // if assumed object changes, we update which roles have been assumed in the table From c28de436fbe7b152b8a6b5b2be525f66491123a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Tue, 5 Nov 2024 12:10:00 +0100 Subject: [PATCH 2/2] Replace deprecated imports --- .../src/ui/DocumentAccessRequests/useAccessRequests.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx b/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx index b203f2219587c..240625c22797c 100644 --- a/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx +++ b/web/packages/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx @@ -28,13 +28,11 @@ import { import { RequestFlags } from 'shared/components/AccessRequests/ReviewRequests'; import { Timestamp } from 'gen-proto-ts/google/protobuf/timestamp_pb'; +import { LoggedInUser } from 'gen-proto-ts/teleport/lib/teleterm/v1/cluster_pb'; +import { AccessRequest as TshdAccessRequest } from 'gen-proto-ts/teleport/lib/teleterm/v1/access_request_pb'; import * as types from 'teleterm/ui/services/workspacesService'; -import { - AssumedRequest, - LoggedInUser, - AccessRequest as TshdAccessRequest, -} from 'teleterm/services/tshd/types'; +import { AssumedRequest } from 'teleterm/services/tshd/types'; import { useAppContext } from 'teleterm/ui/appContextProvider'; import { retryWithRelogin } from 'teleterm/ui/utils';