Skip to content

Commit be7446a

Browse files
pa-lembilalabbad
andauthored
Permissions form fixes (#4675)
* fit object permissions form * add fragment * fix global permissions * revert workaround for roles * chore --------- Co-authored-by: bilalabbad <[email protected]>
1 parent 195cec0 commit be7446a

File tree

6 files changed

+49
-11
lines changed

6 files changed

+49
-11
lines changed

changelog/+permissions.added.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
New permissions system in UI:
2+
- Implemented CRUD views for managing accounts, groups, roles, and permissions
3+
- Updated all components to support new permission system
4+
- Added dynamic message display according to user access levels

frontend/app/src/graphql/queries/role-management/getGlobalPermissions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@ export const GET_ROLE_MANAGEMENT_GLOBAL_PERMISSIONS = gql`
77
node {
88
id
99
display_label
10+
name {
11+
value
12+
}
1013
action {
1114
value
1215
}
16+
decision {
17+
value
18+
}
1319
roles {
1420
count
21+
edges {
22+
node {
23+
id
24+
}
25+
}
1526
}
1627
identifier {
1728
value

frontend/app/src/graphql/queries/role-management/getRoles.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ export const GET_ROLE_MANAGEMENT_ROLES = gql`
2727
}
2828
}
2929
}
30+
permissions {
31+
edges {
32+
node {
33+
kind
34+
view
35+
create
36+
update
37+
delete
38+
}
39+
}
40+
}
3041
}
3142
}
3243
`;

frontend/app/src/screens/role-management/global-permissions.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ function GlobalPermissions() {
7272
{edge?.node?.display_label}
7373
</div>
7474
),
75+
value: edge?.node?.name?.value,
76+
},
77+
action: { value: edge?.node?.action?.value },
78+
decision: { value: edge?.node?.decision?.value },
79+
roles: {
80+
display: <Pill>{edge?.node?.roles?.count}</Pill>,
81+
value: { edges: edge?.node?.roles?.edges },
7582
},
76-
description: { value: edge?.node?.description?.value },
77-
roles: { display: <Pill>{edge?.node?.roles?.count}</Pill> },
7883
identifier: { display: <BadgeCopy value={edge?.node?.identifier?.value} /> },
7984
},
8085
};
@@ -120,7 +125,17 @@ function GlobalPermissions() {
120125
</div>
121126
</div>
122127

123-
<Table columns={columns} rows={rows ?? []} className="border-0" permission={permission} />
128+
<Table
129+
columns={columns}
130+
rows={rows ?? []}
131+
onDelete={(data) => setRowToDelete(data.values)}
132+
onUpdate={(row) => {
133+
setRowToUpdate(row.values);
134+
setShowDrawer(true);
135+
}}
136+
className="border-0"
137+
permission={permission}
138+
/>
124139

125140
<Pagination count={data && data[GLOBAL_PERMISSION_OBJECT]?.count} />
126141
</div>

frontend/app/src/screens/role-management/object-permissions-form.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ACCOUNT_ROLE_OBJECT, OBJECT_PERMISSION_OBJECT } from "@/config/constant
99
import graphqlClient from "@/graphql/graphqlClientApollo";
1010
import { createObject } from "@/graphql/mutations/objects/createObject";
1111
import { updateObjectWithId } from "@/graphql/mutations/objects/updateObjectWithId";
12-
import { branchesState, currentBranchAtom } from "@/state/atoms/branches.atom";
12+
import { currentBranchAtom } from "@/state/atoms/branches.atom";
1313
import { namespacesState, schemaState } from "@/state/atoms/schema.atom";
1414
import { datetimeAtom } from "@/state/atoms/time.atom";
1515
import { AttributeType, RelationshipType } from "@/utils/getObjectItemDisplayValue";
@@ -37,7 +37,6 @@ export const ObjectPermissionForm = ({
3737
onCancel,
3838
onUpdateComplete,
3939
}: NumberPoolFormProps) => {
40-
const branches = useAtomValue(branchesState);
4140
const branch = useAtomValue(currentBranchAtom);
4241
const date = useAtomValue(datetimeAtom);
4342

@@ -46,18 +45,17 @@ export const ObjectPermissionForm = ({
4645
});
4746

4847
const defaultValues = {
49-
branch: getCurrentFieldValue("branch", currentObject),
5048
namespace: getCurrentFieldValue("namespace", currentObject),
5149
name: getCurrentFieldValue("name", currentObject),
50+
action: getCurrentFieldValue("action", currentObject),
51+
decision: getCurrentFieldValue("decision", currentObject),
5252
roles,
5353
};
5454

5555
const form = useForm<FieldValues>({
5656
defaultValues,
5757
});
5858

59-
const branchesOptions = branches.map((branch) => ({ value: branch.name, label: branch.name }));
60-
6159
const actionOptions = [
6260
{
6361
value: "any",

frontend/app/src/screens/role-management/roles.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import graphqlClient from "@/graphql/graphqlClientApollo";
1717
import useQuery from "@/hooks/useQuery";
1818
import { useSchema } from "@/hooks/useSchema";
1919
import UnauthorizedScreen from "../errors/unauthorized-screen";
20-
import { PERMISSION_ALLOW_ALL } from "../permission/utils";
20+
import { getPermission } from "../permission/utils";
2121

2222
function Roles() {
2323
const { loading, data, error, refetch } = useQuery(GET_ROLE_MANAGEMENT_ROLES);
@@ -33,8 +33,7 @@ function Roles() {
3333
> | null>(null);
3434
const [showDrawer, setShowDrawer] = useState(false);
3535

36-
// const permission = getPermission(data?.[ACCOUNT_ROLE_OBJECT]?.permissions?.edges);
37-
const permission = PERMISSION_ALLOW_ALL;
36+
const permission = getPermission(data?.[ACCOUNT_ROLE_OBJECT]?.permissions?.edges);
3837

3938
const columns = [
4039
{

0 commit comments

Comments
 (0)