File tree Expand file tree Collapse file tree
authz-module/libraries-manager/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,13 +23,11 @@ jest.mock('../context', () => ({
2323describe ( 'TeamTable' , ( ) => {
2424 const mockTeamMembers = [
2525 {
26- displayName : 'Alice' ,
2726 email : 'alice@example.com' ,
2827 roles : [ 'Admin' , 'Editor' ] ,
2928 username : 'alice' ,
3029 } ,
3130 {
32- displayName : 'Bob' ,
3331 email : 'bob@example.com' ,
3432 roles : [ 'Viewer' ] ,
3533 username : 'bob' ,
@@ -68,12 +66,12 @@ describe('TeamTable', () => {
6866
6967 renderWrapper ( < TeamTable /> ) ;
7068
71- expect ( screen . getByText ( 'Alice ' ) ) . toBeInTheDocument ( ) ;
69+ expect ( screen . getByText ( 'alice ' ) ) . toBeInTheDocument ( ) ;
7270 expect ( screen . getByText ( 'alice@example.com' ) ) . toBeInTheDocument ( ) ;
7371 expect ( screen . getByText ( 'Admin' ) ) . toBeInTheDocument ( ) ;
7472 expect ( screen . getByText ( 'Editor' ) ) . toBeInTheDocument ( ) ;
7573
76- expect ( screen . getByText ( 'Bob ' ) ) . toBeInTheDocument ( ) ;
74+ expect ( screen . getByText ( 'bob ' ) ) . toBeInTheDocument ( ) ;
7775 expect ( screen . getByText ( 'bob@example.com' ) ) . toBeInTheDocument ( ) ;
7876 expect ( screen . getByText ( 'Viewer' ) ) . toBeInTheDocument ( ) ;
7977 } ) ;
Original file line number Diff line number Diff line change @@ -25,11 +25,24 @@ const EmailCell = ({ row }: CellProps) => (row.original?.username === SKELETON_R
2525 row . original . email
2626) ) ;
2727
28- const NameCell = ( { row } : CellProps ) => ( row . original . username === SKELETON_ROWS [ 0 ] . username ? (
29- < Skeleton width = "180px" />
30- ) : (
31- row . original . displayName
32- ) ) ;
28+ const NameCell = ( { row } : CellProps ) => {
29+ const intl = useIntl ( ) ;
30+ const { username } = useLibraryAuthZ ( ) ;
31+
32+ if ( row . original . username === SKELETON_ROWS [ 0 ] . username ) {
33+ return < Skeleton width = "180px" /> ;
34+ }
35+
36+ if ( row . original . username === username ) {
37+ return (
38+ < span >
39+ { username }
40+ < span className = "text-gray-500" > { intl . formatMessage ( messages [ 'library.authz.team.table.username.current' ] ) } </ span >
41+ </ span >
42+ ) ;
43+ }
44+ return row . original . username ;
45+ } ;
3346
3447const RolesCell = ( { row } : CellProps ) => ( row . original . username === SKELETON_ROWS [ 0 ] . username ? (
3548 < Skeleton width = "80px" />
@@ -82,8 +95,8 @@ const TeamTable = () => {
8295 columns = {
8396 [
8497 {
85- Header : intl . formatMessage ( messages [ 'library.authz.team.table.display.name ' ] ) ,
86- accessor : 'displayName ' ,
98+ Header : intl . formatMessage ( messages [ 'library.authz.team.table.username ' ] ) ,
99+ accessor : 'username ' ,
87100 Cell : NameCell ,
88101 } ,
89102 {
Original file line number Diff line number Diff line change 11import { defineMessages } from '@edx/frontend-platform/i18n' ;
22
33const messages = defineMessages ( {
4- 'library.authz.team.table.display.name' : {
5- id : 'library.authz.team.table.display.name' ,
6- defaultMessage : 'Name' ,
7- description : 'Libraries team management table name column header' ,
4+ 'library.authz.team.table.username' : {
5+ id : 'library.authz.team.table.username' ,
6+ defaultMessage : 'Username' ,
7+ description : 'Libraries team management table username column header' ,
8+ } ,
9+ 'library.authz.team.table.username.current' : {
10+ id : 'library.authz.team.table.username.current' ,
11+ defaultMessage : ' (Me)' ,
12+ description : 'Libraries team management table indicative of current user' ,
813 } ,
914 'library.authz.team.table.email' : {
1015 id : 'library.team.table.email' ,
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ export interface PermissionValidationResponse extends PermissionValidationReques
1010
1111// Libraries AuthZ types
1212export interface TeamMember {
13- displayName : string ;
1413 username : string ;
1514 email : string ;
1615 roles : string [ ] ;
You can’t perform that action at this time.
0 commit comments