Tomas Jelinek has uploaded a new change for review. Change subject: engine,frontend: add snapshot type column ......................................................................
engine,frontend: add snapshot type column The problem was that the "Activet VM before preview" and "Active VM" Strings were hardcoded in the backend and written to the DB as a description. The problem with this is that it can not be localized. This patch removes this hardcodes (also an upgrade script removes the old ones) and adds this info as a new column into the Snapshots subtab of the VM tab. It uses the same styles as the description used. Change-Id: I26866fd4dd91d034e7ae5afee054080a4ab864a1 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1010122 Signed-off-by: Tomas Jelinek <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/TryBackToAllSnapshotsOfVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/snapshot/SnapshotsViewColumns.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.ui.xml M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Enums.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties A packaging/dbscripts/upgrade/03_03_0900_remove_hardcoded_snapshot_descriptions.sql 11 files changed, 40 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/19542/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/TryBackToAllSnapshotsOfVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/TryBackToAllSnapshotsOfVmCommand.java index efaea52..140feb2 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/TryBackToAllSnapshotsOfVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/TryBackToAllSnapshotsOfVmCommand.java @@ -135,7 +135,7 @@ Guid previousActiveSnapshotId = previousActiveSnapshot.getId(); getSnapshotDao().remove(previousActiveSnapshotId); snapshotsManager.addSnapshot(previousActiveSnapshotId, - "Active VM before the preview", + "", SnapshotType.PREVIEW, getVm(), previousActiveSnapshot.getMemoryVolume(), diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java index 120a5db..c4158c0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java @@ -149,7 +149,7 @@ String memoryVolume, final CompensationContext compensationContext) { return addSnapshot(snapshotId, - "Active VM", + "", snapshotStatus, SnapshotType.ACTIVE, vm, diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index e74763c..783bf32 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -1569,4 +1569,7 @@ @DefaultStringValue("Attach a VirtIO-SCSI controller when running the VM") String isVirtioScsiEnabledInfo(); + + @DefaultStringValue("Snapshot Type") + String snapshotType(); } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/snapshot/SnapshotsViewColumns.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/snapshot/SnapshotsViewColumns.java index 479c6fc..d9907cf 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/snapshot/SnapshotsViewColumns.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/snapshot/SnapshotsViewColumns.java @@ -14,6 +14,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import org.ovirt.engine.ui.uicompat.EnumTranslator; public class SnapshotsViewColumns { private static final CommonApplicationConstants constants = GWT.create(CommonApplicationConstants.class); @@ -26,6 +27,21 @@ return constants.currentSnapshotLabel(); } return FullDateTimeRenderer.getLocalizedDateTimeFormat().format(snapshot.getCreationDate()); + } + }; + + public static SafeHtmlColumn<Snapshot> snapshotTypeColumn = new SafeHtmlColumn<Snapshot>() { + + @Override + public final SafeHtml getValue(Snapshot snapshot) { + String translated = EnumTranslator.createAndTranslate(snapshot.getType()); + SafeHtml res = SafeHtmlUtils.fromString(translated); + + if (snapshot.getType() == SnapshotType.ACTIVE || snapshot.getType() == SnapshotType.PREVIEW) { + res = templates.snapshotDescription("color:gray", translated); //$NON-NLS-1$ + } + + return res; } }; @@ -63,9 +79,6 @@ else if (snapshot.getType() == SnapshotType.STATELESS) { descriptionStr = descriptionStr + " (" + constants.readonlyLabel() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ description = templates.snapshotDescription("font-style:italic", descriptionStr); //$NON-NLS-1$ - } - else if (snapshot.getType() == SnapshotType.ACTIVE || snapshot.getType() == SnapshotType.PREVIEW) { - description = templates.snapshotDescription("color:gray", descriptionStr); //$NON-NLS-1$ } return description; diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.java index 3ce4bf7..c9e6431 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.java @@ -121,6 +121,10 @@ getTable().ensureColumnPresent(SnapshotsViewColumns.memoryColumn, constants.memorySnapshot(), memorySnapshotSupported, "55px"); //$NON-NLS-1$ + + getTable().ensureColumnPresent(SnapshotsViewColumns.snapshotTypeColumn, + constants.snapshotType(), true, "100px"); //$NON-NLS-1$ + getTable().ensureColumnPresent(SnapshotsViewColumns.descriptionColumn, constants.descriptionSnapshot(), true, "185px"); //$NON-NLS-1$ } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.ui.xml index 37690f0..c12a8f3 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmSnapshotListModelTable.ui.xml @@ -40,7 +40,7 @@ </ui:style> <g:SplitLayoutPanel addStyleNames="{style.container}"> - <g:west size="500"> + <g:west size="600"> <g:SimplePanel ui:field="snapshotsTableContainer"/> </g:west> <g:center> diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Enums.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Enums.java index edc860f..25b6fcf 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Enums.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Enums.java @@ -276,14 +276,6 @@ String Snapshot$SnapshotStatus___IN_PREVIEW(); - String Snapshot$SnapshotType___REGULAR(); - - String Snapshot$SnapshotType___ACTIVE(); - - String Snapshot$SnapshotType___STATELESS(); - - String Snapshot$SnapshotType___PREVIEW(); - String VdsSpmStatus___None(); String VdsSpmStatus___Contending(); diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java index 301bb4a..bbd03b2 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java @@ -845,4 +845,12 @@ String UnitVmModel$CpuSharesAmount___CUSTOM(); + String Snapshot$SnapshotType___REGULAR(); + + String Snapshot$SnapshotType___ACTIVE(); + + String Snapshot$SnapshotType___STATELESS(); + + String Snapshot$SnapshotType___PREVIEW(); + } diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties index dbe5081..4abcca0 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties @@ -133,10 +133,6 @@ Snapshot$SnapshotStatus___OK=Ok Snapshot$SnapshotStatus___LOCKED=Locked Snapshot$SnapshotStatus___IN_PREVIEW=In Preview -Snapshot$SnapshotType___REGULAR=Regular -Snapshot$SnapshotType___ACTIVE=Active -Snapshot$SnapshotType___STATELESS=Stateless -Snapshot$SnapshotType___PREVIEW=Preview VdsSpmStatus___None=None VdsSpmStatus___Contending=Contending VdsSpmStatus___SPM=SPM diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties index 4976a79..3726d96 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties @@ -421,3 +421,7 @@ UnitVmModel$CpuSharesAmount___MEDIUM=Medium UnitVmModel$CpuSharesAmount___LOW=Low UnitVmModel$CpuSharesAmount___CUSTOM=Custom +Snapshot$SnapshotType___REGULAR=Regular +Snapshot$SnapshotType___ACTIVE=Active +Snapshot$SnapshotType___STATELESS=Stateless +Snapshot$SnapshotType___PREVIEW=Active VM before the preview diff --git a/packaging/dbscripts/upgrade/03_03_0900_remove_hardcoded_snapshot_descriptions.sql b/packaging/dbscripts/upgrade/03_03_0900_remove_hardcoded_snapshot_descriptions.sql new file mode 100644 index 0000000..2e73768 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_03_0900_remove_hardcoded_snapshot_descriptions.sql @@ -0,0 +1,2 @@ +update snapshots set description = '' where description = 'Active VM' and snapshot_type = 'ACTIVE'; +update snapshots set description = '' where description = 'Active VM before the preview' and snapshot_type = 'PREVIEW'; -- To view, visit http://gerrit.ovirt.org/19542 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26866fd4dd91d034e7ae5afee054080a4ab864a1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
