Commit e73479ef by Marcus Efraimsson

folders: fix permissions in folder picker component

Only enable creating new folders from folder picker if user has org roles
admin or editor.
Only render General option in folder picker if user has org roles admin
or editor.
parent b4863002
...@@ -19,9 +19,12 @@ export class FolderPickerCtrl { ...@@ -19,9 +19,12 @@ export class FolderPickerCtrl {
newFolderNameTouched: boolean; newFolderNameTouched: boolean;
hasValidationError: boolean; hasValidationError: boolean;
validationError: any; validationError: any;
isEditor: boolean;
/** @ngInject */ /** @ngInject */
constructor(private backendSrv, private validationSrv) { constructor(private backendSrv, private validationSrv, private contextSrv) {
this.isEditor = this.contextSrv.isEditor;
if (!this.labelClass) { if (!this.labelClass) {
this.labelClass = 'width-7'; this.labelClass = 'width-7';
} }
...@@ -38,19 +41,20 @@ export class FolderPickerCtrl { ...@@ -38,19 +41,20 @@ export class FolderPickerCtrl {
return this.backendSrv.get('api/search', params).then(result => { return this.backendSrv.get('api/search', params).then(result => {
if ( if (
query === '' || this.isEditor &&
query.toLowerCase() === 'g' || (query === '' ||
query.toLowerCase() === 'ge' || query.toLowerCase() === 'g' ||
query.toLowerCase() === 'gen' || query.toLowerCase() === 'ge' ||
query.toLowerCase() === 'gene' || query.toLowerCase() === 'gen' ||
query.toLowerCase() === 'gener' || query.toLowerCase() === 'gene' ||
query.toLowerCase() === 'genera' || query.toLowerCase() === 'gener' ||
query.toLowerCase() === 'general' query.toLowerCase() === 'genera' ||
query.toLowerCase() === 'general')
) { ) {
result.unshift({ title: this.rootName, id: 0 }); result.unshift({ title: this.rootName, id: 0 });
} }
if (this.enableCreateNew && query === '') { if (this.isEditor && this.enableCreateNew && query === '') {
result.unshift({ title: '-- New Folder --', id: -1 }); result.unshift({ title: '-- New Folder --', id: -1 });
} }
......
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