From 3a94918b8f9657685524cdd40fa5a83126e08a9c Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Thu, 18 Jan 2018 15:49:15 +0100 Subject: [PATCH] dashfolders: Rename UserPicker folder => Picker. Inject the permission-store in the FolderPermissions-container instead of the Permissions component, add the PermissionsStore to the RootStore and and the error-message to the Permissions-store #10275 --- public/app/containers/IContainerProps.ts | 2 ++ .../ManageDashboards/FolderPermissions.tsx | 12 +++++-- public/app/core/angular_wrappers.ts | 11 ++---- .../components/Permissions/Permissions.tsx | 35 ++++--------------- .../PickerOption.jest.tsx} | 6 ++-- .../PickerOption.tsx} | 0 .../{UserPicker => Picker}/TeamPicker.tsx | 10 +++--- .../UserPicker.jest.tsx | 0 .../{UserPicker => Picker}/UserPicker.tsx | 8 ++--- .../__snapshots__/PickerOption.jest.tsx.snap} | 2 +- .../__snapshots__/UserPicker.jest.tsx.snap | 0 .../{UserPicker => Picker}/withPicker.tsx | 8 ----- .../PermissionsStore/PermissionsStore.ts | 7 +++- 13 files changed, 37 insertions(+), 64 deletions(-) rename public/app/core/components/{UserPicker/UserPickerOption.jest.tsx => Picker/PickerOption.jest.tsx} (70%) rename public/app/core/components/{UserPicker/UserPickerOption.tsx => Picker/PickerOption.tsx} (100%) rename public/app/core/components/{UserPicker => Picker}/TeamPicker.tsx (88%) rename public/app/core/components/{UserPicker => Picker}/UserPicker.jest.tsx (100%) rename public/app/core/components/{UserPicker => Picker}/UserPicker.tsx (90%) rename public/app/core/components/{UserPicker/__snapshots__/UserPickerOption.jest.tsx.snap => Picker/__snapshots__/PickerOption.jest.tsx.snap} (87%) rename public/app/core/components/{UserPicker => Picker}/__snapshots__/UserPicker.jest.tsx.snap (100%) rename public/app/core/components/{UserPicker => Picker}/withPicker.tsx (83%) diff --git a/public/app/containers/IContainerProps.ts b/public/app/containers/IContainerProps.ts index c3eb2d80dee..6e790cee06d 100644 --- a/public/app/containers/IContainerProps.ts +++ b/public/app/containers/IContainerProps.ts @@ -1,6 +1,7 @@ import { SearchStore } from './../stores/SearchStore/SearchStore'; import { ServerStatsStore } from './../stores/ServerStatsStore/ServerStatsStore'; import { NavStore } from './../stores/NavStore/NavStore'; +import { PermissionsStore } from './../stores/PermissionsStore/PermissionsStore'; import { AlertListStore } from './../stores/AlertListStore/AlertListStore'; import { ViewStore } from './../stores/ViewStore/ViewStore'; import { FolderStore } from './../stores/FolderStore/FolderStore'; @@ -10,6 +11,7 @@ interface IContainerProps { serverStats: typeof ServerStatsStore.Type; nav: typeof NavStore.Type; alertList: typeof AlertListStore.Type; + permissions: typeof PermissionsStore.Type; view: typeof ViewStore.Type; folder: typeof FolderStore.Type; backendSrv: any; diff --git a/public/app/containers/ManageDashboards/FolderPermissions.tsx b/public/app/containers/ManageDashboards/FolderPermissions.tsx index 2ad77505c78..b9387e72f73 100644 --- a/public/app/containers/ManageDashboards/FolderPermissions.tsx +++ b/public/app/containers/ManageDashboards/FolderPermissions.tsx @@ -5,7 +5,7 @@ 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') +@inject('nav', 'folder', 'view', 'permissions') @observer export class FolderPermissions extends Component { dashboard: any; @@ -24,7 +24,7 @@ export class FolderPermissions extends Component { } render() { - const { nav, folder } = this.props; + const { nav, folder, permissions } = this.props; if (!folder.folder || !nav.main) { return

Loading

; @@ -34,7 +34,13 @@ export class FolderPermissions extends Component {
- +
); diff --git a/public/app/core/angular_wrappers.ts b/public/app/core/angular_wrappers.ts index 0591a3a2935..0521d85cb30 100644 --- a/public/app/core/angular_wrappers.ts +++ b/public/app/core/angular_wrappers.ts @@ -4,8 +4,8 @@ import PageHeader from './components/PageHeader/PageHeader'; import EmptyListCTA from './components/EmptyListCTA/EmptyListCTA'; import LoginBackground from './components/Login/LoginBackground'; import { SearchResult } from './components/search/SearchResult'; -import UserPicker from './components/UserPicker/UserPicker'; import { TagFilter } from './components/TagFilter/TagFilter'; +import UserPicker from './components/Picker/UserPicker'; import Permissions from './components/Permissions/Permissions'; export function registerAngularDirectives() { @@ -20,12 +20,5 @@ export function registerAngularDirectives() { ['tagOptions', { watchDepth: 'reference' }], ]); react2AngularDirective('selectUserPicker', UserPicker, ['backendSrv', 'handlePicked']); - react2AngularDirective('permissions', Permissions, [ - 'error', - 'newType', - 'aclTypes', - 'typeChanged', - 'backendSrv', - 'dashboardId', - ]); + react2AngularDirective('permissions', Permissions, ['error', 'aclTypes', 'typeChanged', 'backendSrv', 'dashboardId']); } diff --git a/public/app/core/components/Permissions/Permissions.tsx b/public/app/core/components/Permissions/Permissions.tsx index 423dd9c41c0..48d24e97cc0 100644 --- a/public/app/core/components/Permissions/Permissions.tsx +++ b/public/app/core/components/Permissions/Permissions.tsx @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PermissionsList from './PermissionsList'; -import { inject, observer } from 'mobx-react'; -import UserPicker, { User } from 'app/core/components/UserPicker/UserPicker'; -import TeamPicker, { Team } from 'app/core/components/UserPicker/TeamPicker'; +import { observer } from 'mobx-react'; +import UserPicker, { User } from 'app/core/components/Picker/UserPicker'; +import TeamPicker, { Team } from 'app/core/components/Picker/TeamPicker'; export interface DashboardAcl { id?: number; @@ -24,17 +24,14 @@ export interface DashboardAcl { export interface IProps { error: string; - newType: string; dashboardId: number; permissions?: any; isFolder: boolean; backendSrv: any; } -@inject('permissions') @observer class Permissions extends Component { - // TODO Remove Inner from Name when we get access via ReactContainer dashboardId: any; meta: any; items: DashboardAcl[]; @@ -51,8 +48,6 @@ class Permissions extends Component { error: string; refreshList: any; - readonly duplicateError = 'This permission exists already.'; - constructor(props) { super(props); const { dashboardId, permissions, isFolder } = this.props; @@ -69,10 +64,6 @@ class Permissions extends Component { }; } - componentWillReceiveProps(nextProps) { - console.log('nextProps', nextProps); - } - permissionChanged(index: number, permission: number, permissionName: string) { const { permissions } = this.props; permissions.updatePermissionOnIndex(index, permission, permissionName); @@ -127,7 +118,7 @@ class Permissions extends Component { render() { console.log('Permissions render'); - const { error, permissions, backendSrv } = this.props; + const { permissions, backendSrv } = this.props; const { newType } = this.state; return ( @@ -154,25 +145,11 @@ class Permissions extends Component { ); })} - - {/*