Commit 55100d5f by Marcus Efraimsson Committed by GitHub

Merge pull request #10760 from grafana/10749_link_to_folder

Fix link to folder from permissions list
parents 6def21e8 7d3b990e
...@@ -99,7 +99,7 @@ func GetDashboard(c *middleware.Context) Response { ...@@ -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 { ...@@ -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> { ...@@ -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() { ...@@ -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'; ...@@ -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> { ...@@ -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> { ...@@ -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>
......
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 ...@@ -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 @@ ...@@ -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 { ...@@ -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() {
......
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