mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(ui): add confirmation to delete actions [EE-4612] (#10003)
This commit is contained in:
parent
6fde4195f8
commit
cfe0d3092d
4 changed files with 43 additions and 24 deletions
|
@ -1,6 +1,7 @@
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
||||||
import { confirmImageExport } from '@/react/docker/images/common/ConfirmExportModal';
|
import { confirmImageExport } from '@/react/docker/images/common/ConfirmExportModal';
|
||||||
|
import { confirmDelete } from '@@/modals/confirm';
|
||||||
|
|
||||||
angular.module('portainer.docker').controller('ImageController', [
|
angular.module('portainer.docker').controller('ImageController', [
|
||||||
'$async',
|
'$async',
|
||||||
|
@ -120,30 +121,42 @@ angular.module('portainer.docker').controller('ImageController', [
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.removeTag = function (repository) {
|
$scope.removeTag = function (repository) {
|
||||||
ImageService.deleteImage(repository, false)
|
return $async(async () => {
|
||||||
.then(function success() {
|
if (!(await confirmDelete('Are you sure you want to delete this tag?'))) {
|
||||||
if ($scope.image.RepoTags.length === 1) {
|
return;
|
||||||
Notifications.success('Image successfully deleted', repository);
|
}
|
||||||
$state.go('docker.images', {}, { reload: true });
|
|
||||||
} else {
|
ImageService.deleteImage(repository, false)
|
||||||
Notifications.success('Tag successfully deleted', repository);
|
.then(function success() {
|
||||||
$state.go('docker.images.image', { id: $transition$.params().id }, { reload: true });
|
if ($scope.image.RepoTags.length === 1) {
|
||||||
}
|
Notifications.success('Image successfully deleted', repository);
|
||||||
})
|
$state.go('docker.images', {}, { reload: true });
|
||||||
.catch(function error(err) {
|
} else {
|
||||||
Notifications.error('Failure', err, 'Unable to remove image');
|
Notifications.success('Tag successfully deleted', repository);
|
||||||
});
|
$state.go('docker.images.image', { id: $transition$.params().id }, { reload: true });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function error(err) {
|
||||||
|
Notifications.error('Failure', err, 'Unable to remove image');
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeImage = function (id) {
|
$scope.removeImage = function (id) {
|
||||||
ImageService.deleteImage(id, false)
|
return $async(async () => {
|
||||||
.then(function success() {
|
if (!(await confirmDelete('Deleting this image will also delete all associated tags. Are you sure you want to delete this image?'))) {
|
||||||
Notifications.success('Image successfully deleted', id);
|
return;
|
||||||
$state.go('docker.images', {}, { reload: true });
|
}
|
||||||
})
|
|
||||||
.catch(function error(err) {
|
ImageService.deleteImage(id, false)
|
||||||
Notifications.error('Failure', err, 'Unable to remove image');
|
.then(function success() {
|
||||||
});
|
Notifications.success('Image successfully deleted', id);
|
||||||
|
$state.go('docker.images', {}, { reload: true });
|
||||||
|
})
|
||||||
|
.catch(function error(err) {
|
||||||
|
Notifications.error('Failure', err, 'Unable to remove image');
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function exportImage(image) {
|
function exportImage(image) {
|
||||||
|
|
|
@ -57,7 +57,8 @@ angular.module('portainer.docker').controller('ImagesController', [
|
||||||
function confirmImageForceRemoval() {
|
function confirmImageForceRemoval() {
|
||||||
return confirmDestructive({
|
return confirmDestructive({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
message: 'Forcing the removal of the image will remove the image even if it has multiple tags or if it is used by stopped containers.',
|
message:
|
||||||
|
"Forcing removal of an image will remove it even if it's used by stopped containers, and delete all associated tags. Are you sure you want to remove the selected image(s)?",
|
||||||
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,7 @@ angular.module('portainer.docker').controller('ImagesController', [
|
||||||
function confirmRegularRemove() {
|
function confirmRegularRemove() {
|
||||||
return confirmDestructive({
|
return confirmDestructive({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
message: 'Removing the image will remove all tags associated to that image. Are you sure you want to remove the image?',
|
message: 'Removing an image will also delete all associated tags. Are you sure you want to remove the selected image(s)?',
|
||||||
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
|
import { confirmDelete } from '@@/modals/confirm';
|
||||||
|
|
||||||
export class EdgeGroupsController {
|
export class EdgeGroupsController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
|
@ -26,6 +27,10 @@ export class EdgeGroupsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeActionAsync(selectedItems) {
|
async removeActionAsync(selectedItems) {
|
||||||
|
if (!(await confirmDelete('Do you want to remove the selected Edge Group(s)?'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (let item of selectedItems) {
|
for (let item of selectedItems) {
|
||||||
try {
|
try {
|
||||||
await this.EdgeGroupService.remove(item.Id);
|
await this.EdgeGroupService.remove(item.Id);
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class EdgeJobsViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAction(selectedItems) {
|
removeAction(selectedItems) {
|
||||||
confirmDelete('Do you want to remove the selected edge job(s)?').then((confirmed) => {
|
confirmDelete('Do you want to remove the selected Edge job(s)?').then((confirmed) => {
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue