diff --git a/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.test.tsx b/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.test.tsx index 9530e74cbbf67..a4dc881042005 100644 --- a/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.test.tsx +++ b/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.test.tsx @@ -68,7 +68,7 @@ test('fetching requestable roles for servers uses UUID, not hostname', async () ); }); -test('fetching requestable roles kube_cluster resource without namespace request', async () => { +test('fetching requestable roles for a kube_cluster resource without specifying a namespace', async () => { const kube = makeKube(); const cluster = makeRootCluster(); const appContext = new MockAppContext(); diff --git a/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts b/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts index 363ef039d85cc..1d5a282bbdfd2 100644 --- a/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts +++ b/web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts @@ -163,10 +163,6 @@ export default function useAccessRequestCheckout() { /** * * @param pendingRequest holds a list or map of resources to process - * @param excludeSubResourceParentResource when true, resources that have - * subresources, will be excluded from the returned list. eg: - * if a kube_cluster resource has a list of namespaces (subresources), - * then if this flag is true, kube_cluster will be excluded from the result. */ function getPendingAccessRequestsPerResource( pendingRequest: PendingAccessRequest @@ -293,19 +289,11 @@ export default function useAccessRequestCheckout() { resourceIds: pendingAccessRequestsWithoutParentResource .filter(d => d.kind !== 'role') .map(d => { - if (d.kind === 'namespace') { - return { - name: d.id, - kind: d.kind, - clusterName: d.clusterName, - subResourceName: d.subResourceName, - }; - } return { name: d.id, clusterName: d.clusterName, kind: d.kind, - subResourceName: '', + subResourceName: d.subResourceName || '', }; }), roles: pendingAccessRequestsWithoutParentResource @@ -345,6 +333,9 @@ export default function useAccessRequestCheckout() { async function performDryRun() { let teletermAccessRequest: TeletermAccessRequest; + // reset any create attempts between dry runs. + setCreateRequestAttempt({ status: '' }); + try { const { accessRequest } = await prepareAndCreateRequest({ dryRun: true, @@ -352,12 +343,9 @@ export default function useAccessRequestCheckout() { }); teletermAccessRequest = accessRequest; } catch { - setCreateRequestAttempt({ status: '' }); return; } - setCreateRequestAttempt({ status: '' }); - const accessRequest = makeUiAccessRequest(teletermAccessRequest); onDryRunChange(accessRequest); } @@ -440,7 +428,7 @@ export default function useAccessRequestCheckout() { isCollapsed, assumedRequests: getAssumedRequests(), toggleResource, - data: pendingAccessRequests, + pendingAccessRequests, shouldShowClusterNameColumn, createRequest, reset, diff --git a/web/packages/teleterm/src/ui/DocumentAccessRequests/NewRequest/useNewRequest.ts b/web/packages/teleterm/src/ui/DocumentAccessRequests/NewRequest/useNewRequest.ts index f9dde65ac760d..bcc9d7b04f3e0 100644 --- a/web/packages/teleterm/src/ui/DocumentAccessRequests/NewRequest/useNewRequest.ts +++ b/web/packages/teleterm/src/ui/DocumentAccessRequests/NewRequest/useNewRequest.ts @@ -211,9 +211,14 @@ export default function useNewRequest(rootCluster: Cluster) { return; } + /** + * This should never happen but just a safeguard. + * This function is used in the "unified resources" view, + * where a user can click on a "request access" button. + * Selecting kube_cluster's namespace is not available in this view + * (instead it is rendered in the "request checkout" view). + */ if (kind === 'namespace') { - // It is not possible to request a kube namespace through this function. - // The type should be corrected. return; }