mirror of https://github.com/portainer/portainer
fix(ui): confirm deletion [EE-4612] (#8868)
parent
e37e87971d
commit
f96e7ff434
|
@ -54,8 +54,8 @@
|
||||||
order-by="RepoTags"
|
order-by="RepoTags"
|
||||||
show-host-column="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'"
|
show-host-column="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'"
|
||||||
download-action="downloadAction"
|
download-action="downloadAction"
|
||||||
remove-action="removeAction"
|
remove-action="confirmRemove"
|
||||||
force-remove-action="confirmRemovalAction"
|
force-remove-action="confirmForceRemove"
|
||||||
export-in-progress="state.exportInProgress"
|
export-in-progress="state.exportInProgress"
|
||||||
refresh-callback="getImages"
|
refresh-callback="getImages"
|
||||||
></images-datatable>
|
></images-datatable>
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
||||||
import { ModalType } from '@@/modals';
|
|
||||||
import { confirmImageExport } from '@/react/docker/images/common/ConfirmExportModal';
|
import { confirmImageExport } from '@/react/docker/images/common/ConfirmExportModal';
|
||||||
import { confirm } from '@@/modals/confirm';
|
import { confirmDestructive } from '@@/modals/confirm';
|
||||||
import { buildConfirmButton } from '@@/modals/utils';
|
import { buildConfirmButton } from '@@/modals/utils';
|
||||||
|
|
||||||
angular.module('portainer.docker').controller('ImagesController', [
|
angular.module('portainer.docker').controller('ImagesController', [
|
||||||
|
@ -15,7 +14,8 @@ angular.module('portainer.docker').controller('ImagesController', [
|
||||||
'FileSaver',
|
'FileSaver',
|
||||||
'Blob',
|
'Blob',
|
||||||
'endpoint',
|
'endpoint',
|
||||||
function ($scope, $state, Authentication, ImageService, Notifications, HttpRequestHelper, FileSaver, Blob, endpoint) {
|
'$async',
|
||||||
|
function ($scope, $state, Authentication, ImageService, Notifications, HttpRequestHelper, FileSaver, Blob, endpoint, $async) {
|
||||||
$scope.endpoint = endpoint;
|
$scope.endpoint = endpoint;
|
||||||
$scope.isAdmin = Authentication.isAdmin();
|
$scope.isAdmin = Authentication.isAdmin();
|
||||||
|
|
||||||
|
@ -54,14 +54,39 @@ angular.module('portainer.docker').controller('ImagesController', [
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.confirmRemovalAction = function (selectedItems, force) {
|
$scope.confirmForceRemove = confirmForceRemove;
|
||||||
confirmImageForceRemoval().then((confirmed) => {
|
function confirmForceRemove(selectedItems, force) {
|
||||||
|
return $async(async () => {
|
||||||
|
const confirmed = await confirmDestructive({
|
||||||
|
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.',
|
||||||
|
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
||||||
|
});
|
||||||
|
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.removeAction(selectedItems, force);
|
$scope.removeAction(selectedItems, force);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
$scope.confirmRemove = confirmRemove;
|
||||||
|
function confirmRemove(selectedItems) {
|
||||||
|
return $async(async () => {
|
||||||
|
const confirmed = await confirmDestructive({
|
||||||
|
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?',
|
||||||
|
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.removeAction(selectedItems, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function isAuthorizedToDownload(selectedItems) {
|
function isAuthorizedToDownload(selectedItems) {
|
||||||
for (var i = 0; i < selectedItems.length; i++) {
|
for (var i = 0; i < selectedItems.length; i++) {
|
||||||
|
@ -161,12 +186,3 @@ angular.module('portainer.docker').controller('ImagesController', [
|
||||||
initView();
|
initView();
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function confirmImageForceRemoval() {
|
|
||||||
return confirm({
|
|
||||||
title: 'Are you sure?',
|
|
||||||
modalType: ModalType.Destructive,
|
|
||||||
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.',
|
|
||||||
confirmButton: buildConfirmButton('Remove the image', 'danger'),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
|
import { confirmDestructive } from '@@/modals/confirm';
|
||||||
|
import { buildConfirmButton } from '@@/modals/utils';
|
||||||
|
|
||||||
export class EdgeStacksViewController {
|
export class EdgeStacksViewController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
|
@ -25,6 +27,16 @@ export class EdgeStacksViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeActionAsync(stacks) {
|
async removeActionAsync(stacks) {
|
||||||
|
const confirmed = await confirmDestructive({
|
||||||
|
title: 'Are you sure?',
|
||||||
|
message: 'Are you sure you want to remove the selected Edge stack(s)?',
|
||||||
|
confirmButton: buildConfirmButton('Remove', 'danger'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (let stack of stacks) {
|
for (let stack of stacks) {
|
||||||
try {
|
try {
|
||||||
await this.EdgeStackService.remove(stack.Id);
|
await this.EdgeStackService.remove(stack.Id);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
|
import { confirmDestructive } from '@@/modals/confirm';
|
||||||
|
import { buildConfirmButton } from '@@/modals/utils';
|
||||||
|
|
||||||
angular.module('portainer.app').controller('GroupsController', GroupsController);
|
angular.module('portainer.app').controller('GroupsController', GroupsController);
|
||||||
|
|
||||||
|
@ -11,6 +13,16 @@ function GroupsController($scope, $state, $async, GroupService, Notifications) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeActionAsync(selectedItems) {
|
async function removeActionAsync(selectedItems) {
|
||||||
|
const confirmed = await confirmDestructive({
|
||||||
|
title: 'Are you sure?',
|
||||||
|
message: 'Are you sure you want to remove the selected environment group(s)?',
|
||||||
|
confirmButton: buildConfirmButton('Remove', 'danger'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (let group of selectedItems) {
|
for (let group of selectedItems) {
|
||||||
try {
|
try {
|
||||||
await GroupService.deleteGroup(group.Id);
|
await GroupService.deleteGroup(group.Id);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
|
import { confirmDestructive } from '@@/modals/confirm';
|
||||||
|
import { buildConfirmButton } from '@@/modals/utils';
|
||||||
|
|
||||||
angular.module('portainer.app').controller('TagsController', TagsController);
|
angular.module('portainer.app').controller('TagsController', TagsController);
|
||||||
|
|
||||||
|
@ -30,6 +32,16 @@ function TagsController($scope, $state, $async, TagService, Notifications) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeActionAsync(tags) {
|
async function removeActionAsync(tags) {
|
||||||
|
const confirmed = await confirmDestructive({
|
||||||
|
title: 'Are you sure?',
|
||||||
|
message: 'Are you sure you want to remove the selected tag(s)?',
|
||||||
|
confirmButton: buildConfirmButton('Remove', 'danger'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (let tag of tags) {
|
for (let tag of tags) {
|
||||||
try {
|
try {
|
||||||
await TagService.deleteTag(tag.Id);
|
await TagService.deleteTag(tag.Id);
|
||||||
|
|
Loading…
Reference in New Issue