fix(docker): comfirm modal for removing secrets/networks/configs [EE-4211] (#7882)

* fix(ui): comfirm modal for removing secrets/networks/configs [EE-4211]

* fix(ui): comfirm modal for removing secrets/networks/configs [EE-4211]

* fix(ui): comfirm modal for removing secrets/networks/configs [EE-4211]
pull/7917/head
Hao 2022-10-21 16:03:41 +08:00 committed by GitHub
parent 7624ff10ee
commit 0365ed8e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import angular from 'angular'; import angular from 'angular';
import { confirmDeletionAsync } from 'Portainer/services/modal.service/confirm';
class ConfigsController { class ConfigsController {
/* @ngInject */ /* @ngInject */
@ -31,7 +32,11 @@ class ConfigsController {
this.getConfigs(); this.getConfigs();
} }
removeAction(selectedItems) { async removeAction(selectedItems) {
const confirmed = await confirmDeletionAsync('Do you want to remove the selected config(s)?');
if (!confirmed) {
return null;
}
return this.$async(this.removeActionAsync, selectedItems); return this.$async(this.removeActionAsync, selectedItems);
} }

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
import DockerNetworkHelper from 'Docker/helpers/networkHelper'; import DockerNetworkHelper from 'Docker/helpers/networkHelper';
import { isOfflineEndpoint } from '@/portainer/helpers/endpointHelper'; import { isOfflineEndpoint } from '@/portainer/helpers/endpointHelper';
import { confirmDeletionAsync } from 'Portainer/services/modal.service/confirm';
angular.module('portainer.docker').controller('NetworksController', [ angular.module('portainer.docker').controller('NetworksController', [
'$q', '$q',
@ -12,7 +13,11 @@ angular.module('portainer.docker').controller('NetworksController', [
'endpoint', 'endpoint',
'AgentService', 'AgentService',
function ($q, $scope, $state, NetworkService, Notifications, HttpRequestHelper, endpoint, AgentService) { function ($q, $scope, $state, NetworkService, Notifications, HttpRequestHelper, endpoint, AgentService) {
$scope.removeAction = function (selectedItems) { $scope.removeAction = async function (selectedItems) {
const confirmed = await confirmDeletionAsync('Do you want to remove the selected network(s)?');
if (!confirmed) {
return null;
}
var actionCount = selectedItems.length; var actionCount = selectedItems.length;
angular.forEach(selectedItems, function (network) { angular.forEach(selectedItems, function (network) {
HttpRequestHelper.setPortainerAgentTargetHeader(network.NodeName); HttpRequestHelper.setPortainerAgentTargetHeader(network.NodeName);

View File

@ -1,10 +1,15 @@
import { confirmDeletionAsync } from 'Portainer/services/modal.service/confirm';
angular.module('portainer.docker').controller('SecretsController', [ angular.module('portainer.docker').controller('SecretsController', [
'$scope', '$scope',
'$state', '$state',
'SecretService', 'SecretService',
'Notifications', 'Notifications',
function ($scope, $state, SecretService, Notifications) { function ($scope, $state, SecretService, Notifications) {
$scope.removeAction = function (selectedItems) { $scope.removeAction = async function (selectedItems) {
const confirmed = await confirmDeletionAsync('Do you want to remove the selected secret(s)?');
if (!confirmed) {
return null;
}
var actionCount = selectedItems.length; var actionCount = selectedItems.length;
angular.forEach(selectedItems, function (secret) { angular.forEach(selectedItems, function (secret) {
SecretService.remove(secret.Id) SecretService.remove(secret.Id)