mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 03:32:37 -06:00
8de606aa22
* Set min height of panel pane to 200px * Disable badge on viz picker when item is in disabled in search results * Fix UserProfile inputs width * Remove select caret in user admin permissions editor * fix 23911
103 lines
2.9 KiB
TypeScript
103 lines
2.9 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { ConfirmButton, RadioButtonGroup, Icon } from '@grafana/ui';
|
|
import { cx } from 'emotion';
|
|
|
|
interface Props {
|
|
isGrafanaAdmin: boolean;
|
|
|
|
onGrafanaAdminChange: (isGrafanaAdmin: boolean) => void;
|
|
}
|
|
|
|
interface State {
|
|
isEditing: boolean;
|
|
currentAdminOption: string;
|
|
}
|
|
|
|
const adminOptions = [
|
|
{ label: 'Yes', value: 'YES' },
|
|
{ label: 'No', value: 'NO' },
|
|
];
|
|
|
|
export class UserPermissions extends PureComponent<Props, State> {
|
|
state = {
|
|
isEditing: false,
|
|
currentAdminOption: this.props.isGrafanaAdmin ? 'YES' : 'NO',
|
|
};
|
|
|
|
onChangeClick = () => {
|
|
this.setState({ isEditing: true });
|
|
};
|
|
|
|
onCancelClick = () => {
|
|
this.setState({
|
|
isEditing: false,
|
|
currentAdminOption: this.props.isGrafanaAdmin ? 'YES' : 'NO',
|
|
});
|
|
};
|
|
|
|
onGrafanaAdminChange = () => {
|
|
const { currentAdminOption } = this.state;
|
|
const newIsGrafanaAdmin = currentAdminOption === 'YES' ? true : false;
|
|
this.props.onGrafanaAdminChange(newIsGrafanaAdmin);
|
|
};
|
|
|
|
onAdminOptionSelect = (value: string) => {
|
|
this.setState({ currentAdminOption: value });
|
|
};
|
|
|
|
render() {
|
|
const { isGrafanaAdmin } = this.props;
|
|
const { isEditing, currentAdminOption } = this.state;
|
|
const changeButtonContainerClass = cx('pull-right');
|
|
|
|
return (
|
|
<>
|
|
<h3 className="page-heading">Permissions</h3>
|
|
<div className="gf-form-group">
|
|
<div className="gf-form">
|
|
<table className="filter-table form-inline">
|
|
<tbody>
|
|
<tr>
|
|
<td className="width-16">Grafana Admin</td>
|
|
{isEditing ? (
|
|
<td colSpan={2}>
|
|
<RadioButtonGroup
|
|
options={adminOptions}
|
|
value={currentAdminOption}
|
|
onChange={this.onAdminOptionSelect}
|
|
/>
|
|
</td>
|
|
) : (
|
|
<td colSpan={2}>
|
|
{isGrafanaAdmin ? (
|
|
<>
|
|
<Icon name="shield" /> Yes
|
|
</>
|
|
) : (
|
|
<>No</>
|
|
)}
|
|
</td>
|
|
)}
|
|
<td>
|
|
<div className={changeButtonContainerClass}>
|
|
<ConfirmButton
|
|
className="pull-right"
|
|
onClick={this.onChangeClick}
|
|
onConfirm={this.onGrafanaAdminChange}
|
|
onCancel={this.onCancelClick}
|
|
confirmText="Change"
|
|
>
|
|
Change
|
|
</ConfirmButton>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
}
|