mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Replace icons in dashboard and settings * Replace icons in alerting * Update batch of icons * Implement icons accross various files * Style updates * Search: Fix recent and starred icons * Update styling and details * Replace new icon created by unicons * Fix e2e test, styling * Minor styling updates Co-authored-by: Clarity-89 <homes89@ukr.net>
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { Alert, Icon } from '@grafana/ui';
|
|
import { AppNotificationSeverity, LdapConnectionInfo, LdapServerInfo } from 'app/types';
|
|
|
|
interface Props {
|
|
ldapConnectionInfo: LdapConnectionInfo;
|
|
}
|
|
|
|
export const LdapConnectionStatus: FC<Props> = ({ ldapConnectionInfo }) => {
|
|
return (
|
|
<>
|
|
<h3 className="page-heading">LDAP Connection</h3>
|
|
<div className="gf-form-group">
|
|
<div className="gf-form">
|
|
<table className="filter-table form-inline">
|
|
<thead>
|
|
<tr>
|
|
<th>Host</th>
|
|
<th colSpan={2}>Port</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{ldapConnectionInfo &&
|
|
ldapConnectionInfo.map((serverInfo, index) => (
|
|
<tr key={index}>
|
|
<td>{serverInfo.host}</td>
|
|
<td>{serverInfo.port}</td>
|
|
<td>
|
|
{serverInfo.available ? (
|
|
<Icon name="check" className="pull-right" />
|
|
) : (
|
|
<Icon name="exclamation-triangle" className="pull-right" />
|
|
)}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div className="gf-form-group">
|
|
<LdapErrorBox ldapConnectionInfo={ldapConnectionInfo} />
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
interface LdapConnectionErrorProps {
|
|
ldapConnectionInfo: LdapConnectionInfo;
|
|
}
|
|
|
|
export const LdapErrorBox: FC<LdapConnectionErrorProps> = ({ ldapConnectionInfo }) => {
|
|
const hasError = ldapConnectionInfo.some(info => info.error);
|
|
if (!hasError) {
|
|
return null;
|
|
}
|
|
|
|
const connectionErrors: LdapServerInfo[] = [];
|
|
ldapConnectionInfo.forEach(info => {
|
|
if (info.error) {
|
|
connectionErrors.push(info);
|
|
}
|
|
});
|
|
|
|
const errorElements = connectionErrors.map((info, index) => (
|
|
<div key={index}>
|
|
<span style={{ fontWeight: 500 }}>
|
|
{info.host}:{info.port}
|
|
<br />
|
|
</span>
|
|
<span>{info.error}</span>
|
|
{index !== connectionErrors.length - 1 && (
|
|
<>
|
|
<br />
|
|
<br />
|
|
</>
|
|
)}
|
|
</div>
|
|
));
|
|
|
|
return <Alert title="Connection error" severity={AppNotificationSeverity.Error} children={errorElements} />;
|
|
};
|