mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Provisioning: Do not allow deletion of provisioned dashboards (#16211)
* Unprovision dashboard in case of DisableDeletion = true * Rename command struct * Handle removed provision files * Allow html in confirm-modal * Do not show confirm button without onConfirm * Show dialog on deleting provisioned dashboard * Changed DeleteDashboard to DeleteProvisionedDashboard * Remove unreachable return * Add provisioned checks to API * Remove filter func * Fix and add tests for deleting dashboards * Change delete confirm text * Added and used pkg/errors for error wrapping
This commit is contained in:
@@ -52,11 +52,6 @@ export class UtilSrv {
|
||||
showConfirmModal(payload) {
|
||||
const scope = this.$rootScope.$new();
|
||||
|
||||
scope.onConfirm = () => {
|
||||
payload.onConfirm();
|
||||
scope.dismiss();
|
||||
};
|
||||
|
||||
scope.updateConfirmText = value => {
|
||||
scope.confirmTextValid = payload.confirmText.toLowerCase() === value.toLowerCase();
|
||||
};
|
||||
@@ -64,6 +59,7 @@ export class UtilSrv {
|
||||
scope.title = payload.title;
|
||||
scope.text = payload.text;
|
||||
scope.text2 = payload.text2;
|
||||
scope.text2htmlBind = payload.text2htmlBind;
|
||||
scope.confirmText = payload.confirmText;
|
||||
|
||||
scope.onConfirm = payload.onConfirm;
|
||||
|
||||
@@ -182,6 +182,24 @@ export class SettingsCtrl {
|
||||
let confirmText = '';
|
||||
let text2 = this.dashboard.title;
|
||||
|
||||
if (this.dashboard.meta.provisioned) {
|
||||
appEvents.emit('confirm-modal', {
|
||||
title: 'Cannot delete provisioned dashboard',
|
||||
text: `
|
||||
This dashboard is managed by Grafanas provisioning and cannot be deleted. Remove the dashboard from the
|
||||
config file to delete it.
|
||||
`,
|
||||
text2: `
|
||||
<i>See <a class="external-link" href="http://docs.grafana.org/administration/provisioning/#dashboards" target="_blank">
|
||||
documentation</a> for more information about provisioning.</i>
|
||||
`,
|
||||
text2htmlBind: true,
|
||||
icon: 'fa-trash',
|
||||
noText: 'OK',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const alerts = _.sumBy(this.dashboard.panels, panel => {
|
||||
return panel.alert ? 1 : 0;
|
||||
});
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
<div class="confirm-modal-text">
|
||||
{{text}}
|
||||
<div class="confirm-modal-text2" ng-show="text2">
|
||||
{{text2}}
|
||||
</div>
|
||||
<div ng-if="text2 && text2htmlBind" class="confirm-modal-text2" ng-bind-html="text2"></div>
|
||||
<div ng-if="text2 && !text2htmlBind" class="confirm-modal-text2">{{text2}}</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-content-confirm-text" ng-if="confirmText">
|
||||
@@ -27,7 +26,7 @@
|
||||
|
||||
<div class="confirm-modal-buttons">
|
||||
<button ng-show="onAltAction" type="button" class="btn btn-primary" ng-click="dismiss();onAltAction();">{{altActionText}}</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="onConfirm();dismiss();" ng-disabled="!confirmTextValid" give-focus="true">{{yesText}}</button>
|
||||
<button ng-show="onConfirm" type="button" class="btn btn-danger" ng-click="onConfirm();dismiss();" ng-disabled="!confirmTextValid" give-focus="true">{{yesText}}</button>
|
||||
<button type="button" class="btn btn-inverse" ng-click="dismiss()">{{noText}}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user