Skip to content

Commit

Permalink
Address CR
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Oct 21, 2024
1 parent a7f49c2 commit 7b9a051
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
1 change: 0 additions & 1 deletion web/packages/design/src/Link/Link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const StyledButtonLink = styled.a.attrs({
rel: 'noreferrer',
})`
color: ${({ theme }) => theme.colors.buttons.link.default};
font-weight: normal;
background: none;
text-decoration: underline;
text-transform: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ export const FailedResourceRequest = () => (
</MemoryRouter>
);

export const FailedUnsupportedKubeResourceKind = () => (
<MemoryRouter>
<RequestCheckoutWithSlider
{...baseProps}
isResourceRequest={true}
fetchResourceRequestRolesAttempt={{
status: 'failed',
statusText:
'Your Teleport roles request_mode field restricts you from requesting kinds [kube_cluster] for Kubernetes cluster "pumpkin-kube-cluster". Allowed kinds: [pod secret]',
}}
/>
</MemoryRouter>
);

export const Success = () => (
<MemoryRouter initialEntries={['']}>
<RequestCheckoutWithSlider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { AssumeStartTime } from '../../AssumeStartTime/AssumeStartTime';
import { AccessDurationRequest } from '../../AccessDuration';
import {
checkForUnsupportedKubeRequestModes,
excludeKubeClusterWithNamespaces,
isKubeClusterWithNamespaces,
type KubeNamespaceRequest,
} from '../kube';

Expand Down Expand Up @@ -217,9 +217,9 @@ export function RequestCheckout<T extends PendingListItem>({
createAttempt.status === 'processing' ||
fetchResourceRequestRolesAttempt.status === 'processing';

const numResourcesSelected = data.filter(item =>
excludeKubeClusterWithNamespaces(item, data)
);
const numResourcesSelected = data.filter(
item => !isKubeClusterWithNamespaces(item, data)
).length;

const DefaultHeader = () => {
return (
Expand All @@ -233,8 +233,8 @@ export function RequestCheckout<T extends PendingListItem>({
/>
<Box>
<H2>
{numResourcesSelected.length}{' '}
{pluralize(numResourcesSelected.length, 'Resource')} Selected
{numResourcesSelected} {pluralize(numResourcesSelected, 'Resource')}{' '}
Selected
</H2>
</Box>
</Flex>
Expand Down Expand Up @@ -297,8 +297,8 @@ export function RequestCheckout<T extends PendingListItem>({
<Alert kind="danger">
You can only request Kubernetes resource kind{' '}
{unsupportedKubeRequestModes} for cluster{' '}
{affectedKubeClusterName}, but the web UI does not support these
kinds yet. Use the{' '}
{affectedKubeClusterName}, but is not supported through this UI.
Use the{' '}
<ExternalLink
target="_blank"
href="https://goteleport.com/docs/admin-guides/access-controls/access-requests/resource-requests/#step-26-search-for-resources"
Expand Down
15 changes: 6 additions & 9 deletions web/packages/shared/components/AccessRequests/NewRequest/kube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,21 @@ export type KubeNamespaceRequest = {
};

/**
* Returns true if the currItem is a kube cluster or is a namespace
* of the currItem.
* Returns true if the item is a kube cluster or is a namespace
* of the item.
*
* Technically you can request for both a kube_cluster and its subresources
* but it's probably not what a user would expect from the web UI because
* requesting for subresources means narrowing access versus requesting
* access to the whole kube_cluster.
*/
export function excludeKubeClusterWithNamespaces(
currItem: PendingListItem,
export function isKubeClusterWithNamespaces(
item: PendingListItem,
allItems: PendingListItem[]
) {
return (
currItem.kind !== 'kube_cluster' ||
!(
currItem.kind === 'kube_cluster' &&
allItems.find(a => a.kind === 'namespace' && a.id == currItem.id)
)
item.kind === 'kube_cluster' &&
allItems.find(a => a.kind === 'namespace' && a.id == item.id)
);
}

Expand Down

0 comments on commit 7b9a051

Please sign in to comment.