Fix(UI): Fixed policy implementation issues with team details page (#7133)

* Fixed policy implementation issues with team details page

* Worked on comments
This commit is contained in:
Aniket Katkar 2022-09-01 23:27:27 +05:30 committed by GitHub
parent 6b61c43a0a
commit 0efcf38917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -11,10 +11,11 @@
* limitations under the License.
*/
import { Button } from 'antd';
import { Button, Tooltip } from 'antd';
import Table, { ColumnsType } from 'antd/lib/table';
import React, { useMemo } from 'react';
import { Link } from 'react-router-dom';
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
import { EntityType } from '../../enums/entity.enum';
import { EntityReference } from '../../generated/type/entityReference';
import { getEntityName } from '../../utils/CommonUtils';
@ -29,10 +30,12 @@ const ListEntities = ({
list,
type,
onDelete,
hasAccess,
}: {
list: EntityReference[];
type: EntityType;
onDelete: (record: EntityReference) => void;
hasAccess: boolean;
}) => {
const columns: ColumnsType<EntityReference> = useMemo(() => {
return [
@ -82,12 +85,21 @@ const ListEntities = ({
key: 'actions',
render: (_, record) => {
return (
<Button
data-testid={`remove-action-${getEntityName(record)}`}
type="text"
onClick={() => onDelete(record)}>
<SVGIcons alt="remove" icon={Icons.ICON_REMOVE} title="Remove" />
</Button>
<Tooltip
placement="bottomRight"
title={hasAccess ? 'Remove' : NO_PERMISSION_FOR_ACTION}>
<Button
data-testid={`remove-action-${getEntityName(record)}`}
disabled={!hasAccess}
type="text"
onClick={() => onDelete(record)}>
<SVGIcons
alt="remove"
icon={Icons.ICON_REMOVE}
title="Remove"
/>
</Button>
</Tooltip>
);
},
},

View File

@ -874,6 +874,7 @@ const TeamDetailsV1 = ({
Add Role
</ButtonAntd>
<ListEntities
hasAccess={entityPermissions.EditAll}
list={currentTeam.defaultRoles || []}
type={EntityType.ROLE}
onDelete={(record) =>
@ -904,6 +905,7 @@ const TeamDetailsV1 = ({
Add Policy
</ButtonAntd>
<ListEntities
hasAccess={entityPermissions.EditAll}
list={currentTeam.policies || []}
type={EntityType.POLICY}
onDelete={(record) =>