Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enahnce Role Bindings and CRB #3308

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ common:
age: Age
annotations: Annotations
created: Created
configuration: Configuration
last-update: Last Update
description: Description
discard-changes: Discard Changes
Expand Down
12 changes: 1 addition & 11 deletions src/resources/RoleBindings/GenericRoleBindingDetails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { useTranslation } from 'react-i18next';

import { RoleSubjects } from './RoleSubjects.js';
import { RoleRef } from './RoleRef';
Expand All @@ -10,20 +9,11 @@ export function GenericRoleBindingDetails({
description,
...otherParams
}) {
const { t } = useTranslation();

const customColumns = [
{
header: t('role-bindings.headers.role-ref'),
value: resource => <RoleRef roleRef={resource.roleRef} />,
},
];
return (
<ResourceDetails
{...otherParams}
customColumns={customColumns}
description={description}
customComponents={[RoleSubjects]}
customComponents={[RoleRef, RoleSubjects]}
/>
);
}
30 changes: 22 additions & 8 deletions src/resources/RoleBindings/RoleRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';
import { Tooltip } from 'shared/components/Tooltip/Tooltip';
import { useUrl } from 'hooks/useUrl';
import { Link } from 'shared/components/Link/Link';
import { UI5Panel } from 'shared/components/UI5Panel/UI5Panel';
import { useTranslation } from 'react-i18next';
import { LayoutPanelRow } from 'shared/components/LayoutPanelRow/LayoutPanelRow';

const shortRoleKind = roleRefKind => {
return roleRefKind === 'ClusterRole' ? '(CR)' : '(R)';
const shortRoleKind = resource => {
return resource.roleRef === 'ClusterRole' ? '(CR)' : '(R)';
};

export function RoleRef({ roleRef }) {
const { t } = useTranslation();
const { clusterUrl, namespaceUrl } = useUrl();
if (!roleRef) {
return EMPTY_TEXT_PLACEHOLDER;
Expand All @@ -21,11 +25,21 @@ export function RoleRef({ roleRef }) {
};

return (
<div>
<Link url={roleDetailsLink()}>{roleRef.name}</Link>
<Tooltip delay={0} content={roleRef.kind}>
{shortRoleKind(roleRef.kind)}
</Tooltip>
</div>
<UI5Panel
keyComponent="role-binding"
title={t('common.headers.configuration')}
>
<LayoutPanelRow
name={t('role-bindings.headers.role-ref')}
value={
<>
<Link url={roleDetailsLink()}>{roleRef.name}</Link>
<Tooltip delay={0} content={roleRef.kind}>
{shortRoleKind(roleRef.kind)}
</Tooltip>
</>
}
/>
</UI5Panel>
);
}
Loading