mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
More work on editable false dashboards, #1834
This commit is contained in:
parent
af277f560f
commit
16fc6e8b42
@ -119,6 +119,8 @@ function (angular, _) {
|
||||
$scope.saveDashboardAs = function() {
|
||||
var newScope = $rootScope.$new();
|
||||
newScope.clone = $scope.dashboard.getSaveModelClone();
|
||||
newScope.clone.editable = true;
|
||||
newScope.clone.hideControls = false;
|
||||
|
||||
$scope.appEvent('show-modal', {
|
||||
src: './app/features/dashboard/partials/saveDashboardAs.html',
|
||||
|
@ -66,6 +66,8 @@ function (angular, $, kbn, _, moment) {
|
||||
if (!this.editable) {
|
||||
meta.canEdit = false;
|
||||
meta.canDelete = false;
|
||||
meta.canSave = false;
|
||||
this.hideControls = true;
|
||||
}
|
||||
|
||||
this.meta = meta;
|
||||
|
@ -27,7 +27,7 @@
|
||||
<li ng-show="dashboardMeta.canShare">
|
||||
<a class="pointer" ng-click="shareDashboard()" bs-tooltip="'Share dashboard'" data-placement="bottom"><i class="fa fa-share-square-o"></i></a>
|
||||
</li>
|
||||
<li ng-show="dashboardMeta.canEdit">
|
||||
<li ng-show="dashboardMeta.canSave">
|
||||
<a ng-click="saveDashboard()" bs-tooltip="'Save dashboard'" data-placement="bottom"><i class="fa fa-save"></i></a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
@ -38,7 +38,7 @@
|
||||
<li ng-if="dashboardMeta.canEdit"><a class="pointer" ng-click="openEditView('templating');">Templating</a></li>
|
||||
<li><a class="pointer" ng-click="exportDashboard();">Export</a></li>
|
||||
<li><a class="pointer" ng-click="editJson();">View JSON</a></li>
|
||||
<li ng-if="dashboardMeta.canSave"><a class="pointer" ng-click="saveDashboardAs();">Save As...</a></li>
|
||||
<li ng-if="contextSrv.isEditor"><a class="pointer" ng-click="saveDashboardAs();">Save As...</a></li>
|
||||
<li ng-if="dashboardMeta.canDelete"><a class="pointer" ng-click="deleteDashboard();">Delete dashboard</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -59,12 +59,15 @@ function (angular, _, kbn, moment, $) {
|
||||
$location.path('');
|
||||
return;
|
||||
}
|
||||
$scope.initDashboard({meta: {}, model: window.grafanaImportDashboard }, $scope);
|
||||
$scope.initDashboard({
|
||||
meta: { canShare: false, canStar: false },
|
||||
model: window.grafanaImportDashboard
|
||||
}, $scope);
|
||||
});
|
||||
|
||||
module.controller('NewDashboardCtrl', function($scope) {
|
||||
$scope.initDashboard({
|
||||
meta: {},
|
||||
meta: { canStar: false, canShare: false },
|
||||
model: {
|
||||
title: "New dashboard",
|
||||
rows: [{ height: '250px', panels:[] }]
|
||||
@ -93,7 +96,10 @@ function (angular, _, kbn, moment, $) {
|
||||
};
|
||||
|
||||
file_load($routeParams.jsonFile).then(function(result) {
|
||||
$scope.initDashboard({meta: {fromFile: true}, model: result}, $scope);
|
||||
$scope.initDashboard({
|
||||
meta: { canSave: false, canDelete: false },
|
||||
model: result
|
||||
}, $scope);
|
||||
});
|
||||
|
||||
});
|
||||
@ -138,7 +144,10 @@ function (angular, _, kbn, moment, $) {
|
||||
};
|
||||
|
||||
script_load($routeParams.jsFile).then(function(result) {
|
||||
$scope.initDashboard({meta: {fromScript: true, canDelete: false}, model: result.data}, $scope);
|
||||
$scope.initDashboard({
|
||||
meta: {fromScript: true, canDelete: false, canSave: false},
|
||||
model: result.data
|
||||
}, $scope);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -18,13 +18,6 @@ function (angular, _, store, config) {
|
||||
}
|
||||
}
|
||||
|
||||
this.version = config.buildInfo.version;
|
||||
this.lightTheme = false;
|
||||
this.user = new User();
|
||||
this.isSignedIn = this.user.isSignedIn;
|
||||
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
|
||||
this.sidemenu = store.getBool('grafana.sidemenu');
|
||||
|
||||
// events
|
||||
$rootScope.$on('toggle-sidemenu', function() {
|
||||
self.toggleSideMenu();
|
||||
@ -47,6 +40,12 @@ function (angular, _, store, config) {
|
||||
}, 50);
|
||||
};
|
||||
|
||||
this.version = config.buildInfo.version;
|
||||
this.lightTheme = false;
|
||||
this.user = new User();
|
||||
this.isSignedIn = this.user.isSignedIn;
|
||||
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
|
||||
this.sidemenu = store.getBool('grafana.sidemenu');
|
||||
this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -185,10 +185,26 @@ define([
|
||||
expect(model.annotations.list.length).to.be(0);
|
||||
expect(model.templating.list.length).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Given editable false dashboard', function() {
|
||||
var model;
|
||||
|
||||
beforeEach(function() {
|
||||
model = _dashboardSrv.create({
|
||||
editable: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should set meta canEdit and canSave to false', function() {
|
||||
expect(model.meta.canSave).to.be(false);
|
||||
expect(model.meta.canEdit).to.be(false);
|
||||
});
|
||||
|
||||
it('getSaveModelClone should remove meta', function() {
|
||||
var clone = model.getSaveModelClone();
|
||||
expect(clone.meta).to.be(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user