dashfolders: add disabled Admin permission to list

This is a fake entry that is used to signal to the user that an Admin
user always has Admin rights and they cannot be removed.
This commit is contained in:
Daniel Lee
2018-01-26 14:38:10 +01:00
parent ccd86873e7
commit 83548f98b9
3 changed files with 51 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
import React, { Component } from 'react';
import { permissionOptions } from 'app/stores/PermissionsStore/PermissionsStore';
export interface IProps {
item: any;
}
export default class DisabledPermissionListItem extends Component<IProps, any> {
render() {
const { item } = this.props;
return (
<tr className="gf-form-disabled">
<td style={{ width: '100%' }}>
<i className={item.icon} />
<span dangerouslySetInnerHTML={{ __html: item.nameHtml }} />
</td>
<td />
<td className="query-keyword">Can</td>
<td>
<div className="gf-form-select-wrapper">
<select value={item.permission} className="gf-form-input gf-size-auto" disabled={true}>
{permissionOptions.map((option, idx) => {
return (
<option key={idx} value={option.value}>
{option.text}
</option>
);
})}
</select>
</div>
</td>
<td>
<button className="btn btn-inverse btn-small">
<i className="fa fa-lock" />
</button>
</td>
</tr>
);
}
}

View File

@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import PermissionsListItem from './PermissionsListItem';
import DisabledPermissionsListItem from './DisabledPermissionsListItem';
import { observer } from 'mobx-react';
export interface IProps {
@@ -17,10 +18,18 @@ class PermissionsList extends Component<IProps, any> {
return (
<table className="filter-table gf-form-group">
<tbody>
<DisabledPermissionsListItem
key={0}
item={{
nameHtml: 'Everyone with <span class="query-keyword">Admin</span> Role',
permission: 4,
icon: 'fa fa-fw fa-street-view',
}}
/>
{permissions.map((item, idx) => {
return (
<PermissionsListItem
key={idx}
key={idx + 1}
item={item}
itemIndex={idx}
removeItem={removeItem}

View File

@@ -26,7 +26,6 @@ describe('PermissionsStore', () => {
store = PermissionsStore.create(
{
fetching: false,
canUpdate: false,
items: [],
},
{