import React, { PureComponent } from 'react'; import { dateTime } from '@grafana/data'; import { SyncInfo } from 'app/types'; interface Props { ldapSyncInfo: SyncInfo; } interface State { isSyncing: boolean; } const syncTimeFormat = 'dddd YYYY-MM-DD HH:mm zz'; export class LdapSyncInfo extends PureComponent { state = { isSyncing: false, }; handleSyncClick = () => { console.log('Bulk-sync now'); this.setState({ isSyncing: !this.state.isSyncing }); }; render() { const { ldapSyncInfo } = this.props; const { isSyncing } = this.state; const nextSyncTime = dateTime(ldapSyncInfo.nextSync).format(syncTimeFormat); const prevSyncSuccessful = ldapSyncInfo && ldapSyncInfo.prevSync; const prevSyncTime = prevSyncSuccessful ? dateTime(ldapSyncInfo.prevSync.started).format(syncTimeFormat) : ''; return ( <>

LDAP Synchronisation

{prevSyncSuccessful && ( <> )}
Active synchronisation {ldapSyncInfo.enabled ? 'Enabled' : 'Disabled'}
Scheduled {ldapSyncInfo.schedule}
Next scheduled synchronisation {nextSyncTime}
Last synchronisation{prevSyncTime} Successful
); } }