mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
permissions: fix link to folder from permissions list
Also, closing Add Permissions CTA when DashboardPermissions and FolderPermissions unmounts. Fixes #10749"
This commit is contained in:
parent
e1de4794ec
commit
7d3b990e91
@ -99,7 +99,7 @@ func GetDashboard(c *middleware.Context) Response {
|
|||||||
return ApiError(500, "Dashboard folder could not be read", err)
|
return ApiError(500, "Dashboard folder could not be read", err)
|
||||||
}
|
}
|
||||||
meta.FolderTitle = query.Result.Title
|
meta.FolderTitle = query.Result.Title
|
||||||
meta.FolderSlug = query.Result.Slug
|
meta.FolderUrl = query.Result.GetUrl()
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure db version is in sync with json model version
|
// make sure db version is in sync with json model version
|
||||||
|
@ -27,7 +27,7 @@ type DashboardMeta struct {
|
|||||||
IsFolder bool `json:"isFolder"`
|
IsFolder bool `json:"isFolder"`
|
||||||
FolderId int64 `json:"folderId"`
|
FolderId int64 `json:"folderId"`
|
||||||
FolderTitle string `json:"folderTitle"`
|
FolderTitle string `json:"folderTitle"`
|
||||||
FolderSlug string `json:"folderSlug"`
|
FolderUrl string `json:"folderUrl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardFullWithMeta struct {
|
type DashboardFullWithMeta struct {
|
||||||
|
@ -17,6 +17,11 @@ export class FolderPermissions extends Component<IContainerProps, any> {
|
|||||||
this.loadStore();
|
this.loadStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
const { permissions } = this.props;
|
||||||
|
permissions.hideAddPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
loadStore() {
|
loadStore() {
|
||||||
const { nav, folder, view } = this.props;
|
const { nav, folder, view } = this.props;
|
||||||
return folder.load(view.routeParams.get('uid') as string).then(res => {
|
return folder.load(view.routeParams.get('uid') as string).then(res => {
|
||||||
|
@ -20,11 +20,5 @@ export function registerAngularDirectives() {
|
|||||||
['tagOptions', { watchDepth: 'reference' }],
|
['tagOptions', { watchDepth: 'reference' }],
|
||||||
]);
|
]);
|
||||||
react2AngularDirective('selectUserPicker', UserPicker, ['backendSrv', 'handlePicked']);
|
react2AngularDirective('selectUserPicker', UserPicker, ['backendSrv', 'handlePicked']);
|
||||||
react2AngularDirective('dashboardPermissions', DashboardPermissions, [
|
react2AngularDirective('dashboardPermissions', DashboardPermissions, ['backendSrv', 'dashboardId', 'folder']);
|
||||||
'backendSrv',
|
|
||||||
'dashboardId',
|
|
||||||
'folderTitle',
|
|
||||||
'folderSlug',
|
|
||||||
'folderId',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,11 @@ import Tooltip from 'app/core/components/Tooltip/Tooltip';
|
|||||||
import PermissionsInfo from 'app/core/components/Permissions/PermissionsInfo';
|
import PermissionsInfo from 'app/core/components/Permissions/PermissionsInfo';
|
||||||
import AddPermissions from 'app/core/components/Permissions/AddPermissions';
|
import AddPermissions from 'app/core/components/Permissions/AddPermissions';
|
||||||
import SlideDown from 'app/core/components/Animations/SlideDown';
|
import SlideDown from 'app/core/components/Animations/SlideDown';
|
||||||
|
import { FolderInfo } from './FolderInfo';
|
||||||
|
|
||||||
export interface IProps {
|
export interface IProps {
|
||||||
dashboardId: number;
|
dashboardId: number;
|
||||||
folderId: number;
|
folder?: FolderInfo;
|
||||||
folderTitle: string;
|
|
||||||
folderSlug: string;
|
|
||||||
backendSrv: any;
|
backendSrv: any;
|
||||||
}
|
}
|
||||||
@observer
|
@observer
|
||||||
@ -28,8 +27,12 @@ class DashboardPermissions extends Component<IProps, any> {
|
|||||||
this.permissions.toggleAddPermissions();
|
this.permissions.toggleAddPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.permissions.hideAddPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { dashboardId, folderTitle, folderSlug, folderId, backendSrv } = this.props;
|
const { dashboardId, folder, backendSrv } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -56,7 +59,7 @@ class DashboardPermissions extends Component<IProps, any> {
|
|||||||
permissions={this.permissions}
|
permissions={this.permissions}
|
||||||
isFolder={false}
|
isFolder={false}
|
||||||
dashboardId={dashboardId}
|
dashboardId={dashboardId}
|
||||||
folderInfo={{ title: folderTitle, slug: folderSlug, id: folderId }}
|
folderInfo={folder}
|
||||||
backendSrv={backendSrv}
|
backendSrv={backendSrv}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export interface FolderInfo {
|
export interface FolderInfo {
|
||||||
title: string;
|
|
||||||
id: number;
|
id: number;
|
||||||
slug: string;
|
title: string;
|
||||||
|
url: string;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export default observer(({ item, removeItem, permissionChanged, itemIndex, folde
|
|||||||
folderInfo && (
|
folderInfo && (
|
||||||
<em className="muted no-wrap">
|
<em className="muted no-wrap">
|
||||||
Inherited from folder{' '}
|
Inherited from folder{' '}
|
||||||
<a className="text-link" href={`dashboards/folder/${folderInfo.id}/${folderInfo.slug}/permissions`}>
|
<a className="text-link" href={`${folderInfo.url}/permissions`}>
|
||||||
{folderInfo.title}
|
{folderInfo.title}
|
||||||
</a>{' '}
|
</a>{' '}
|
||||||
</em>
|
</em>
|
||||||
|
@ -99,9 +99,7 @@
|
|||||||
<dashboard-permissions ng-if="ctrl.dashboard"
|
<dashboard-permissions ng-if="ctrl.dashboard"
|
||||||
dashboardId="ctrl.dashboard.id"
|
dashboardId="ctrl.dashboard.id"
|
||||||
backendSrv="ctrl.backendSrv"
|
backendSrv="ctrl.backendSrv"
|
||||||
folderTitle="ctrl.dashboard.meta.folderTitle"
|
folder="ctrl.getFolder()"
|
||||||
folderSlug="ctrl.dashboard.meta.folderSlug"
|
|
||||||
folderId="ctrl.dashboard.meta.folderId"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -197,6 +197,14 @@ export class SettingsCtrl {
|
|||||||
this.dashboard.meta.folderTitle = folder.title;
|
this.dashboard.meta.folderTitle = folder.title;
|
||||||
this.dashboard.meta.folderSlug = folder.slug;
|
this.dashboard.meta.folderSlug = folder.slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFolder() {
|
||||||
|
return {
|
||||||
|
id: this.dashboard.meta.folderId,
|
||||||
|
title: this.dashboard.meta.folderTitle,
|
||||||
|
url: this.dashboard.meta.folderUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dashboardSettings() {
|
export function dashboardSettings() {
|
||||||
|
Loading…
Reference in New Issue
Block a user