-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(KFLUXUI-175): give up SpaceBindingRequest and enjoy RoleBinding
- Loading branch information
Showing
45 changed files
with
1,189 additions
and
769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const defaultKonfluxRoleMap = { | ||
'konflux-admin-user-actions': 'admin', | ||
'konflux-contributor-user-actions': 'contributor', | ||
'konflux-maintainer-user-actions': 'maintainer', | ||
}; | ||
|
||
export const mockConfigMap = { | ||
kind: 'ConfigMap', | ||
apiVersion: 'v1', | ||
metadata: { | ||
name: 'konflux-public-info', | ||
namespace: 'konflux-info', | ||
}, | ||
data: { | ||
'info.json': | ||
'{\n "environment": "staging",\n "integrations": {\n "github": {\n "application_url": "https://github.com/apps/konflux-staging"\n },\n "sbom_server": {\n "url": "https://atlas.stage.devshift.net/sbom/content/\u003cPLACEHOLDER\u003e"\n },\n "image_controller": {\n "enabled": true,\n "notifications": [\n {\n "title": "SBOM-event-to-Bombino",\n "event": "repo_push",\n "method": "webhook",\n "config": {\n "url": "https://bombino.preprod.api.redhat.com/v1/sbom/quay/push"\n }\n }\n ]\n }\n },\n "rbac": [\n {\n "displayName": "admin",\n "description": "Full access to Konflux resources including secrets",\n "roleRef": {\n "apiGroup": "rbac.authorization.k8s.io",\n "kind": "ClusterRole",\n "name": "konflux-admin-user-actions"\n }\n },\n {\n "displayName": "maintainer",\n "description": "Partial access to Konflux resources without access to secrets",\n "roleRef": {\n "apiGroup": "rbac.authorization.k8s.io",\n "kind": "ClusterRole",\n "name": "konflux-maintainer-user-actions"\n }\n },\n {\n "displayName": "contributor",\n "description": "View access to Konflux resources without access to secrets",\n "roleRef": {\n "apiGroup": "rbac.authorization.k8s.io",\n "kind": "ClusterRole",\n "name": "konflux-contributor-user-actions"\n }\n }\n ]\n}\n', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { RoleBinding } from '../types'; | ||
|
||
export const mockRoleBinding: RoleBinding = { | ||
apiVersion: 'rbac.authorization.k8s.io/v1', | ||
kind: 'RoleBinding', | ||
metadata: { name: 'metadata-name', namespace: 'test-ws' }, | ||
subjects: [ | ||
{ apiGroup: 'rbac.authorization.k8s.io', name: 'user1', kind: 'User', namespace: 'test-ws' }, | ||
], | ||
roleRef: { | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
kind: 'ClusterRole', | ||
name: 'konflux-contributor-user-actions', | ||
}, | ||
}; | ||
|
||
export const mockRoleBindings: RoleBinding[] = [ | ||
{ | ||
apiVersion: 'rbac.authorization.k8s.io/v1', | ||
kind: 'RoleBinding', | ||
metadata: { name: 'metadata-name', namespace: 'test-ws' }, | ||
subjects: [ | ||
{ apiGroup: 'rbac.authorization.k8s.io', name: 'user1', kind: 'User', namespace: 'test-ws' }, | ||
], | ||
roleRef: { | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
kind: 'ClusterRole', | ||
name: 'konflux-contributor-user-actions', | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'rbac.authorization.k8s.io/v1', | ||
kind: 'RoleBinding', | ||
metadata: { name: 'metadata-name-1', namespace: 'test-ws' }, | ||
subjects: [ | ||
{ apiGroup: 'rbac.authorization.k8s.io', name: 'user2', kind: 'User', namespace: 'test-ws' }, | ||
], | ||
roleRef: { | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
kind: 'ClusterRole', | ||
name: 'konflux-maintainer-user-actions', | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'rbac.authorization.k8s.io/v1', | ||
kind: 'RoleBinding', | ||
metadata: { name: 'metadata-name-2', namespace: 'test-ws' }, | ||
subjects: [ | ||
{ apiGroup: 'rbac.authorization.k8s.io', name: 'user3', kind: 'User', namespace: 'test-ws' }, | ||
], | ||
roleRef: { | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
kind: 'ClusterRole', | ||
name: 'konflux-maintainer-user-actions', | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'rbac.authorization.k8s.io/v1', | ||
kind: 'RoleBinding', | ||
metadata: { name: 'metadata-name-3', namespace: 'test-ws' }, | ||
subjects: [ | ||
{ apiGroup: 'rbac.authorization.k8s.io', name: 'user4', kind: 'User', namespace: 'test-ws' }, | ||
], | ||
roleRef: { | ||
apiGroup: 'rbac.authorization.k8s.io', | ||
kind: 'ClusterRole', | ||
name: 'konflux-admin-user-actions', | ||
}, | ||
}, | ||
]; | ||
|
||
export const mockRoleBindingWithoutUser: RoleBinding = { | ||
...mockRoleBinding, | ||
subjects: mockRoleBinding.subjects.map((subject) => | ||
subject.kind === 'User' ? { ...subject, kind: 'Group' } : subject, | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const rbTableColumnClasses = { | ||
username: 'pf-m-width-25', | ||
role: 'pf-m-width-20', | ||
status: 'pf-m-hidden pf-m-visible-on-md pf-m-width-20', | ||
kebab: 'pf-v5-c-table__action', | ||
}; | ||
|
||
export const RBListHeader = () => [ | ||
{ | ||
title: 'Username', | ||
props: { className: rbTableColumnClasses.username }, | ||
}, | ||
{ | ||
title: 'Role', | ||
props: { className: rbTableColumnClasses.role }, | ||
}, | ||
{ | ||
title: ' ', | ||
props: { | ||
className: rbTableColumnClasses.kebab, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import { Bullseye, Spinner } from '@patternfly/react-core'; | ||
import { useRoleMap } from '../../hooks/useRole'; | ||
import { RowFunctionArgs, TableData } from '../../shared'; | ||
import ActionMenu from '../../shared/components/action-menu/ActionMenu'; | ||
import { RoleBinding } from '../../types'; | ||
import { rbTableColumnClasses } from './RBListHeader'; | ||
import { useRBActions } from './user-access-actions'; | ||
|
||
export const RBListRow: React.FC<React.PropsWithChildren<RowFunctionArgs<RoleBinding>>> = ({ | ||
obj, | ||
}) => { | ||
const actions = useRBActions(obj); | ||
const { roleMap, roleMapLoading } = useRoleMap(); | ||
|
||
if (roleMapLoading) { | ||
return ( | ||
<Bullseye> | ||
<Spinner data-test="spinner" /> | ||
</Bullseye> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<TableData className={rbTableColumnClasses.username}>{obj.subjects[0].name}</TableData> | ||
<TableData className={rbTableColumnClasses.role}>{roleMap[obj.roleRef.name]}</TableData> | ||
<TableData className={rbTableColumnClasses.kebab}> | ||
<ActionMenu actions={actions} /> | ||
</TableData> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.