anmolbabu has uploaded a new change for review.

Change subject: webadmin : Show confirmation for geo-rep actions
......................................................................

webadmin : Show confirmation for geo-rep actions

This patch adds confirmation dialogs for stop, pause
and remove geo-rep sessions.

Change-Id: I319072213021cfd130b4521c0b77e5e4ab9cb1fe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1224893
Signed-off-by: Anmol Babu <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeGeoRepActionConfirmationModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.ui.xml
6 files changed, 93 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/42289/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeGeoRepActionConfirmationModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeGeoRepActionConfirmationModel.java
index 2a40ea9..f318574 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeGeoRepActionConfirmationModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeGeoRepActionConfirmationModel.java
@@ -12,6 +12,7 @@
     private EntityModel<Boolean> force;
     private String forceLabel;
     private String forceHelp;
+    private String message;
 
     public GlusterVolumeGeoRepActionConfirmationModel() {
         init();
@@ -23,6 +24,7 @@
         setSlaveHost(new EntityModel<String>());
         setForce(new EntityModel<Boolean>());
 
+        force.setIsAvailable(false);
     }
 
     protected void initWindow(String masterVolume, String slaveVolume, String 
slaveHost) {
@@ -77,6 +79,15 @@
         onPropertyChanged(new 
PropertyChangedEventArgs("forceHelp"));//$NON-NLS-1$
     }
 
