mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
fix: fixed permission list caching issue, fixes #10750
This commit is contained in:
parent
2d1bd270fb
commit
e6b82b2fb1
@ -1,4 +1,4 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component } from 'react';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { toJS } from 'mobx';
|
||||
import IContainerProps from 'app/containers/IContainerProps';
|
||||
@ -8,6 +8,7 @@ import Tooltip from 'app/core/components/Tooltip/Tooltip';
|
||||
import PermissionsInfo from 'app/core/components/Permissions/PermissionsInfo';
|
||||
import AddPermissions from 'app/core/components/Permissions/AddPermissions';
|
||||
import SlideDown from 'app/core/components/Animations/SlideDown';
|
||||
|
||||
@inject('nav', 'folder', 'view', 'permissions')
|
||||
@observer
|
||||
export class FolderPermissions extends Component<IContainerProps, any> {
|
||||
|
@ -14,6 +14,7 @@ describe('FolderSettings', () => {
|
||||
dashboard: {
|
||||
id: 1,
|
||||
title: 'Folder Name',
|
||||
uid: 'uid-str',
|
||||
},
|
||||
meta: {
|
||||
url: '/dashboards/f/uid/folder-name',
|
||||
@ -23,19 +24,27 @@ describe('FolderSettings', () => {
|
||||
);
|
||||
|
||||
const store = RootStore.create(
|
||||
{},
|
||||
{
|
||||
view: {
|
||||
path: 'asd',
|
||||
query: {},
|
||||
routeParams: {
|
||||
uid: 'uid-str',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
backendSrv: backendSrv,
|
||||
}
|
||||
);
|
||||
|
||||
wrapper = shallow(<FolderSettings backendSrv={backendSrv} {...store} />);
|
||||
return wrapper
|
||||
.dive()
|
||||
page = wrapper.dive();
|
||||
return page
|
||||
.instance()
|
||||
.loadStore()
|
||||
.then(() => {
|
||||
page = wrapper.dive();
|
||||
page.update();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -5,6 +5,7 @@ export const Folder = types.model('Folder', {
|
||||
title: types.string,
|
||||
url: types.string,
|
||||
canSave: types.boolean,
|
||||
uid: types.string,
|
||||
hasChanged: types.boolean,
|
||||
});
|
||||
|
||||
@ -14,15 +15,23 @@ export const FolderStore = types
|
||||
})
|
||||
.actions(self => ({
|
||||
load: flow(function* load(uid: string) {
|
||||
// clear folder state
|
||||
if (self.folder && self.folder.uid !== uid) {
|
||||
self.folder = null;
|
||||
}
|
||||
|
||||
const backendSrv = getEnv(self).backendSrv;
|
||||
const res = yield backendSrv.getDashboardByUid(uid);
|
||||
|
||||
self.folder = Folder.create({
|
||||
id: res.dashboard.id,
|
||||
title: res.dashboard.title,
|
||||
url: res.meta.url,
|
||||
uid: res.dashboard.uid,
|
||||
canSave: res.meta.canSave,
|
||||
hasChanged: false,
|
||||
});
|
||||
|
||||
return res;
|
||||
}),
|
||||
|
||||
|
@ -115,6 +115,7 @@ export const PermissionsStore = types
|
||||
self.fetching = false;
|
||||
self.error = null;
|
||||
}),
|
||||
|
||||
addStoreItem: flow(function* addStoreItem() {
|
||||
self.error = null;
|
||||
let item = {
|
||||
@ -152,11 +153,13 @@ export const PermissionsStore = types
|
||||
resetNewType();
|
||||
return updateItems(self);
|
||||
}),
|
||||
|
||||
removeStoreItem: flow(function* removeStoreItem(idx: number) {
|
||||
self.error = null;
|
||||
self.items.splice(idx, 1);
|
||||
return updateItems(self);
|
||||
}),
|
||||
|
||||
updatePermissionOnIndex: flow(function* updatePermissionOnIndex(
|
||||
idx: number,
|
||||
permission: number,
|
||||
@ -166,18 +169,19 @@ export const PermissionsStore = types
|
||||
self.items[idx].updatePermission(permission, permissionName);
|
||||
return updateItems(self);
|
||||
}),
|
||||
|
||||
setNewType(newType: string) {
|
||||
self.newItem = NewPermissionsItem.create({ type: newType });
|
||||
},
|
||||
|
||||
resetNewType() {
|
||||
resetNewType();
|
||||
},
|
||||
|
||||
toggleAddPermissions() {
|
||||
self.isAddPermissionsVisible = !self.isAddPermissionsVisible;
|
||||
},
|
||||
showAddPermissions() {
|
||||
self.isAddPermissionsVisible = true;
|
||||
},
|
||||
|
||||
hideAddPermissions() {
|
||||
self.isAddPermissionsVisible = false;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user