diff --git a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx index 1d828127e93..f1c663de155 100644 --- a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx +++ b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx @@ -144,7 +144,7 @@ class UnThemedConfirmButton extends PureComponent { )} - @@ -63,8 +74,6 @@ export class UserOrgs extends PureComponent { } } -const ORG_ROLES = ['Viewer', 'Editor', 'Admin']; - const getOrgRowStyles = stylesFactory((theme: GrafanaTheme) => { return { removeButton: css` @@ -85,16 +94,14 @@ interface OrgRowProps extends Themeable { } interface OrgRowState { - currentRole: string; + currentRole: OrgRole; isChangingRole: boolean; - isRemovingFromOrg: boolean; } class UnThemedOrgRow extends PureComponent { state = { currentRole: this.props.org.role, isChangingRole: false, - isRemovingFromOrg: false, }; onOrgRemove = () => { @@ -107,12 +114,7 @@ class UnThemedOrgRow extends PureComponent { this.setState({ isChangingRole: true, currentRole: org.role }); }; - onOrgRemoveClick = () => { - this.setState({ isRemovingFromOrg: true }); - }; - - onOrgRoleChange = (event: React.ChangeEvent) => { - const newRole = event.target.value; + onOrgRoleChange = (newRole: OrgRole) => { this.setState({ currentRole: newRole }); }; @@ -121,12 +123,12 @@ class UnThemedOrgRow extends PureComponent { }; onCancelClick = () => { - this.setState({ isChangingRole: false, isRemovingFromOrg: false }); + this.setState({ isChangingRole: false }); }; render() { const { org, theme } = this.props; - const { currentRole, isChangingRole, isRemovingFromOrg } = this.state; + const { currentRole, isChangingRole } = this.state; const styles = getOrgRowStyles(theme); const labelClass = cx('width-16', styles.label); @@ -135,50 +137,35 @@ class UnThemedOrgRow extends PureComponent { {org.name} {isChangingRole ? ( -
- -
+ ) : ( {org.role} )} - {!isRemovingFromOrg && ( - -
- - Change role - -
- - )} - {!isChangingRole && ( - -
- - Remove from organisation - -
- - )} + +
+ + Change role + +
+ + +
+ + Remove from organisation + +
+ ); } @@ -203,22 +190,22 @@ interface AddToOrgModalProps { interface AddToOrgModalState { selectedOrg: Organization; - role: string; + role: OrgRole; } export class AddToOrgModal extends PureComponent { state: AddToOrgModalState = { selectedOrg: null, - role: 'Admin', + role: OrgRole.Admin, }; onOrgSelect = (org: OrgSelectItem) => { this.setState({ selectedOrg: { ...org } }); }; - onOrgRoleChange = (event: React.ChangeEvent) => { + onOrgRoleChange = (newRole: OrgRole) => { this.setState({ - role: event.target.value, + role: newRole, }); }; @@ -235,36 +222,25 @@ export class AddToOrgModal extends PureComponent -
-
Organisation
- -
-
-
Role
-
- -
-
-
- - -
+ + + + + + + + + + + + ); } diff --git a/public/app/features/admin/UserPermissions.tsx b/public/app/features/admin/UserPermissions.tsx index db9f250dcfe..24f39fc2e26 100644 --- a/public/app/features/admin/UserPermissions.tsx +++ b/public/app/features/admin/UserPermissions.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { ConfirmButton } from '@grafana/ui'; +import { ConfirmButton, RadioButtonGroup } from '@grafana/ui'; import { cx } from 'emotion'; interface Props { @@ -13,6 +13,11 @@ interface State { currentAdminOption: string; } +const adminOptions = [ + { label: 'Yes', value: 'YES' }, + { label: 'No', value: 'NO' }, +]; + export class UserPermissions extends PureComponent { state = { isEditing: false, @@ -36,8 +41,8 @@ export class UserPermissions extends PureComponent { this.props.onGrafanaAdminChange(newIsGrafanaAdmin); }; - onAdminOptionSelect = (event: React.ChangeEvent) => { - this.setState({ currentAdminOption: event.target.value }); + onAdminOptionSelect = (value: string) => { + this.setState({ currentAdminOption: value }); }; render() { @@ -57,19 +62,11 @@ export class UserPermissions extends PureComponent { {isEditing ? (
- + />
) : ( diff --git a/public/app/features/admin/UserProfile.tsx b/public/app/features/admin/UserProfile.tsx index 59de6d26f36..fba3241687a 100644 --- a/public/app/features/admin/UserProfile.tsx +++ b/public/app/features/admin/UserProfile.tsx @@ -3,7 +3,7 @@ import { UserDTO } from 'app/types'; import { cx, css } from 'emotion'; import { config } from 'app/core/config'; import { GrafanaTheme } from '@grafana/data'; -import { ConfirmButton, Input, ConfirmModal, InputStatus, Button, stylesFactory } from '@grafana/ui'; +import { ConfirmButton, ConfirmModal, InputStatus, Button, stylesFactory, Forms } from '@grafana/ui'; interface Props { user: UserDTO; @@ -265,13 +265,13 @@ export class UserProfileRow extends PureComponent{label} {this.state.editing ? ( - ) : ( {this.props.value} diff --git a/public/app/types/user.ts b/public/app/types/user.ts index 1cc1cb054cb..bbf1130a795 100644 --- a/public/app/types/user.ts +++ b/public/app/types/user.ts @@ -1,4 +1,5 @@ import { TimeZone } from '@grafana/data'; +import { OrgRole } from '.'; export interface OrgUser { avatarUrl: string; @@ -88,7 +89,7 @@ export interface UserSession { export interface UserOrg { name: string; orgId: number; - role: string; + role: OrgRole; } export interface UserAdminState {