From 030966baf4d464158297485e6c925aff1e6d158e Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 6 Sep 2024 22:26:32 +0530 Subject: [PATCH] Add special warning message for Factory Reset, Enterprise Wipe, disneroll operations. --- .../mgt/core/device/mgt/common/Feature.java | 164 ++++++++++++++++++ .../HTTPDeviceTypeManagerService.java | 23 +++ .../template/config/ConfirmationTexts.java | 127 ++++++++++++++ .../config/DangerZoneTooltipTexts.java | 90 ++++++++++ .../device/type/template/config/Feature.java | 26 ++- .../type/template/config/Operation.java | 28 ++- .../ConfigurationBasedFeatureManager.java | 27 ++- 7 files changed, 481 insertions(+), 4 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java index 800d142c3e..a495acc279 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java @@ -93,6 +93,20 @@ public class Feature implements Serializable { ) private List metadataEntries; + @ApiModelProperty( + name = "confirmationTexts", + value = "Disenroll delete confirmation modal texts.", + required = false + ) + private ConfirmationTexts confirmationTexts; + + @ApiModelProperty( + name = "dangerZoneTooltipTexts", + value = "Danger zone tooltip texts.", + required = false + ) + private DangerZoneTooltipTexts dangerZoneTooltipTexts; + @XmlElement public int getId() { return id; @@ -173,6 +187,24 @@ public class Feature implements Serializable { this.hidden = hidden; } + @XmlElement + public ConfirmationTexts getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(ConfirmationTexts confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + + @XmlElement + public DangerZoneTooltipTexts getDangerZoneTooltipTexts() { + return dangerZoneTooltipTexts; + } + + public void setDangerZoneTooltipTexts(DangerZoneTooltipTexts dangerZoneTooltipTexts) { + this.dangerZoneTooltipTexts = dangerZoneTooltipTexts; + } + public static class MetadataEntry implements Serializable { private int id; @@ -203,4 +235,136 @@ public class Feature implements Serializable { this.value = value; } } + + public static class ConfirmationTexts implements Serializable { + private int id; + private String deleteConfirmModalTitle; + private String deleteConfirmModalText; + private String deleteConfirmationTextDescribe; + private String deleteConfirmationText; + private String cancelText; + private String confirmText; + private String inputLabel; + private String inputRequireMessage; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getInputLabel() { + return inputLabel; + } + + public void setInputLabel(String inputLabel) { + this.inputLabel = inputLabel; + } + + public String getInputRequireMessage() { + return inputRequireMessage; + } + + public void setInputRequireMessage(String inputRequireMessage) { + this.inputRequireMessage = inputRequireMessage; + } + + public String getDeleteConfirmModalTitle() { + return deleteConfirmModalTitle; + } + + public void setDeleteConfirmModalTitle(String deleteConfirmModalTitle) { + this.deleteConfirmModalTitle = deleteConfirmModalTitle; + } + + public String getDeleteConfirmModalText() { + return deleteConfirmModalText; + } + + public void setDeleteConfirmModalText(String deleteConfirmModalText) { + this.deleteConfirmModalText = deleteConfirmModalText; + } + + public String getDeleteConfirmationTextDescribe() { + return deleteConfirmationTextDescribe; + } + + public void setDeleteConfirmationTextDescribe(String deleteConfirmationTextDescribe) { + this.deleteConfirmationTextDescribe = deleteConfirmationTextDescribe; + } + + public String getDeleteConfirmationText() { + return deleteConfirmationText; + } + + public void setDeleteConfirmationText(String deleteConfirmationText) { + this.deleteConfirmationText = deleteConfirmationText; + } + } + + public static class DangerZoneTooltipTexts implements Serializable { + private String toolTipTitle; + private String toolTipPopConfirmText; + private String confirmText; + private String cancelText; + private String toolTipAvailable; + + public String getToolTipAvailable() { + return toolTipAvailable; + } + + public void setToolTipAvailable(String toolTipAvailable) { + this.toolTipAvailable = toolTipAvailable; + } + + public String getToolTipTitle() { + return toolTipTitle; + } + + public void setToolTipTitle(String toolTipTitle) { + this.toolTipTitle = toolTipTitle; + } + + public String getToolTipPopConfirmText() { + return toolTipPopConfirmText; + } + + public void setToolTipPopConfirmText(String toolTipPopConfirmText) { + this.toolTipPopConfirmText = toolTipPopConfirmText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java index 25e3664adc..82ca6b2082 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java @@ -79,6 +79,29 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple } configFeature.setMetaData(metaValues); } + if (feature.getConfirmationTexts() != null) { + List confirmationTextValues = new ArrayList<>(); + Feature.ConfirmationTexts confirmationText = feature.getConfirmationTexts(); + confirmationTextValues.add(confirmationText.getDeleteConfirmModalTitle()); + confirmationTextValues.add(confirmationText.getDeleteConfirmModalText()); + confirmationTextValues.add(confirmationText.getDeleteConfirmationTextDescribe()); + confirmationTextValues.add(confirmationText.getDeleteConfirmationText()); + confirmationTextValues.add(confirmationText.getCancelText()); + confirmationTextValues.add(confirmationText.getConfirmText()); + confirmationTextValues.add(confirmationText.getInputLabel()); + confirmationTextValues.add(confirmationText.getInputRequireMessage()); + configFeature.setConfirmationTexts(confirmationTextValues); + } + if (feature.getDangerZoneTooltipTexts() != null) { + List dangerZoneTextValues = new ArrayList<>(); + Feature.DangerZoneTooltipTexts dangerZoneText = feature.getDangerZoneTooltipTexts(); + dangerZoneTextValues.add(dangerZoneText.getToolTipTitle()); + dangerZoneTextValues.add(dangerZoneText.getToolTipPopConfirmText()); + dangerZoneTextValues.add(dangerZoneText.getConfirmText()); + dangerZoneTextValues.add(dangerZoneText.getCancelText()); + dangerZoneTextValues.add(dangerZoneText.getToolTipAvailable()); + configFeature.setDangerZoneTooltipTexts(dangerZoneTextValues); + } featureList.add(configFeature); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java new file mode 100644 index 0000000000..d3bf15f8e6 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "confirmationTexts", propOrder = { + "deleteConfirmModalTitle", + "deleteConfirmModalText", + "deleteConfirmationTextDescribe", + "deleteConfirmationText", + "cancelText", + "confirmText", + "inputLabel", + "inputRequireMessage" +}) +public class ConfirmationTexts { + + @XmlElement(name = "deleteConfirmModalTitle") + private String deleteConfirmModalTitle; + + @XmlElement(name = "deleteConfirmModalText") + private String deleteConfirmModalText; + + @XmlElement(name = "deleteConfirmationTextDescribe") + private String deleteConfirmationTextDescribe; + + @XmlElement(name = "deleteConfirmationText") + private String deleteConfirmationText; + + @XmlElement(name = "cancelText") + private String cancelText; + + @XmlElement(name = "confirmText") + private String confirmText; + + @XmlElement(name = "inputLabel") + private String inputLabel; + + @XmlElement(name = "inputRequireMessage") + private String inputRequireMessage; + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + + public String getInputRequireMessage() { + return inputRequireMessage; + } + + public void setInputRequireMessage(String inputRequireMessage) { + this.inputRequireMessage = inputRequireMessage; + } + + public String getInputLabel() { + return inputLabel; + } + + public void setInputLabel(String inputLabel) { + this.inputLabel = inputLabel; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getDeleteConfirmModalTitle() { + return deleteConfirmModalTitle; + } + + public void setDeleteConfirmModalTitle(String deleteConfirmModalTitle) { + this.deleteConfirmModalTitle = deleteConfirmModalTitle; + } + + public String getDeleteConfirmModalText() { + return deleteConfirmModalText; + } + + public void setDeleteConfirmModalText(String deleteConfirmModalText) { + this.deleteConfirmModalText = deleteConfirmModalText; + } + + public String getDeleteConfirmationTextDescribe() { + return deleteConfirmationTextDescribe; + } + + public void setDeleteConfirmationTextDescribe(String deleteConfirmationTextDescribe) { + this.deleteConfirmationTextDescribe = deleteConfirmationTextDescribe; + } + + public String getDeleteConfirmationText() { + return deleteConfirmationText; + } + + public void setDeleteConfirmationText(String deleteConfirmationText) { + this.deleteConfirmationText = deleteConfirmationText; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java new file mode 100644 index 0000000000..2a38729c99 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "dangerZoneTooltipTexts", propOrder = { + "toolTipTitle", + "toolTipPopConfirmText", + "confirmText", + "cancelText", + "toolTipAvailable" +}) +public class DangerZoneTooltipTexts { + + @XmlElement(name = "toolTipTitle") + private String toolTipTitle; + + @XmlElement(name = "toolTipPopConfirmText") + private String toolTipPopConfirmText; + + @XmlElement(name = "confirmText") + private String confirmText; + + @XmlElement(name = "cancelText") + private String cancelText; + + @XmlElement(name = "toolTipAvailable") + private String toolTipAvailable; + + public String getToolTipAvailable() { + return toolTipAvailable; + } + + public void setToolTipAvailable(String toolTipAvailable) { + this.toolTipAvailable = toolTipAvailable; + } + + public String getToolTipTitle() { + return toolTipTitle; + } + + public void setToolTipTitle(String toolTipTitle) { + this.toolTipTitle = toolTipTitle; + } + + public String getToolTipPopConfirmText() { + return toolTipPopConfirmText; + } + + public void setToolTipPopConfirmText(String toolTipPopConfirmText) { + this.toolTipPopConfirmText = toolTipPopConfirmText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java index 4f20701ef3..a8c32e621b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java @@ -47,7 +47,9 @@ import java.util.List; "description", "tooltip", "operation", - "metaData" + "metaData", + "confirmationTexts", + "dangerZoneTooltipTexts" }) public class Feature { @@ -73,6 +75,12 @@ public class Feature { @XmlElement(name = "Property", required = true) private List metaData; + @XmlElement(name = "ConfirmationTexts", required = false) + private List confirmationTexts; + + @XmlElement(name = "DangerZoneTooltipTexts", required = false) + private List dangerZoneTooltipTexts; + /** * Gets the value of the name property. * @@ -209,4 +217,20 @@ public class Feature { public void setType(String type) { this.type = type; } + + public List getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(List confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + + public List getDangerZoneTooltipTexts() { + return dangerZoneTooltipTexts; + } + + public void setDangerZoneTooltipTexts(List dangerZoneTooltipTexts) { + this.dangerZoneTooltipTexts = dangerZoneTooltipTexts; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java index 289b89e8a0..e7c9275cd5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java @@ -41,8 +41,10 @@ import javax.xml.bind.annotation.*; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Operation", propOrder = { - "params", - "metadata" + "params", + "metadata", + "confirmationTexts", + "tooltipTexts" }) public class Operation { @@ -58,6 +60,28 @@ public class Operation { @XmlAttribute(name = "icon") private String icon; + @XmlElement(name = "tooltipTexts", required = false) + private DangerZoneTooltipTexts tooltipTexts; + + @XmlElement(name = "confirmationTexts", required = false) + private ConfirmationTexts confirmationTexts; + + public DangerZoneTooltipTexts getTooltipTexts() { + return tooltipTexts; + } + + public void setTooltipTexts(DangerZoneTooltipTexts tooltipTexts) { + this.tooltipTexts = tooltipTexts; + } + + public ConfirmationTexts getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(ConfirmationTexts confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + public Params getParams() { return params; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java index 461eba7776..7b6a55e260 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java @@ -116,7 +116,32 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { operationMeta.put(UI_PARAMS, uiParams); operationMeta.put(FORM_PARAMS, formParams); } - + if (operation.getConfirmationTexts() != null) { + Feature.ConfirmationTexts confirmationTexts = new Feature.ConfirmationTexts(); + confirmationTexts.setDeleteConfirmModalTitle( + operation.getConfirmationTexts().getDeleteConfirmModalTitle()); + confirmationTexts.setDeleteConfirmModalText( + operation.getConfirmationTexts().getDeleteConfirmModalText()); + confirmationTexts.setDeleteConfirmationTextDescribe( + operation.getConfirmationTexts().getDeleteConfirmationTextDescribe()); + confirmationTexts.setDeleteConfirmationText( + operation.getConfirmationTexts().getDeleteConfirmationText()); + confirmationTexts.setCancelText(operation.getConfirmationTexts().getCancelText()); + confirmationTexts.setConfirmText(operation.getConfirmationTexts().getConfirmText()); + confirmationTexts.setInputLabel(operation.getConfirmationTexts().getInputLabel()); + confirmationTexts.setInputRequireMessage( + operation.getConfirmationTexts().getInputRequireMessage()); + deviceFeature.setConfirmationTexts(confirmationTexts); + } + if (operation.getTooltipTexts() != null) { + Feature.DangerZoneTooltipTexts tooltipTexts = new Feature.DangerZoneTooltipTexts(); + tooltipTexts.setToolTipTitle(operation.getTooltipTexts().getToolTipTitle()); + tooltipTexts.setToolTipPopConfirmText(operation.getTooltipTexts().getToolTipPopConfirmText()); + tooltipTexts.setConfirmText(operation.getTooltipTexts().getConfirmText()); + tooltipTexts.setCancelText(operation.getTooltipTexts().getCancelText()); + tooltipTexts.setToolTipAvailable(operation.getTooltipTexts().getToolTipAvailable()); + deviceFeature.setDangerZoneTooltipTexts(tooltipTexts); + } if (metadataEntries == null) { metadataEntries = new ArrayList<>(); }