mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Now at 218 * Progress * Update * Progress * Updated tests * at 159 * fixed tests * Progress * YAy blow 100! at 94 * 10,9,8,7,6,5,4,3,2,1... lift off * Fixed tests * Fixed more type errors Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { dateTimeFormat } from '@grafana/data';
|
|
import { LdapUserSyncInfo } from 'app/types';
|
|
import { Icon } from '@grafana/ui';
|
|
|
|
interface Props {
|
|
disableSync: boolean;
|
|
syncInfo: LdapUserSyncInfo;
|
|
onSync?: () => void;
|
|
}
|
|
|
|
interface State {
|
|
isSyncing: boolean;
|
|
}
|
|
|
|
const format = 'dddd YYYY-MM-DD HH:mm zz';
|
|
|
|
export class UserSyncInfo extends PureComponent<Props, State> {
|
|
state = {
|
|
isSyncing: false,
|
|
};
|
|
|
|
onSyncClick = async () => {
|
|
const { onSync } = this.props;
|
|
this.setState({ isSyncing: true });
|
|
try {
|
|
if (onSync) {
|
|
await onSync();
|
|
}
|
|
} finally {
|
|
this.setState({ isSyncing: false });
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const { syncInfo, disableSync } = this.props;
|
|
const { isSyncing } = this.state;
|
|
const nextSyncSuccessful = syncInfo && syncInfo.nextSync;
|
|
const nextSyncTime = nextSyncSuccessful ? dateTimeFormat(syncInfo.nextSync!, { format }) : '';
|
|
const prevSyncSuccessful = syncInfo && syncInfo.prevSync;
|
|
const prevSyncTime = prevSyncSuccessful ? dateTimeFormat(syncInfo.prevSync!, { format }) : '';
|
|
const isDisabled = isSyncing || disableSync;
|
|
|
|
return (
|
|
<>
|
|
<button className={`btn btn-secondary pull-right`} onClick={this.onSyncClick} disabled={isDisabled}>
|
|
<span className="btn-title">Sync user</span>
|
|
{isSyncing && <Icon name="fa fa-spinner" className="fa-fw fa-spin run-icon" />}
|
|
</button>
|
|
|
|
<div className="clearfix" />
|
|
|
|
<h3 className="page-heading">LDAP</h3>
|
|
<div className="gf-form-group">
|
|
<div className="gf-form">
|
|
<table className="filter-table form-inline">
|
|
<tbody>
|
|
<tr>
|
|
<td>Last synchronisation</td>
|
|
<td>{prevSyncTime}</td>
|
|
{prevSyncSuccessful && <td className="pull-right">Successful</td>}
|
|
</tr>
|
|
<tr>
|
|
<td>Next scheduled synchronisation</td>
|
|
<td colSpan={2}>{nextSyncTime}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
}
|