diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/AddPolicyPage/AddPolicyPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/AddPolicyPage/AddPolicyPage.tsx index 4fa114ad38b..87fffaa988e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/AddPolicyPage/AddPolicyPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/AddPolicyPage/AddPolicyPage.tsx @@ -11,7 +11,17 @@ * limitations under the License. */ -import { Button, Card, Col, Form, Input, Row, Select, Space } from 'antd'; +import { + Button, + Card, + Col, + Form, + Input, + Row, + Select, + Space, + Typography, +} from 'antd'; import { AxiosError } from 'axios'; import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; @@ -82,10 +92,13 @@ const AddPolicyPage = () => { }; return ( - + - + + + Add New Policy +
{ +const List = ({ + list, + type, +}: { + list: EntityReference[]; + type: 'role' | 'team'; +}) => { const columns: ColumnsType = useMemo(() => { return [ { @@ -45,13 +67,28 @@ const RolesList = ({ roles }: { roles: EntityReference[] }) => { dataIndex: 'name', width: '200px', key: 'name', - render: (_, record) => ( - - {getEntityName(record)} - - ), + render: (_, record) => { + let link = ''; + switch (type) { + case 'role': + link = getRoleWithFqnPath(record.fullyQualifiedName || ''); + + break; + case 'team': + link = getTeamsWithFqnPath(record.fullyQualifiedName || ''); + + break; + + default: + break; + } + + return ( + + {getEntityName(record)} + + ); + }, }, { title: 'Description', @@ -61,14 +98,27 @@ const RolesList = ({ roles }: { roles: EntityReference[] }) => { ), }, + { + title: 'Actions', + dataIndex: 'actions', + width: '80px', + key: 'actions', + render: () => { + return ( + + ); + }, + }, ]; }, []); return ( @@ -167,11 +217,51 @@ const PoliciesDetailPage = () => { ) : ( {policy.rules.map((rule) => ( - - - + + + + + {rule.name} + +
+ + Active +
+
+ +
+ + Description: + + +
+ + + + Resources: + + + {rule.resources?.join(', ')} + + + + + + Operations: + + + {rule.operations?.join(', ')} + + +
))} @@ -179,23 +269,13 @@ const PoliciesDetailPage = () => { )} - + {isEmpty(policy.teams) ? ( ) : ( - - {policy.teams?.map((team) => ( - - - - - - ))} - + )} diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesListPage/PoliciesList.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesListPage/PoliciesList.tsx index 85a08e0f89d..09d6ad1222a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesListPage/PoliciesList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/PoliciesPage/PoliciesListPage/PoliciesList.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { Button, Space, Table } from 'antd'; +import { Button, Popover, Space, Table, Tag } from 'antd'; import { ColumnsType } from 'antd/lib/table'; import { isUndefined, uniqueId } from 'lodash'; import React, { FC, useMemo, useState } from 'react'; @@ -22,6 +22,7 @@ import { EntityType } from '../../../enums/entity.enum'; import { Policy } from '../../../generated/entity/policies/policy'; import { Paging } from '../../../generated/type/paging'; import { getEntityName } from '../../../utils/CommonUtils'; +import { LIST_CAP } from '../../../utils/PermissionsUtils'; import { getPolicyWithFqnPath, getRoleWithFqnPath, @@ -61,18 +62,44 @@ const PoliciesList: FC = ({ policies, fetchPolicies }) => { { title: 'Roles', dataIndex: 'roles', - width: '200px', + width: '250px', key: 'roles', render: (_, record) => { + const listLength = record.roles?.length ?? 0; + const hasMore = listLength > LIST_CAP; + return record.roles?.length ? ( - {record.roles.map((role) => ( + {record.roles.slice(0, LIST_CAP).map((role) => ( {getEntityName(role)} ))} + {hasMore && ( + + {record.roles.slice(LIST_CAP).map((role) => ( + + {getEntityName(role)} + + ))} + + } + overlayClassName="tw-w-40 tw-text-center" + trigger="click"> + {`+${ + listLength - LIST_CAP + } more`} + + )} ) : ( '-- ' diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/AddRolePage/AddRolePage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/AddRolePage/AddRolePage.tsx index 99a5dfdf732..b3ef4ffc72a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/AddRolePage/AddRolePage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/AddRolePage/AddRolePage.tsx @@ -11,7 +11,17 @@ * limitations under the License. */ -import { Button, Card, Col, Form, Input, Row, Select, Space } from 'antd'; +import { + Button, + Card, + Col, + Form, + Input, + Row, + Select, + Space, + Typography, +} from 'antd'; import { AxiosError } from 'axios'; import React, { useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; @@ -90,10 +100,13 @@ const AddRolePage = () => { }, []); return ( - + - + + + Add New Role + { +const List = ({ + list, + type, +}: { + list: EntityReference[]; + type: 'policy' | 'team' | 'user'; +}) => { const columns: ColumnsType = useMemo(() => { return [ { @@ -48,13 +57,32 @@ const PoliciesList = ({ policies }: { policies: EntityReference[] }) => { dataIndex: 'name', width: '200px', key: 'name', - render: (_, record) => ( - - {getEntityName(record)} - - ), + render: (_, record) => { + let link = ''; + switch (type) { + case 'policy': + link = getPolicyWithFqnPath(record.fullyQualifiedName || ''); + + break; + case 'team': + link = getTeamsWithFqnPath(record.fullyQualifiedName || ''); + + break; + case 'user': + link = getUserPath(record.fullyQualifiedName || ''); + + break; + + default: + break; + } + + return ( + + {getEntityName(record)} + + ); + }, }, { title: 'Description', @@ -64,14 +92,27 @@ const PoliciesList = ({ policies }: { policies: EntityReference[] }) => { ), }, + { + title: 'Actions', + dataIndex: 'actions', + width: '80px', + key: 'actions', + render: () => { + return ( + + ); + }, + }, ]; }, []); return (
@@ -165,40 +206,20 @@ const RolesDetailPage = () => { - + {isEmpty(role.teams) ? ( ) : ( - - {role.teams?.map((team) => ( - - - - - - ))} - + )} {isEmpty(role.users) ? ( ) : ( - - {role.users?.map((user) => ( - - - - - - ))} - + )} diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesListPage/RolesList.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesListPage/RolesList.tsx index 4001a1d0d82..b1ae63c27de 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesListPage/RolesList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesListPage/RolesList.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { Button, Space, Table } from 'antd'; +import { Button, Popover, Space, Table, Tag } from 'antd'; import { ColumnsType } from 'antd/lib/table'; import { isUndefined, uniqueId } from 'lodash'; import React, { FC, useMemo, useState } from 'react'; @@ -22,6 +22,7 @@ import { EntityType } from '../../../enums/entity.enum'; import { Role } from '../../../generated/entity/teams/role'; import { Paging } from '../../../generated/type/paging'; import { getEntityName } from '../../../utils/CommonUtils'; +import { LIST_CAP } from '../../../utils/PermissionsUtils'; import { getPolicyWithFqnPath, getRoleWithFqnPath, @@ -62,18 +63,44 @@ const RolesList: FC = ({ roles, fetchRoles }) => { { title: 'Policies', dataIndex: 'policies', - width: '200px', + width: '250px', key: 'policies', render: (_, record) => { + const listLength = record.policies?.length ?? 0; + const hasMore = listLength > LIST_CAP; + return record.policies?.length ? ( - {record.policies.map((policy) => ( + {record.policies.slice(0, LIST_CAP).map((policy) => ( {getEntityName(policy)} ))} + {hasMore && ( + + {record.policies.slice(LIST_CAP).map((policy) => ( + + {getEntityName(policy)} + + ))} + + } + overlayClassName="tw-w-40 tw-text-center" + trigger="click"> + {`+${ + listLength - LIST_CAP + } more`} + + )} ) : ( '-- ' diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/PermissionsUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/PermissionsUtils.ts index 5052a20dd31..6726daa84a3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/PermissionsUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/PermissionsUtils.ts @@ -33,3 +33,5 @@ export const hasPemission = ( return currentPermission?.access === Access.Allow; }; + +export const LIST_CAP = 1;