Skip to content

Commit

Permalink
webadmin: confirm removing user profile properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rszwajko authored and sgratch committed Nov 1, 2022
1 parent 3aaa274 commit f28f68f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.ovirt.engine.core.common.businessentities.UserProfileProperty;
import org.ovirt.engine.core.common.businessentities.aaa.DbUser;
Expand All @@ -13,6 +14,7 @@
import org.ovirt.engine.ui.frontend.UserProfileManager;
import org.ovirt.engine.ui.uicommonweb.BaseCommandTarget;
import org.ovirt.engine.ui.uicommonweb.UICommand;
import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel;
import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
import org.ovirt.engine.ui.uicompat.ConstantsManager;
import org.ovirt.engine.ui.uicompat.UIConstants;
Expand All @@ -27,16 +29,53 @@ public UserSettingsModel() {
setTitle(ConstantsManager.getInstance().getConstants().accountSettings());
setHashName("user_settings"); //$NON-NLS-1$

removeCommand = new UICommand("Remove", new BaseCommandTarget() {//$NON-NLS-1$
@Override
public void executeCommand(UICommand uiCommand) {
removeUserProfileProperty();
}
});
removeCommand = new UICommand(
"RemoveUserProfilePropertyWithConfirmation", //$NON-NLS-1$
new BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
confirmRemoval();
}
});

updateActionAvailability();
}

private void confirmRemoval() {
if (getWindow() != null) {
return;
}

ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeUserProfilePropertiesTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().removeUserProfilePropertiesMessage());
model.setHashName("remove_user_profile_properties"); //$NON-NLS-1$

model.setItems(getSelectedItems().stream().map(UserProfileProperty::getName).collect(Collectors.toList()));

model.getCommands()
.add(
UICommand.createDefaultOkUiCommand(
"RemoveUserProfileProperty", //$NON-NLS-1$
new BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
removeUserProfileProperty();
setWindow(null);
}
}));
model.getCommands()
.add(UICommand.createCancelUiCommand(
"CancelRemovingUserProfileProperty", //$NON-NLS-1$
new BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
setWindow(null);
}
}));
}

private void removeUserProfileProperty() {
List<UserProfileProperty> selected = getSelectedItems();
if (selected == null || selected.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ public interface UIConstants extends Constants {

String removeUsersTitle();

String removeUserProfilePropertiesTitle();

String removeUserProfilePropertiesMessage();

String directoryGroupsTitle();

String quotaTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ removeTemplateDisksTitle=Remove Template Disk(s)
removeTemplatesTitle=Remove Template(s)
removeUnregisteredTemplatesTitle=Remove Unregistered Template(s)
removeUsersTitle=Remove User(s)
removeUserProfilePropertiesTitle=Remove User Profile properties
removeUserProfilePropertiesMessage=Are you sure you want to remove the following User Profile properties?
removeVirtualMachineTitle=Remove Virtual Machine
removeUnregisteredVirtualMachineTitle=Remove Unregistered Virtual Machine
removeVirtualMachinesTitle=Remove Virtual Machine(s)
Expand Down

0 comments on commit f28f68f

Please sign in to comment.