Commit 85837881 by Peter Holmberg

disable permissions

parent 83480a1d
......@@ -6,6 +6,7 @@ import DataSourcePermissionsList from './DataSourcePermissionsList';
import { AclTarget } from 'app/types/acl';
import {
addDataSourcePermission,
disableDataSourcePermissions,
enableDataSourcePermissions,
loadDataSourcePermissions,
removeDataSourcePermission,
......@@ -18,6 +19,7 @@ export interface Props {
pageId: number;
addDataSourcePermission: typeof addDataSourcePermission;
enableDataSourcePermissions: typeof enableDataSourcePermissions;
disableDataSourcePermissions: typeof disableDataSourcePermissions;
loadDataSourcePermissions: typeof loadDataSourcePermissions;
removeDataSourcePermission: typeof removeDataSourcePermission;
}
......@@ -52,6 +54,12 @@ export class DataSourcePermissions extends PureComponent<Props, State> {
enableDataSourcePermissions(pageId);
};
onDisablePermissions = () => {
const { pageId, disableDataSourcePermissions } = this.props;
disableDataSourcePermissions(pageId);
};
onAddPermission = state => {
const { pageId, addDataSourcePermission } = this.props;
const data = {
......@@ -89,16 +97,19 @@ export class DataSourcePermissions extends PureComponent<Props, State> {
<div className="page-action-bar">
<h3 className="page-sub-heading">Permissions</h3>
<div className="page-action-bar__spacer" />
{!isPermissionsEnabled && (
<button className="btn btn-success pull-right" onClick={this.onEnablePermissions} disabled={isAdding}>
Enable Permissions
</button>
)}
{isPermissionsEnabled && (
<button className="btn btn-success pull-right" onClick={this.onOpenAddPermissions} disabled={isAdding}>
{isPermissionsEnabled && [
<button
key="add-permission"
className="btn btn-success pull-right"
onClick={this.onOpenAddPermissions}
disabled={isAdding}
>
<i className="fa fa-plus" /> Add Permission
</button>
)}
</button>,
<button key="disable-permissions" className="btn btn-danger pull-right" onClick={this.onDisablePermissions}>
Disable Permissions
</button>,
]}
</div>
{!isPermissionsEnabled ? (
<div className="empty-list-cta">
......@@ -140,6 +151,7 @@ function mapStateToProps(state) {
const mapDispatchToProps = {
addDataSourcePermission,
enableDataSourcePermissions,
disableDataSourcePermissions,
loadDataSourcePermissions,
removeDataSourcePermission,
};
......
......@@ -173,6 +173,13 @@ export function enableDataSourcePermissions(id: number): ThunkResult<void> {
};
}
export function disableDataSourcePermissions(id: number): ThunkResult<void> {
return async dispatch => {
await getBackendSrv().post(`/api/datasources/${id}/disable-permissions`, {});
dispatch(loadDataSourcePermissions(id));
};
}
export function addDataSourcePermission(id: number, data: object): ThunkResult<void> {
return async dispatch => {
await getBackendSrv().post(`/api/datasources/${id}/permissions`, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment