From f23fb740a93ee883528cf54ec8f7b66690b31455 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Tue, 16 Jan 2018 11:28:14 +0100 Subject: [PATCH] dashfolders: Add FolderPermissions container and make sure isFolder is passed to PermissionsStore #10275 --- .../ManageDashboards/FolderPermissions.tsx | 40 +++++++++++++++++++ .../components/Permissions/Permissions.tsx | 17 ++++---- public/app/routes/routes.ts | 13 ++++-- .../PermissionsStore/PermissionsStore.ts | 21 ++++++---- 4 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 public/app/containers/ManageDashboards/FolderPermissions.tsx diff --git a/public/app/containers/ManageDashboards/FolderPermissions.tsx b/public/app/containers/ManageDashboards/FolderPermissions.tsx new file mode 100644 index 00000000000..b5d5129878a --- /dev/null +++ b/public/app/containers/ManageDashboards/FolderPermissions.tsx @@ -0,0 +1,40 @@ +import React, { Component } from 'react'; +import { inject, observer } from 'mobx-react'; +import { toJS } from 'mobx'; +import IContainerProps from 'app/containers/IContainerProps'; +import PageHeader from 'app/core/components/PageHeader/PageHeader'; +import Permissions from 'app/core/components/Permissions/Permissions'; + +@inject('nav', 'folder', 'view') +@observer +export class FolderPermissions extends Component { + dashboard: any; + + constructor(props) { + super(props); + this.loadStore(); + } + + loadStore() { + const { nav, folder, view } = this.props; + return folder.load(view.routeParams.get('slug') as string).then(res => { + this.dashboard = res.dashboard; + return nav.initFolderNav(toJS(folder.folder), 'manage-folder-permissions'); + }); + } + + render() { + const { nav, folder } = this.props; + + if (!folder.folder || !nav.main) { + return

Loading

; + } + + return ( +
+ + +
+ ); + } +} diff --git a/public/app/core/components/Permissions/Permissions.tsx b/public/app/core/components/Permissions/Permissions.tsx index a01cf8d4e2e..462e5195fa7 100644 --- a/public/app/core/components/Permissions/Permissions.tsx +++ b/public/app/core/components/Permissions/Permissions.tsx @@ -26,12 +26,11 @@ export interface DashboardAcl { } export interface IProps { - error: any; - newType: any; - aclTypes: any; - backendSrv: any; + error: string; + newType: string; dashboardId: number; permissions: any; + isFolder: boolean; } class Permissions extends Component { @@ -67,14 +66,12 @@ class PermissionsInner extends Component { constructor(props) { super(props); - - const { dashboardId, permissions } = this.props; - + const { dashboardId, permissions, isFolder } = this.props; this.permissionChanged = this.permissionChanged.bind(this); this.typeChanged = this.typeChanged.bind(this); this.removeItem = this.removeItem.bind(this); this.update = this.update.bind(this); - permissions.load(dashboardId); + permissions.load(dashboardId, isFolder); this.state = { newType: 'Group', @@ -134,7 +131,7 @@ class PermissionsInner extends Component { render() { console.log('PermissionsInner render'); - const { error, aclTypes, permissions } = this.props; + const { error, permissions } = this.props; const { newType } = this.state; return ( @@ -153,7 +150,7 @@ class PermissionsInner extends Component {