Alissa Bonas has uploaded a new change for review.

Change subject: webadmin: edit path for localstorage
......................................................................

webadmin: edit path for localstorage

Add ability to edit path for local storage in Storage tab
in webadmin. The edit will be possible for storage domains
in maintenance.

Change-Id: Ice7ee59325fb5a6d0eafde6e6e37c866bc662bc9
Signed-off-by: Alissa Bonas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/storage/AbstractStorageView.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/LocalStorageView.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
8 files changed, 33 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/15540/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
index b6032eb..ebcc551 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
@@ -50,7 +50,7 @@
     protected boolean canDoAction() {
         StorageServerConnections newConnectionDetails = 
getParameters().getStorageServerConnection();
 
-        if (newConnectionDetails.getstorage_type() != StorageType.NFS && 
newConnectionDetails.getstorage_type() != StorageType.POSIXFS) {
+        if(!newConnectionDetails.getstorage_type().isFileDomain() || 
newConnectionDetails.getstorage_type().equals(StorageType.GLUSTERFS)) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE);
         }
 
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index fe4344b..79f96bf 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -346,7 +346,7 @@
 ACTION_TYPE_FAILED_URL_INVALID=Cannot ${action} ${type}. The URL is not valid, 
please enter a valid URL and try again.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST=Cannot ${action} ${type}. 
Storage connection doesn't exist.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS 
data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are related to more than one 
storage domain : ${domainNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_WRONG_PARAMETERS_FOR_STORAGE_TYPE=Cannot 
${action} ${type}. Connection parameters are invalid for this storage type.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE=Cannot 
${action} ${type}. Storage type cannot be edited.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index cf837f7..64e39cb 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -967,7 +967,7 @@
     @DefaultStringValue("Cannot ${action} ${type}. Storage connection already 
exists.")
     String ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS();
 
-    @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters can be edited only for NFS data domains in maintenance.")
+    @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters can be edited only for NFS, Posix or local data domains in 
maintenance.")
     String  
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE();
 
     @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters are related to more than one storage domain")
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/storage/AbstractStorageView.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/storage/AbstractStorageView.java
index 485df74..1e3c452 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/storage/AbstractStorageView.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/storage/AbstractStorageView.java
@@ -1,43 +1,15 @@
 package org.ovirt.engine.ui.common.widget.uicommon.storage;
 
 import org.ovirt.engine.ui.common.widget.HasEditorDriver;
-import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor;
 import org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel;
 
-import com.google.gwt.dom.client.Style.Unit;
 import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.ValueBox;
 
 public abstract class AbstractStorageView<M extends IStorageModel> extends 
Composite implements HasEditorDriver<M> {
-
-    @Ignore
-    protected EntityModelTextBoxEditor pathEditor;
 
     protected boolean multiSelection;
 
     public abstract void focus();
-
-    protected void createPathEditor() {
-        pathEditor = new EntityModelTextBoxEditor() {
-            boolean accessible;
-
-            @Override
-            public void setAccessible(boolean accessible) {
-                this.accessible = accessible;
-
-                if (!accessible) {
-                    ValueBox<Object> localPathValueBox = super.asValueBox();
-                    localPathValueBox.setReadOnly(true);
-                    
localPathValueBox.getElement().getStyle().setBorderWidth(0, Unit.PX);
-                }
-            }
-
-            @Override
-            public void setEnabled(boolean enabled) {
-                super.setEnabled(accessible ? enabled : true);
-            }
-        };
-    }
 
     public boolean isSubViewFocused() {
         return false;
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java
index 192188e..5de9590 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java
@@ -361,15 +361,16 @@
         model.getAvailableStorageItems().setIsChangable(false);
         model.setIsChangable(isStorageEditable);
 
+        boolean isPathEditable = isPathEditable(storage);
+        isStorageEditable = isStorageEditable || isPathEditable;
+
         IStorageModel item = null;
         switch (storage.getStorageType()) {
             case NFS:
                 item = prepareNfsStorageForEdit(storage);
-                boolean isNfsPathEditable = isPathEditable(storage);
-                isStorageEditable = isStorageEditable || isNfsPathEditable;
                 //when storage is active, only SPM can perform actions on it, 
thus it is set above that host is not changeable.
                 //If storage is editable but not active (maintenance) - any 
host can perform the edit so the changeable here is set based on that
-                model.getHost().setIsChangable(isNfsPathEditable);
+                model.getHost().setIsChangable(isPathEditable);
                 break;
 
             case FCP:
@@ -382,12 +383,11 @@
 
             case LOCALFS:
                 item = prepareLocalStorageForEdit(storage);
+                model.getHost().setIsChangable(isPathEditable);
                 break;
 
             case POSIXFS:
                 item = preparePosixStorageForEdit(storage);
-                boolean isPathEditable = isPathEditable(storage);
-                isStorageEditable = isStorageEditable || isPathEditable;
                 //when storage is active, only SPM can perform actions on it, 
thus it is set above that host is not changeable.
                 //If storage is editable but not active (maintenance) - any 
host can perform the edit so the changeable here is set based on that
                 model.getHost().setIsChangable(isPathEditable);
@@ -480,19 +480,22 @@
     }
 
     private boolean isPathEditable(StorageDomain storage) {
-        return (storage.getStorageDomainType() == StorageDomainType.Data || 
storage.getStorageDomainType() == StorageDomainType.Master) && 
storage.getStatus() == StorageDomainStatus.Maintenance;
+        if(storage.getStorageType().isFileDomain() && 
!storage.getStorageType().equals(StorageType.GLUSTERFS)) {
+          return ((storage.getStorageDomainType() == StorageDomainType.Data || 
storage.getStorageDomainType() == StorageDomainType.Master) && 
storage.getStatus() == StorageDomainStatus.Maintenance);
+        }
+        return false;
     }
 
     private IStorageModel prepareLocalStorageForEdit(StorageDomain storage)
     {
         LocalStorageModel model = new LocalStorageModel();
         model.setRole(storage.getStorageDomainType());
-        model.getPath().setIsAvailable(false);
+        boolean isPathEditable = isPathEditable(storage);
+        model.getPath().setIsChangable(isPathEditable);
 
         AsyncDataProvider.getStorageConnectionById(new AsyncQuery(model, new 
INewAsyncCallback() {
             @Override
             public void onSuccess(Object target, Object returnValue) {
-
                 LocalStorageModel localStorageModel = (LocalStorageModel) 
target;
                 StorageServerConnections connection = 
(StorageServerConnections) returnValue;
                 
localStorageModel.getPath().setEntity(connection.getconnection());
@@ -1769,15 +1772,22 @@
         }
         else
         {
-            Frontend.RunAction(VdcActionType.UpdateStorageDomain, new 
StorageDomainManagementParameter(storageDomain), new 
IFrontendActionAsyncCallback() {
-                @Override
-                public void executed(FrontendActionAsyncResult result) {
-
-                    StorageListModel storageListModel = (StorageListModel) 
result.getState();
-                    storageListModel.onFinish(storageListModel.context, true, 
storageListModel.storageModel);
-
-                }
-            }, this);
+            StorageDomain storageDomain = (StorageDomain) getSelectedItem();
+            if (isPathEditable(storageDomain)) {
+                updatePath();
+            }
+            else {
+                Frontend.RunAction(VdcActionType.UpdateStorageDomain,
+                        new 
StorageDomainManagementParameter(this.storageDomain),
+                        new IFrontendActionAsyncCallback() {
+                            @Override
+                            public void executed(FrontendActionAsyncResult 
result) {
+                                StorageListModel storageListModel = 
(StorageListModel) result.getState();
+                                
storageListModel.onFinish(storageListModel.context, true, 
storageListModel.storageModel);
+                            }
+                        },
+                        this);
+            }
         }
     }
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index c958c03..12cae66 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -342,7 +342,7 @@
 ACTION_TYPE_FAILED_URL_INVALID=Cannot ${action} ${type}. The URL is not valid, 
please enter a valid URL and try again.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST=Cannot ${action} ${type}. 
Storage connection doesn't exist.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS 
data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are related to more than one 
storage domain : ${domainNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_WRONG_PARAMETERS_FOR_STORAGE_TYPE=Cannot 
${action} ${type}. Connection parameters are invalid for this storage type.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE=Cannot 
${action} ${type}. Storage type cannot be edited.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/LocalStorageView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/LocalStorageView.java
index f00ac20..6aa715b 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/LocalStorageView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/LocalStorageView.java
@@ -33,7 +33,7 @@
     @UiField
     WidgetStyle style;
 
-    @UiField(provided = true)
+    @UiField
     @WithElementId
     @Path(value = "path.entity")
     EntityModelTextBoxEditor localPathEditor;
@@ -45,8 +45,6 @@
 
     @Inject
     public LocalStorageView() {
-        createPathEditor();
-        localPathEditor = pathEditor;
         initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
         localize(ClientGinjectorProvider.instance().getApplicationConstants());
         ViewIdHandler.idHandler.generateAndSetIds(this);
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index dc68e5b..14c1df6 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -350,7 +350,7 @@
 ACTION_TYPE_FAILED_URL_INVALID=Cannot ${action} ${type}. The URL is not valid, 
please enter a valid URL and try again.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST=Cannot ${action} ${type}. 
Storage connection doesn't exist.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS 
data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are related to more than one 
storage domain : ${domainNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_WRONG_PARAMETERS_FOR_STORAGE_TYPE=Cannot 
${action} ${type}. Connection parameters are invalid for this storage type.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE=Cannot 
${action} ${type}. Storage type cannot be edited.


-- 
To view, visit http://gerrit.ovirt.org/15540
To unsubscribe, visit http://gerrit.ovirt.org/settings

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

Reply via email to