-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(image): add the ability to force remove an image (#497) #562
Conversation
@ncresswell do we still want to add the ability to force remove an image? |
@Filirom1 would you be able to implement that information ? I'm not a great fond of popups as I've think they're bad for UX but nonetheless I agree with Neil that some confirmation should be asked. |
Hi @ncresswell I don't see what you are asking for. If you have examples it could help me. Otherwize, with html5 dialog we could have something like this easily: Pressing the ESC on the keyboard also cancel the dialog. As for I as know, |
IMO, message needs to be udpated as a user could select multiple images and trigger the force remove. |
Ok, I will push my commits once I get back home. And we will iterate on it to have something great :-) |
Perfect ! Thanks a lot @Filirom1 👍 |
bd14a76
to
9c12eba
Compare
Looks like something went wrong ;) You should just pull/merge develop instead of doing a rebase. |
9c12eba
to
e984b5f
Compare
Yes, I rebase on master. Bad idea 😢 |
That's better ! I'll have a look at it today. |
Even if I despise popups, I do not see any alternative here. I'm OK for the bootbox library. IMO, the message should be updated to "Forcing the removal of the image will remove the image even if it has multiple tags or if it is used by stopped containers". |
I like your message, I commit it 👯♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at my comments for a few changes.
Also, please run grunt lint
and fix linting issues.
Oh and one more thing, would it be possible to have the modal centered on the screen instead of it opening in the top part of the screen ?
$scope.confirmRemovalAction = function (force) { | ||
bootbox.confirm({ | ||
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an extra '.' at the end of the sentence?
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", | ||
buttons: { | ||
confirm: { | ||
label: 'Force', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the label with 'Remove the image'
@@ -59,7 +59,28 @@ function ($scope, $state, Config, Image, ImageHelper, Messages, Pagination) { | |||
}); | |||
}; | |||
|
|||
$scope.removeAction = function () { | |||
$scope.confirmRemovalAction = function (force) { | |||
bootbox.confirm({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you could isolate the bootbox call inside a specific service ? Like ModalService
? This way if we want to get rid of bootbox
later, we'll just have to change the implementation there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
About the linter, I fixed my code, but the linter is still displaying a lot of errors elsewhere in the code. Are you aware of it ?
|
Please run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An update is required in the ModalService.
@@ -59,7 +59,28 @@ function ($scope, $state, Config, Image, ImageHelper, Messages, Pagination) { | |||
}); | |||
}; | |||
|
|||
$scope.removeAction = function () { | |||
$scope.confirmRemovalAction = function (force) { | |||
ModalService.confirm({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go farther when isolating the bootbox inside the ModalService. ModalService methods should be pretty abstract and should not know about the required fields. It should only expose a confirmationModal
method with the things that can change inside a confimation modal (e.g. title, message, confirmLabel, cancelLabel and the success callback).
Something like ModalService.confirmModal('Are you sure?', Forcing the removal of the image will remove the image even if it has multiple tags or if it is used by stopped containers.', 'Remove the image', 'Cancel'
, function () { ... })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I understand your point, but passing such parameters as arguments will make this module hard to evolve.
I would prefer passing parameters as an object:
ModalService.confirmModal({
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.',
confirm: {
label: 'Remove the image'
},
cancel: {
label: 'cancel'
}
})
To make my point clear, in our situation, the className of the confirm button is red for danger.
This may not be the case, if later, for example, we want to use this service to confirm a password change.
Passing an object will make it simpler to extend with additional parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I offer you this new solution in a5944dc, based on object passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is OK for me.
assets/css/app.css
Outdated
@@ -135,6 +139,23 @@ input[type="radio"] { | |||
line-height: 1.42857143; | |||
border-radius: 4px; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this code is related to the centering of the modal. Have you tried to do it in the service directly ? See bootboxjs/bootbox#166 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @Filirom1 👍 Also, please update your local dev dependencies as there is still a small linting issue:
I'll merge it and fix the linting issue. |
Co-authored-by: Simon Meng <simon.meng@portainer.io>
Hello,
This MR implements #497
This is my first contribution on this project, I am volonteer to continue on #354, if this one is OK for you.
Cheers
Romain
Close #497