mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* refactor(loginpage): migrate custom button styles to use Button component * refactor(certificationkey): prefer grafana-ui form elements over html elements and classnames * refactor(axisselector): prefer grafana-ui Button component over html button element * refactor(input-datasource): replace use of btn class with grafana-ui components * chore(grafana-ui): delete deprecated ToggleButtonGroup component * refactor: replace btn and cta-form__close class usage with IconButton * chore(closebutton): post master merge use v2 theme * refactor(permissionlist): remove usage of .btn classname * Wip * docs(styling): update styling and theme docs import paths * refactor(alerting): remote btn classnames from TestRuleResult * refactor(apikeys): prefer grafana-ui Button components over btn classNames * refactor(folders): prefer grafana-ui Button components over btn classNames * refactor(teams): prefer grafana-ui Button components over btn classNames * refactor(datasources): prefer grafana-ui Button components over btn classNames * refactor: prefer grafana-ui Button components over btn classNames * Minor style tweak to service buttons * test: update snapshots related to button changes * chore(input-datasource): remove unused import declaration * refactor(loginservicebuttons): rename theme.palette to theme.colors Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { UserDTO, UserOrg } from 'app/types';
|
|
import { LoadingPlaceholder, Button } from '@grafana/ui';
|
|
|
|
export interface Props {
|
|
user: UserDTO;
|
|
orgs: UserOrg[];
|
|
isLoading: boolean;
|
|
loadOrgs: () => void;
|
|
setUserOrg: (org: UserOrg) => void;
|
|
}
|
|
|
|
export class UserOrganizations extends PureComponent<Props> {
|
|
componentDidMount() {
|
|
this.props.loadOrgs();
|
|
}
|
|
|
|
render() {
|
|
const { isLoading, orgs, user } = this.props;
|
|
|
|
if (isLoading) {
|
|
return <LoadingPlaceholder text="Loading organizations..." />;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{orgs.length > 0 && (
|
|
<>
|
|
<h3 className="page-sub-heading">Organizations</h3>
|
|
<div className="gf-form-group">
|
|
<table className="filter-table form-inline">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Role</th>
|
|
<th />
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{orgs.map((org: UserOrg, index) => {
|
|
return (
|
|
<tr key={index}>
|
|
<td>{org.name}</td>
|
|
<td>{org.role}</td>
|
|
<td className="text-right">
|
|
{org.orgId === user.orgId ? (
|
|
<Button variant="secondary" size="sm" disabled>
|
|
Current
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
variant="secondary"
|
|
size="sm"
|
|
onClick={() => {
|
|
this.props.setUserOrg(org);
|
|
}}
|
|
>
|
|
Select
|
|
</Button>
|
|
)}
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default UserOrganizations;
|