2020-01-13 10:10:19 -06:00
|
|
|
|
import React, { PureComponent } from 'react';
|
2020-04-27 08:28:06 -05:00
|
|
|
|
import { dateTimeFormat } from '@grafana/data';
|
2020-01-13 10:10:19 -06:00
|
|
|
|
import { SyncInfo, UserDTO } from 'app/types';
|
|
|
|
|
import { Button, LinkButton } from '@grafana/ui';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
ldapSyncInfo: SyncInfo;
|
|
|
|
|
user: UserDTO;
|
|
|
|
|
onUserSync: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface State {}
|
|
|
|
|
|
2020-04-27 08:28:06 -05:00
|
|
|
|
const format = 'dddd YYYY-MM-DD HH:mm zz';
|
2020-01-13 10:10:19 -06:00
|
|
|
|
const debugLDAPMappingBaseURL = '/admin/ldap';
|
|
|
|
|
|
|
|
|
|
export class UserLdapSyncInfo extends PureComponent<Props, State> {
|
|
|
|
|
onUserSync = () => {
|
|
|
|
|
this.props.onUserSync();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { ldapSyncInfo, user } = this.props;
|
|
|
|
|
const prevSyncSuccessful = ldapSyncInfo && ldapSyncInfo.prevSync;
|
2020-04-27 08:28:06 -05:00
|
|
|
|
const nextSyncSuccessful = ldapSyncInfo && ldapSyncInfo.nextSync;
|
|
|
|
|
const nextSyncTime = nextSyncSuccessful ? dateTimeFormat(ldapSyncInfo.nextSync, { format }) : '';
|
Chore: Fix all Typescript strict null errors (#26204)
* 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>
2020-07-10 05:46:59 -05:00
|
|
|
|
const prevSyncTime = prevSyncSuccessful ? dateTimeFormat(ldapSyncInfo.prevSync!.started, { format }) : '';
|
2020-01-13 10:10:19 -06:00
|
|
|
|
const debugLDAPMappingURL = `${debugLDAPMappingBaseURL}?user=${user && user.login}`;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<h3 className="page-heading">LDAP Synchronisation</h3>
|
|
|
|
|
<div className="gf-form-group">
|
|
|
|
|
<div className="gf-form">
|
|
|
|
|
<table className="filter-table form-inline">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td>External sync</td>
|
|
|
|
|
<td>User synced via LDAP – some changes must be done in LDAP or mappings.</td>
|
|
|
|
|
<td>
|
|
|
|
|
<span className="label label-tag">LDAP</span>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
{ldapSyncInfo.enabled ? (
|
|
|
|
|
<>
|
|
|
|
|
<td>Next scheduled synchronisation</td>
|
|
|
|
|
<td colSpan={2}>{nextSyncTime}</td>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<td>Next scheduled synchronisation</td>
|
|
|
|
|
<td colSpan={2}>Not enabled</td>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
{prevSyncSuccessful ? (
|
|
|
|
|
<>
|
|
|
|
|
<td>Last synchronisation</td>
|
|
|
|
|
<td>{prevSyncTime}</td>
|
|
|
|
|
<td>Successful</td>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<td colSpan={3}>Last synchronisation</td>
|
|
|
|
|
)}
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="gf-form-button-row">
|
|
|
|
|
<Button variant="secondary" onClick={this.onUserSync}>
|
|
|
|
|
Sync user
|
|
|
|
|
</Button>
|
2020-03-26 05:50:27 -05:00
|
|
|
|
<LinkButton variant="secondary" href={debugLDAPMappingURL}>
|
2020-01-13 10:10:19 -06:00
|
|
|
|
Debug LDAP Mapping
|
|
|
|
|
</LinkButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|