@@ -2,6 +2,7 @@ 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 AppActions from 'common/dispatcher/app-actions'
56import OrganisationStore from 'common/stores/organisation-store'
67import getUserDisplayName from 'common/utils/getUserDisplayName'
78import Token from './Token'
@@ -341,12 +342,23 @@ export default class AdminAPIKeys extends PureComponent {
341342
342343 componentDidMount ( ) {
343344 this . fetch ( )
345+ AppActions . getOrganisation ( this . props . organisationId )
346+ OrganisationStore . on ( 'change' , this . onOrganisationChange )
347+ }
348+
349+ componentWillUnmount ( ) {
350+ OrganisationStore . off ( 'change' , this . onOrganisationChange )
351+ }
352+
353+ onOrganisationChange = ( ) => {
354+ this . forceUpdate ( )
344355 }
345356
346357 componentDidUpdate ( ) {
347358 if ( this . props . organisationId === this . state . organisationId ) return
348359
349360 this . fetch ( )
361+ AppActions . getOrganisation ( this . props . organisationId )
350362 this . setState ( { organisationId : this . props . organisationId } )
351363 }
352364
@@ -446,12 +458,12 @@ export default class AdminAPIKeys extends PureComponent {
446458 { `Create API Key` }
447459 </ Button >
448460 </ Column >
449- { this . state . isLoading && (
461+ { ( this . state . isLoading || ! OrganisationStore . model ?. users ) && (
450462 < div className = 'text-center' >
451463 < Loader />
452464 </ div >
453465 ) }
454- { ! ! apiKeys && ! ! apiKeys . length && (
466+ { ! ! apiKeys && ! ! apiKeys . length && ! ! OrganisationStore . model ?. users && (
455467 < PanelSearch
456468 className = 'no-pad'
457469 items = { apiKeys }
@@ -464,9 +476,9 @@ export default class AdminAPIKeys extends PureComponent {
464476 ) && (
465477 < Flex className = 'table-column' >
466478 < 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.
479+ This field may be blank if the key was created before this
480+ information was tracked, or if the user has since left the
481+ organisation.
470482 </ Tooltip >
471483 </ Flex >
472484 ) }
0 commit comments