Просмотр исходного кода

new dashboard is now hidden from viewer, fixes #10815 (#10854)

* new dashboard is now hidden from viewer, fixes #10815

* changed orgRole to isEditor

* removed unused import

* added contextSrv mock to search.jest
Patrick O'Carroll 7 лет назад
Родитель
Сommit
aaf4e760c6

+ 1 - 1
public/app/core/components/search/search.html

@@ -43,7 +43,7 @@
         </tag-filter>
         </tag-filter>
       </div>
       </div>
 
 
-      <div class="search-filter-box">
+      <div class="search-filter-box" ng-if="ctrl.isEditor">
         <a href="dashboard/new" class="search-filter-box-link">
         <a href="dashboard/new" class="search-filter-box-link">
           <i class="gicon gicon-dashboard-new"></i> New dashboard
           <i class="gicon gicon-dashboard-new"></i> New dashboard
         </a>
         </a>

+ 3 - 0
public/app/core/components/search/search.ts

@@ -1,6 +1,7 @@
 import _ from 'lodash';
 import _ from 'lodash';
 import coreModule from '../../core_module';
 import coreModule from '../../core_module';
 import { SearchSrv } from 'app/core/services/search_srv';
 import { SearchSrv } from 'app/core/services/search_srv';
+import { contextSrv } from 'app/core/services/context_srv';
 import appEvents from 'app/core/app_events';
 import appEvents from 'app/core/app_events';
 
 
 export class SearchCtrl {
 export class SearchCtrl {
@@ -15,6 +16,7 @@ export class SearchCtrl {
   ignoreClose: any;
   ignoreClose: any;
   isLoading: boolean;
   isLoading: boolean;
   initialFolderFilterTitle: string;
   initialFolderFilterTitle: string;
+  isEditor: string;
 
 
   /** @ngInject */
   /** @ngInject */
   constructor($scope, private $location, private $timeout, private searchSrv: SearchSrv) {
   constructor($scope, private $location, private $timeout, private searchSrv: SearchSrv) {
@@ -24,6 +26,7 @@ export class SearchCtrl {
     this.initialFolderFilterTitle = 'All';
     this.initialFolderFilterTitle = 'All';
     this.getTags = this.getTags.bind(this);
     this.getTags = this.getTags.bind(this);
     this.onTagSelect = this.onTagSelect.bind(this);
     this.onTagSelect = this.onTagSelect.bind(this);
+    this.isEditor = contextSrv.isEditor;
   }
   }
 
 
   closeSearch() {
   closeSearch() {

+ 6 - 0
public/app/core/specs/search.jest.ts

@@ -1,6 +1,12 @@
 import { SearchCtrl } from '../components/search/search';
 import { SearchCtrl } from '../components/search/search';
 import { SearchSrv } from '../services/search_srv';
 import { SearchSrv } from '../services/search_srv';
 
 
+jest.mock('app/core/services/context_srv', () => ({
+  contextSrv: {
+    user: { orgId: 1 },
+  },
+}));
+
 describe('SearchCtrl', () => {
 describe('SearchCtrl', () => {
   const searchSrvStub = {
   const searchSrvStub = {
     search: (options: any) => {},
     search: (options: any) => {},