-
Notifications
You must be signed in to change notification settings - Fork 42
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
Create Users list details drawer #1687
Merged
fhlavac
merged 10 commits into
RedHatInsights:master
from
CodyWMitchell:user-list-details
Nov 5, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0bab391
chore(deps): update konflux references (#1686)
red-hat-konflux[bot] f150391
fix(permission): unable to load more than 2 pages in permissions (#1688)
karelhala 65660ee
chore: publish 1.5.1 <no> [skip ci]
semantic-release-bot 2222100
chore(konflux): add rpms-signature-scan task to pipelines (#1690)
fhlavac 81d51ff
fix(konflux): add rpms check to pull requests (#1691)
karelhala 1502741
chore: publish 1.5.2 <no> [skip ci]
semantic-release-bot 1f433e9
fix(deploy): correct quay repository in frontend config (#1693)
karelhala 11ae535
chore: publish 1.5.3 <no> [skip ci]
semantic-release-bot 2de8e1d
chore(deps): update konflux references (#1689)
red-hat-konflux[bot] 53ccf7a
feat: create user details view
CodyWMitchell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
118 changes: 118 additions & 0 deletions
118
src/smart-components/access-management/UserDetailsDrawer.tsx
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,118 @@ | ||
import { | ||
Drawer, | ||
DrawerActions, | ||
DrawerCloseButton, | ||
DrawerContent, | ||
DrawerContentBody, | ||
DrawerHead, | ||
DrawerPanelContent, | ||
Icon, | ||
Popover, | ||
Tab, | ||
TabTitleText, | ||
Tabs, | ||
Text, | ||
TextContent, | ||
Title, | ||
} from '@patternfly/react-core'; | ||
import React, { useEffect } from 'react'; | ||
import { User } from '../../redux/reducers/user-reducer'; | ||
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons'; | ||
import { useIntl } from 'react-intl'; | ||
import messages from '../../Messages'; | ||
import UserDetailsGroupsView from './UserDetailsGroupsView'; | ||
import UserDetailsRolesView from './UserDetailsRolesView'; | ||
import { EventTypes, useDataViewEventsContext } from '@patternfly/react-data-view'; | ||
|
||
interface UserDetailsProps { | ||
focusedUser?: User; | ||
drawerRef: React.RefObject<HTMLDivElement>; | ||
onClose: () => void; | ||
ouiaId: string; | ||
} | ||
|
||
const UserDetailsDrawerContent: React.FunctionComponent<UserDetailsProps> = ({ focusedUser, drawerRef, onClose, ouiaId }) => { | ||
const [activeTabKey, setActiveTabKey] = React.useState<string | number>(0); | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<DrawerPanelContent> | ||
<DrawerHead> | ||
<Title headingLevel="h2"> | ||
<span tabIndex={focusedUser ? 0 : -1} ref={drawerRef}>{`${focusedUser?.first_name} ${focusedUser?.last_name}`}</span> | ||
</Title> | ||
<TextContent> | ||
<Text>{focusedUser?.email}</Text> | ||
</TextContent> | ||
<DrawerActions> | ||
<DrawerCloseButton onClick={onClose} /> | ||
</DrawerActions> | ||
</DrawerHead> | ||
<Tabs isFilled activeKey={activeTabKey} onSelect={(_, tabIndex) => setActiveTabKey(tabIndex)}> | ||
<Tab eventKey={0} title={intl.formatMessage(messages.userGroups)}> | ||
{focusedUser && <UserDetailsGroupsView ouiaId={`${ouiaId}-user-groups-view`} userId={focusedUser.username} />} | ||
</Tab> | ||
<Tab | ||
eventKey={1} | ||
title={ | ||
<TabTitleText> | ||
{intl.formatMessage(messages.assignedRoles)} | ||
<Popover | ||
triggerAction="hover" | ||
position="top-end" | ||
headerContent={intl.formatMessage(messages.assignedRoles)} | ||
bodyContent={intl.formatMessage(messages.assignedRolesDescription)} | ||
> | ||
<Icon className="pf-v5-u-pl-sm" isInline> | ||
<OutlinedQuestionCircleIcon /> | ||
</Icon> | ||
</Popover> | ||
</TabTitleText> | ||
} | ||
> | ||
{focusedUser && <UserDetailsRolesView userId={focusedUser.username} ouiaId={`${ouiaId}-assigned-users-view`} />} | ||
</Tab> | ||
</Tabs> | ||
</DrawerPanelContent> | ||
); | ||
}; | ||
|
||
interface DetailDrawerProps { | ||
focusedUser?: User; | ||
setFocusedUser: (user: User | undefined) => void; | ||
children: React.ReactNode; | ||
ouiaId: string; | ||
} | ||
|
||
const UserDetailsDrawer: React.FunctionComponent<DetailDrawerProps> = ({ focusedUser, setFocusedUser, children, ouiaId }) => { | ||
const drawerRef = React.useRef<HTMLDivElement>(null); | ||
const context = useDataViewEventsContext(); | ||
|
||
useEffect(() => { | ||
const unsubscribe = context.subscribe(EventTypes.rowClick, (user: User | undefined) => { | ||
setFocusedUser(user); | ||
drawerRef.current?.focus(); | ||
}); | ||
|
||
return () => unsubscribe(); | ||
}, [drawerRef]); | ||
|
||
return ( | ||
<Drawer isExpanded={Boolean(focusedUser)} data-ouia-component-id={ouiaId}> | ||
<DrawerContent | ||
panelContent={ | ||
<UserDetailsDrawerContent | ||
ouiaId={`${ouiaId}-panel-content`} | ||
drawerRef={drawerRef} | ||
focusedUser={focusedUser} | ||
onClose={() => setFocusedUser(undefined)} | ||
/> | ||
} | ||
> | ||
<DrawerContentBody hasPadding>{children}</DrawerContentBody> | ||
</DrawerContent> | ||
</Drawer> | ||
); | ||
}; | ||
|
||
export default UserDetailsDrawer; |
43 changes: 43 additions & 0 deletions
43
src/smart-components/access-management/UserDetailsGroupsView.tsx
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,43 @@ | ||
import { DataView, DataViewTable } from '@patternfly/react-data-view'; | ||
import React, { useCallback, useEffect } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { mappedProps } from '../../helpers/shared/helpers'; | ||
import { fetchGroups } from '../../redux/actions/group-actions'; | ||
import { RBACStore } from '../../redux/store'; | ||
import messages from '../../Messages'; | ||
|
||
interface UserGroupsViewProps { | ||
userId: string; | ||
ouiaId: string; | ||
} | ||
|
||
const UserDetailsGroupsView: React.FunctionComponent<UserGroupsViewProps> = ({ userId, ouiaId }) => { | ||
const dispatch = useDispatch(); | ||
const intl = useIntl(); | ||
const columns: string[] = [intl.formatMessage(messages.userGroup), intl.formatMessage(messages.users)]; | ||
|
||
const groups = useSelector((state: RBACStore) => state.groupReducer?.groups?.data || []); | ||
|
||
const fetchData = useCallback(() => { | ||
dispatch(fetchGroups({ ...mappedProps({ username: userId }), usesMetaInURL: true, system: false })); | ||
}, [dispatch, userId]); | ||
|
||
useEffect(() => { | ||
fetchData(); | ||
}, [fetchData]); | ||
|
||
const rows = groups.map((group: any) => ({ | ||
row: [group.name, group.principalCount || '?'], // TODO: update once API provides principalCount [RHCLOUD-35963] | ||
})); | ||
|
||
return ( | ||
<div className="pf-v5-u-pt-md"> | ||
<DataView ouiaId={ouiaId}> | ||
<DataViewTable variant="compact" aria-label="UserGroupsView" ouiaId={`${ouiaId}-table`} columns={columns} rows={rows} /> | ||
</DataView> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserDetailsGroupsView; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to break this file into multiple ones to not have multiple components there