grafana/public/app/features/admin/ldap/LdapSyncInfo.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

64 lines
1.7 KiB
TypeScript

import React, { PureComponent } from 'react';
import { dateTimeFormat } from '@grafana/data';
import { Button, Spinner } from '@grafana/ui';
import { SyncInfo } from 'app/types';
interface Props {
ldapSyncInfo: SyncInfo;
}
interface State {
isSyncing: boolean;
}
const format = 'dddd YYYY-MM-DD HH:mm zz';
export class LdapSyncInfo extends PureComponent<Props, State> {
state = {
isSyncing: false,
};
handleSyncClick = () => {
this.setState({ isSyncing: !this.state.isSyncing });
};
render() {
const { ldapSyncInfo } = this.props;
const { isSyncing } = this.state;
const nextSyncTime = dateTimeFormat(ldapSyncInfo.nextSync, { format });
return (
<>
<h3 className="page-heading">
LDAP Synchronisation
<Button className="pull-right" onClick={this.handleSyncClick} hidden>
<span className="btn-title">Bulk-sync now</span>
{isSyncing && <Spinner inline={true} />}
</Button>
</h3>
<div className="gf-form-group">
<div className="gf-form">
<table className="filter-table form-inline">
<tbody>
<tr>
<td>Active synchronisation</td>
<td colSpan={2}>{ldapSyncInfo.enabled ? 'Enabled' : 'Disabled'}</td>
</tr>
<tr>
<td>Scheduled</td>
<td>{ldapSyncInfo.schedule}</td>
</tr>
<tr>
<td>Next scheduled synchronisation</td>
<td>{nextSyncTime}</td>
</tr>
</tbody>
</table>
</div>
</div>
</>
);
}
}