@@ -2,7 +2,8 @@ import React, { PureComponent } from 'react'
22import { close as closeIcon } from 'ionicons/icons'
33import { IonIcon } from '@ionic/react'
44import data from 'common/data/base/_data'
5- import InfoMessage from './InfoMessage'
5+ import OrganisationStore from 'common/stores/organisation-store'
6+ import getUserDisplayName from 'common/utils/getUserDisplayName'
67import Token from './Token'
78import JSONReference from './JSONReference'
89import Button from './base/forms/Button'
@@ -458,6 +459,17 @@ export default class AdminAPIKeys extends PureComponent {
458459 < Row className = 'table-header' >
459460 < Flex className = 'table-column px-3' > API Keys</ Flex >
460461 < Flex className = 'table-column' > Created</ Flex >
462+ { Utils . getFlagsmithHasFeature (
463+ 'organisation_api_keys_created_by' ,
464+ ) && (
465+ < Flex className = 'table-column' >
466+ < Tooltip title = 'Created by' place = 'right' >
467+ This field may be blank if the key was created before
468+ this information was tracked, or if the user has since
469+ left the organisation.
470+ </ Tooltip >
471+ </ Flex >
472+ ) }
461473 < Flex className = 'table-column' > Is Admin</ Flex >
462474 < Flex className = 'table-column' > Active</ Flex >
463475 < div
@@ -468,59 +480,71 @@ export default class AdminAPIKeys extends PureComponent {
468480 </ div >
469481 </ Row >
470482 }
471- renderRow = { ( v ) =>
472- ! v . revoked && (
473- < Row
474- className = 'list-item'
475- key = { v . id }
476- onClick = { ( ) => this . editAPIKey ( v . name , v . id , v . prefix ) }
477- >
478- < Flex className = 'table-column px-3' >
479- < div className = 'font-weight-medium mb-1' > { v . name } </ div >
480- < div className = 'list-item-subtitle' >
481- < div > { v . prefix } *****************</ div >
482- </ div >
483- </ Flex >
484- < Flex className = 'table-column fs-small lh-sm' >
485- { moment ( v . created ) . format ( 'Do MMM YYYY HH:mma' ) }
486- </ Flex >
487- < Flex className = 'table-column fs-small lh-sm' >
488- < Switch checked = { v . is_admin } disabled = { true } />
489- </ Flex >
490- < Flex className = 'table-column fs-small lh-sm' >
491- { v . has_expired ? (
492- < div className = 'ml-1' >
493- < Tooltip title = { < Icon name = 'close-circle' /> } >
494- { 'This API key has expired' }
495- </ Tooltip >
483+ renderRow = { ( v ) => {
484+ const orgUsers = OrganisationStore . model ?. users
485+ const createdByUser =
486+ v . created_by && orgUsers ?. find ( ( u ) => u . id === v . created_by )
487+ return (
488+ ! v . revoked && (
489+ < Row
490+ className = 'list-item'
491+ key = { v . id }
492+ onClick = { ( ) => this . editAPIKey ( v . name , v . id , v . prefix ) }
493+ >
494+ < Flex className = 'table-column px-3' >
495+ < div className = 'font-weight-medium mb-1' > { v . name } </ div >
496+ < div className = 'list-item-subtitle' >
497+ < div > { v . prefix } *****************</ div >
496498 </ div >
497- ) : (
498- < span className = 'ml-1' >
499- < Icon
500- name = 'checkmark-circle'
501- fill = '#27AB95'
502- width = { 28 }
503- />
504- </ span >
499+ </ Flex >
500+ < Flex className = 'table-column fs-small lh-sm' >
501+ { moment ( v . created ) . format ( 'Do MMM YYYY HH:mma' ) }
502+ </ Flex >
503+ { Utils . getFlagsmithHasFeature (
504+ 'organisation_api_keys_created_by' ,
505+ ) && (
506+ < Flex className = 'table-column fs-small lh-sm' >
507+ { getUserDisplayName ( createdByUser , '-' ) }
508+ </ Flex >
505509 ) }
506- </ Flex >
507- < div
508- className = 'table-column text-center'
509- style = { { width : '80px' } }
510- >
511- < Button
512- onClick = { ( e ) => {
513- e . stopPropagation ( )
514- this . remove ( v )
515- } }
516- className = 'btn btn-with-icon'
510+ < Flex className = 'table-column fs-small lh-sm' >
511+ < Switch checked = { v . is_admin } disabled = { true } />
512+ </ Flex >
513+ < Flex className = 'table-column fs-small lh-sm' >
514+ { v . has_expired ? (
515+ < div className = 'ml-1' >
516+ < Tooltip title = { < Icon name = 'close-circle' /> } >
517+ { 'This API key has expired' }
518+ </ Tooltip >
519+ </ div >
520+ ) : (
521+ < span className = 'ml-1' >
522+ < Icon
523+ name = 'checkmark-circle'
524+ fill = '#27AB95'
525+ width = { 28 }
526+ />
527+ </ span >
528+ ) }
529+ </ Flex >
530+ < div
531+ className = 'table-column text-center'
532+ style = { { width : '80px' } }
517533 >
518- < Icon name = 'trash-2' width = { 20 } fill = '#656D7B' />
519- </ Button >
520- </ div >
521- </ Row >
534+ < Button
535+ onClick = { ( e ) => {
536+ e . stopPropagation ( )
537+ this . remove ( v )
538+ } }
539+ className = 'btn btn-with-icon'
540+ >
541+ < Icon name = 'trash-2' width = { 20 } fill = '#656D7B' />
542+ </ Button >
543+ </ div >
544+ </ Row >
545+ )
522546 )
523- }
547+ } }
524548 />
525549 ) }
526550 </ div >
0 commit comments