Skip to content

Commit

Permalink
Rename pending access request
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Oct 22, 2024
1 parent 8e795be commit efa1921
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ export default function useAccessRequestCheckout() {
const workspaceAccessRequest =
ctx.workspacesService.getActiveWorkspaceAccessRequestsService();
const docService = ctx.workspacesService.getActiveWorkspaceDocumentService();
const pendingAccessRequest =
const pendingAccessRequestRequest =
workspaceAccessRequest?.getPendingAccessRequest();

const pendingAccessRequestsPerResource =
getPendingAccessRequestsPerResource(pendingAccessRequest);
const pendingAccessRequests = getPendingAccessRequestsPerResource(
pendingAccessRequestRequest
);

const pendingAccessRequestsPerResourceWithoutParentResources =
pendingAccessRequestsPerResource.filter(
p => !isKubeClusterWithNamespaces(p, pendingAccessRequestsPerResource)
const pendingAccessRequestsWithoutParentResource =
pendingAccessRequests.filter(
p => !isKubeClusterWithNamespaces(p, pendingAccessRequests)
);

useEffect(() => {
Expand All @@ -114,18 +115,18 @@ export default function useAccessRequestCheckout() {
if (showCheckout && requestedCount == 0) {
performDryRun();
}
}, [showCheckout, pendingAccessRequest]);
}, [showCheckout, pendingAccessRequestRequest]);

useEffect(() => {
if (!pendingAccessRequest || requestedCount > 0) {
if (!pendingAccessRequestRequest || requestedCount > 0) {
return;
}

runFetchResourceRoles(() =>
retryWithRelogin(ctx, clusterUri, async () => {
const { response } = await ctx.tshd.getRequestableRoles({
clusterUri: rootClusterUri,
resourceIds: pendingAccessRequestsPerResourceWithoutParentResources
resourceIds: pendingAccessRequestsWithoutParentResource
.filter(d => d.kind !== 'role')
.map(d => ({
// We have to use id, not name.
Expand All @@ -141,7 +142,7 @@ export default function useAccessRequestCheckout() {
setSelectedResourceRequestRoles(response.applicableRoles);
})
);
}, [pendingAccessRequest]);
}, [pendingAccessRequestRequest]);

useEffect(() => {
clearCreateAttempt();
Expand Down Expand Up @@ -289,7 +290,7 @@ export default function useAccessRequestCheckout() {
reason: req.reason,
suggestedReviewers: req.suggestedReviewers || [],
dryRun: req.dryRun,
resourceIds: pendingAccessRequestsPerResourceWithoutParentResources
resourceIds: pendingAccessRequestsWithoutParentResource
.filter(d => d.kind !== 'role')
.map(d => {
if (d.kind === 'namespace') {
Expand All @@ -307,7 +308,7 @@ export default function useAccessRequestCheckout() {
subResourceName: '',
};
}),
roles: pendingAccessRequestsPerResourceWithoutParentResources
roles: pendingAccessRequestsWithoutParentResource
.filter(d => d.kind === 'role')
.map(d => d.name),
assumeStartTime: req.start && Timestamp.fromDate(req.start),
Expand All @@ -332,8 +333,7 @@ export default function useAccessRequestCheckout() {
return {
accessRequest: response.request,
requestedCount:
pendingAccessRequestsPerResourceWithoutParentResources.filter
.length,
pendingAccessRequestsWithoutParentResource.filter.length,
};
})
).catch(e => {
Expand Down Expand Up @@ -430,8 +430,8 @@ export default function useAccessRequestCheckout() {
}

const shouldShowClusterNameColumn =
pendingAccessRequest?.kind === 'resource' &&
Array.from(pendingAccessRequest.resources.values()).some(a =>
pendingAccessRequestRequest?.kind === 'resource' &&
Array.from(pendingAccessRequestRequest.resources.values()).some(a =>
routing.isLeafCluster(a.resource.uri)
);

Expand All @@ -440,7 +440,7 @@ export default function useAccessRequestCheckout() {
isCollapsed,
assumedRequests: getAssumedRequests(),
toggleResource,
data: pendingAccessRequestsPerResource,
data: pendingAccessRequests,
shouldShowClusterNameColumn,
createRequest,
reset,
Expand Down

0 comments on commit efa1921

Please sign in to comment.