+    public String getMessage() {
+        return message;
+    }
+
+    public void setActionConfirmationMessage(String message) {
+        this.message = message;
+        onPropertyChanged(new 
PropertyChangedEventArgs("ActionConfirmationMessage"));//$NON-NLS-1$
+    }
+
     public void setForceLabel(String forceLabel) {
         this.forceLabel = forceLabel;
         onPropertyChanged(new 
PropertyChangedEventArgs("forceLabel"));//$NON-NLS-1$
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
index ba2cb11..8b74696 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeGeoRepListModel.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.ui.uicommonweb.models.gluster;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -231,13 +232,13 @@
         if (command.equals(getNewSessionCommand())) {
             createGeoRepSession();
         } else if (command.equals(getRemoveSessionCommand())) {
-            removeGeoRepSession();
+            confirmGeoRepAction(constants.geoReplicationRemoveTitle(), 
HelpTag.volume_geo_rep_remove_confirmation, 
"volume_geo_rep_remove_confirmation", "removeGeoRepSession", 
constants.removeGeoRep());//$NON-NLS-1$//$NON-NLS-2$
         } else if(command.equals(getStartSessionCommand())) {
             startGeoRepSession();
         } else if(command.equals(getStopSessionCommand())) {
-            stopGeoRepSession();
+            confirmGeoRepAction(constants.geoReplicationStopTitle(), 
HelpTag.volume_geo_rep_stop_confirmation, "volume_geo_rep_stop_confirmation", 
"stopGeoRepSesssion", constants.stopGeoRep());//$NON-NLS-1$//$NON-NLS-2$
         }  else if(command.equals(getPauseSessionCommand())) {
-            pauseGeoRepSession();
+            confirmGeoRepAction(constants.geoReplicationPauseTitle(), 
HelpTag.volume_geo_rep_pause_confirmation, "volume_geo_rep_pause_confirmation", 
"pauseGeoRepSession", constants.pauseGeoRep());//$NON-NLS-1$//$NON-NLS-2$
         } else if(command.equals(getResumeSessionCommand())) {
             resumeGeoRepSession();
         } else if(command.equals(getSessionOptionsCommand())) {
@@ -262,6 +263,12 @@
             updateConfig();
         } else if (command.getName().equalsIgnoreCase("closeWindow")) 
{//$NON-NLS-1$
             closeWindow();
+        } else if(command.getName().equalsIgnoreCase("stopGeoRepSesssion")) 
{//$NON-NLS-1$
+            stopGeoRepSession();
+        } else if(command.getName().equalsIgnoreCase("removeGeoRepSession")) 
{//$NON-NLS-1$
+            removeGeoRepSession();
+        } else if(command.getName().equalsIgnoreCase("pauseGeoRepSession")) 
{//$NON-NLS-1$
+            pauseGeoRepSession();
         } else if (command.getName().equalsIgnoreCase("closeConfirmWindow")) 
{//$NON-NLS-1$
             closeConfirmWindow();
         }
@@ -443,7 +450,7 @@
                         if (result.getReturnValue().getSucceeded()) {
                             closeWindow();
                             if (createModel.getStartSession().getEntity()) {
-                                
initializeGeoRepActionConfirmation(constants.geoReplicationStartTitle(), 
HelpTag.volume_geo_rep_start_confirmation, "volume_geo_rep_start_confirmation", 
constants.geoRepForceHelp(), 
messages.geoRepForceTitle(constants.startGeoRep()), "onStartGeoRepSession", 
getEntity().getName(), remoteVolumeName, 
remoteHostName);//$NON-NLS-1$//$NON-NLS-2$
+                                
initializeGeoRepActionConfirmation(constants.geoReplicationStartTitle(), 
HelpTag.volume_geo_rep_start_confirmation, "volume_geo_rep_start_confirmation", 
constants.geoRepForceHelp(), 
messages.geoRepForceTitle(constants.startGeoRep()), "onStartGeoRepSession", 
getEntity().getName(), remoteVolumeName, remoteHostName, 
null);//$NON-NLS-1$//$NON-NLS-2$
                                 final 
GlusterVolumeGeoRepActionConfirmationModel cModel = 
(GlusterVolumeGeoRepActionConfirmationModel) getWindow();
                                 cModel.startProgress(null);
                                 
Frontend.getInstance().runAction(VdcActionType.StartGlusterVolumeGeoRep,
@@ -512,6 +519,15 @@
         performGeoRepAction("onStopGeoRepSession", 
constants.geoReplicationStopTitle(), HelpTag.volume_geo_rep_stop_confirmation, 
"volume_geo_rep_stop_confirmation", constants.stopGeoRep(), 
VdcActionType.StopGeoRepSession, 
constants.stopGeoRepProgressText());//$NON-NLS-1$//$NON-NLS-2$
     }
 
+    private void confirmGeoRepAction(String title, HelpTag helpTag, String 
hashName, String commandName, String action) {
+        GlusterGeoRepSession selectedSession = getSelectedItem();
+        if (selectedSession == null) {
+            return;
+        }
+
+        initializeGeoRepActionConfirmation(title, helpTag, hashName, null, 
null, commandName, selectedSession.getMasterVolumeName(), 
selectedSession.getSlaveVolumeName(), selectedSession.getSlaveHostName(), 
messages.geoRepActionConfirmationMessage(action));
+    }
+
     private void pauseGeoRepSession() {
         performGeoRepAction("onPauseGeoRepSession", 
constants.geoReplicationPauseTitle(), 
HelpTag.volume_geo_rep_pause_confirmation, "volume_geo_rep_pause_confirmation", 
constants.pauseGeoRep(), VdcActionType.PauseGlusterVolumeGeoRepSession, 
constants.pauseGeoRepProgressText());//$NON-NLS-1$//$NON-NLS-2$
     }
@@ -536,13 +552,22 @@
             return;
         }
 
-        initializeGeoRepActionConfirmation(confirmTitle, helpTag, hashName, 
constants.geoRepForceHelp(), messages.geoRepForceTitle(action), commandName, 
selectedSession.getMasterVolumeName(), selectedSession.getSlaveVolumeName(), 
selectedSession.getSlaveHostName());
+        initializeGeoRepActionConfirmation(confirmTitle, helpTag, hashName, 
constants.geoRepForceHelp(), messages.geoRepForceTitle(action), commandName, 
selectedSession.getMasterVolumeName(), selectedSession.getSlaveVolumeName(), 
selectedSession.getSlaveHostName(), null);
         onGeoRepSessionAction(actionType);
     }
 
-    private void initializeGeoRepActionConfirmation(String title, HelpTag 
helpTag, String hashName, String forceHelp, String forceLabelText, String 
commandName, String masterVolumeName, String slaveVolumeName, String 
slaveHostName) {
-        GlusterVolumeGeoRepActionConfirmationModel cModel = new 
GlusterVolumeGeoRepActionConfirmationModel();
-        cModel.setTitle(title);
+    private void initializeGeoRepActionConfirmation(String title, HelpTag 
helpTag, String hashName, String forceHelp, String forceLabelText, String 
commandName, String masterVolumeName, String slaveVolumeName, String 
slaveHostName, String message) {
+        GlusterVolumeGeoRepActionConfirmationModel cModel;
+        if(getWindow() != null) {
+            if((getWindow() instanceof 
GlusterVolumeGeoRepActionConfirmationModel)) {
+                cModel = (GlusterVolumeGeoRepActionConfirmationModel) 
getWindow();
+            } else {
+                return;
+            }
+        } else {
+            cModel = new GlusterVolumeGeoRepActionConfirmationModel();
+            cModel.setTitle(title);
+        }
         cModel.setHelpTag(helpTag);
         cModel.setHashName(hashName);
 
@@ -550,18 +575,17 @@
 
         cModel.initWindow(masterVolumeName, slaveVolumeName, slaveHostName);
 
+        cModel.setActionConfirmationMessage(message);
         cModel.setForceHelp(forceHelp);
         cModel.setForceLabel(forceLabelText);
 
-        UICommand okCommand = new UICommand(commandName, this);
-        okCommand.setTitle(constants.ok());
-        okCommand.setIsDefault(true);
-        cModel.getCommands().add(okCommand);
+        List<UICommand> geoRepActionCommands = 
Arrays.asList(UICommand.createDefaultOkUiCommand(commandName, this), 
UICommand.createCancelUiCommand("closeWindow", this));//$NON-NLS-1$
 
-        UICommand cancelCommand = new UICommand("closeWindow", 
this);//$NON-NLS-1$
-        cancelCommand.setTitle(constants.cancel());
-        cancelCommand.setIsCancel(true);
-        cModel.getCommands().add(cancelCommand);
+        if(cModel.getCommands().size() > 0) {
+            cModel.setCommands(geoRepActionCommands);
+        } else {
+            cModel.getCommands().addAll(geoRepActionCommands);
+        }
     }
 
     private void refreshSessions() {
@@ -597,7 +621,7 @@
                 else {
                     cModel.stopProgress();
                     if (!result.getReturnValue().getSucceeded()) {
-                        
cModel.setMessage(result.getReturnValue().getFault().getMessage());
+                        
cModel.setActionConfirmationMessage(result.getReturnValue().getFault().getMessage());
                     } else {
                         setWindow(null);
                     }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
index 5248c78..57c74a3 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
@@ -419,6 +419,9 @@
     @DefaultMessage("Force {0} session")
     String geoRepForceTitle(String action);
 
+    @DefaultMessage("Are you sure you want to {0} geo-rep session")
+    String geoRepActionConfirmationMessage(String action);
+
     // Gluster Volume Snapshots
     @DefaultMessage("Value of cluster configuration parameter {0} is empty")
     String clusterSnapshotOptionValueEmpty(String option);
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget.java
index fe752e4..674cf87 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeGeoRepActionConfirmPopUpViewPresenterWidget.java
@@ -25,13 +25,13 @@
             @Override
             public void eventRaised(Event ev, Object sender, EventArgs args) {
                 
if(((PropertyChangedEventArgs)args).propertyName.equalsIgnoreCase("forceLabel"))
 {//$NON-NLS-1$
-                    if(model.getForceLabel() != null) {
-                        getView().setForceLabelMessage(model.getForceLabel());
-                    }
+                    getView().setForceLabelMessage(model.getForceLabel());
                 } else 
if(((PropertyChangedEventArgs)args).propertyName.equalsIgnoreCase("forceHelp")) 
{//$NON-NLS-1$
                     getView().setForceHelp(model.getForceHelp());
                 } else if 
(((PropertyChangedEventArgs)args).propertyName.equalsIgnoreCase("Message")) 
{//$NON-NLS-1$
                     getView().setErrorMessage(model.getMessage());
+                } else 
if(((PropertyChangedEventArgs)args).propertyName.equalsIgnoreCase("ActionConfirmationMessage"))
 {//$NON-NLS-1$
+                    getView().setActionConfirmationMessage(model.getMessage());
                 }
             }
         });
@@ -41,6 +41,7 @@
         public void setForceLabelMessage(String forceLabelMessage);
         public void setForceHelp(String forceHelpText);
         public void setErrorMessage(String errorMessage);
+        public void setActionConfirmationMessage(String message);
     }
 
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
index 50595a3..b503a20 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.java
@@ -40,6 +40,11 @@
     WidgetStyle style;
 
     @UiField
+    @Ignore
+    @WithElementId
+    Label actionConfirmationMessage;
+
+    @UiField
     @Path("masterVolume.entity")
     @WithElementId
     StringEntityModelLabelEditor masterVolumeEditor;
@@ -86,7 +91,12 @@
         localize();
         addStyles();
         driver.initialize(this);
+        initVisibilities();
+    }
+
+    private void initVisibilities() {
         errorMsg.setVisible(false);
+        geoRepForceHelpIcon.setVisible(false);
     }
 
     private void addStyles() {
@@ -101,8 +111,11 @@
 
     @Override
     public void setForceLabelMessage(String forceLabelMessage) {
-        forceEditor.setLabel(forceLabelMessage == null ? 
constants.notAvailableLabel() : forceLabelMessage);
-        forceEditor.setVisible(forceLabelMessage != null);
+        boolean isNonEmptyForceLabelMessage = forceLabelMessage != null;
+        if (isNonEmptyForceLabelMessage) {
+            forceEditor.setLabel(forceLabelMessage);
+        }
+        forceEditor.setVisible(isNonEmptyForceLabelMessage);
     }
 
     private void initEditors() {
@@ -117,7 +130,11 @@
 
     @Override
     public void setForceHelp(String forceHelpText) {
-        geoRepForceHelpIcon.setText(templates.italicText(forceHelpText));
+        boolean isForceHelpNonEmpty = forceHelpText != null;
+        if (isForceHelpNonEmpty) {
+            geoRepForceHelpIcon.setText(templates.italicText(forceHelpText));
+        }
+        geoRepForceHelpIcon.setVisible(isForceHelpNonEmpty);
     }
 
     @Override
@@ -125,10 +142,20 @@
         return driver.flush();
     }
 
+    public void setActionConfirmationMessage(String message) {
+        boolean isNonEmptyMessage = message != null;
+        if (isNonEmptyMessage) {
+            actionConfirmationMessage.setText(message);
+        }
+    }
+
     @Override
     public void setErrorMessage(String errorMessage) {
-        errorMsg.setText(errorMessage);
-        errorMsg.setVisible(errorMessage != null);
+        boolean isNonEmptyErrorMessage = errorMessage != null;
+        if (isNonEmptyErrorMessage) {
+            errorMsg.setText(errorMessage);
+        }
+        errorMsg.setVisible(isNonEmptyErrorMessage);
     }
 
     interface WidgetStyle extends CssResource {
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.ui.xml
index acffff6..a940001 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GeoRepActionConfirmPopUpView.ui.xml
@@ -28,6 +28,7 @@
        <d:SimpleDialogPanel width="480px" height="300px">
                <d:content>
                        <g:FlowPanel>
+                               <g:Label ui:field="actionConfirmationMessage" 
addStyleNames="{style.messageLabel}" />
                                <ge:StringEntityModelLabelEditor 
ui:field="masterVolumeEditor" />
                                <ge:StringEntityModelLabelEditor 
ui:field="slaveVolumeEditor" />
                                <ge:StringEntityModelLabelEditor 
ui:field="slaveHostEditor" />
@@ -35,7 +36,7 @@
                                        <ge:EntityModelCheckBoxEditor 
ui:field="forceEditor" />
                                        <d:InfoIcon 
ui:field="geoRepForceHelpIcon" />
                                </g:HorizontalPanel>
-                               <g:Label ui:field="errorMsg" 
addStyleNames="{style.messageLabel}"/>
+                               <g:Label ui:field="errorMsg" 
addStyleNames="{style.messageLabel}" />
                        </g:FlowPanel>
                </d:content>
        </d:SimpleDialogPanel>


-- 
To view, visit https://gerrit.ovirt.org/42289
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I319072213021cfd130b4521c0b77e5e4ab9cb1fe
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: anmolbabu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to