import React, { PureComponent } from 'react'; import { dateTimeFormat } from '@grafana/data'; import { Button, LinkButton } from '@grafana/ui'; import { contextSrv } from 'app/core/core'; import { AccessControlAction, SyncInfo, UserDTO } from 'app/types'; interface Props { ldapSyncInfo: SyncInfo; user: UserDTO; onUserSync: () => void; } interface State {} const format = 'dddd YYYY-MM-DD HH:mm zz'; const debugLDAPMappingBaseURL = '/admin/ldap'; export class UserLdapSyncInfo extends PureComponent { onUserSync = () => { this.props.onUserSync(); }; render() { const { ldapSyncInfo, user } = this.props; const nextSyncSuccessful = ldapSyncInfo && ldapSyncInfo.nextSync; const nextSyncTime = nextSyncSuccessful ? dateTimeFormat(ldapSyncInfo.nextSync, { format }) : ''; const debugLDAPMappingURL = `${debugLDAPMappingBaseURL}?user=${user && user.login}`; const canReadLDAPUser = contextSrv.hasPermission(AccessControlAction.LDAPUsersRead); const canSyncLDAPUser = contextSrv.hasPermission(AccessControlAction.LDAPUsersSync); return ( <>

LDAP Synchronisation

{ldapSyncInfo.enabled ? ( <> ) : ( <> )}
External sync User synced via LDAP. Some changes must be done in LDAP or mappings. LDAP
Next scheduled synchronization {nextSyncTime}Next scheduled synchronization Not enabled
{canSyncLDAPUser && ( )} {canReadLDAPUser && ( Debug LDAP Mapping )}
); } }