diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/NextGenDMThumbnail.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/NextGenDMThumbnail.java deleted file mode 100644 index 49d6ec0cef..0000000000 --- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/NextGenDMThumbnail.java +++ /dev/null @@ -1,40 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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 com.adobe.cq.wcm.core.components.commons.editor.nextgendm; - -import org.osgi.annotation.versioning.ProviderType; - -@ProviderType -/** - * Thumbnails for Next Generation Dynamic Media Images. - */ -public interface NextGenDMThumbnail { - /** - * Get thumbnail source url for the next generation dynamic media image. - * @return {String} - the url of image thumbnail. - */ - default public String getSrc() { - return null; - } - - /** - * Get thumbnail alternative text for the next generation dynamic media image. - * @return {String - the alternative text. - */ - default public String getAlt() { - return null; - } -} diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/package-info.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/package-info.java deleted file mode 100644 index 9aab89a84d..0000000000 --- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/commons/editor/nextgendm/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -/** - * This package defines next generation dynamic media image thumbnail model. - */ -@Version("1.0.0") -package com.adobe.cq.wcm.core.components.commons.editor.nextgendm; - -import org.osgi.annotation.versioning.Version; diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImpl.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImpl.java deleted file mode 100644 index bccd98cd7c..0000000000 --- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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 com.adobe.cq.wcm.core.components.internal.models.v3; - -import javax.annotation.PostConstruct; - -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ValueMap; -import org.apache.sling.models.annotations.Exporter; -import org.apache.sling.models.annotations.Model; -import org.apache.sling.models.annotations.Optional; -import org.apache.sling.models.annotations.injectorspecific.OSGiService; -import org.apache.sling.models.annotations.injectorspecific.Self; -import org.apache.sling.models.annotations.injectorspecific.SlingObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.adobe.cq.export.json.ExporterConstants; -import com.adobe.cq.ui.wcm.commons.config.NextGenDynamicMediaConfig; -import com.adobe.cq.wcm.core.components.commons.editor.nextgendm.NextGenDMThumbnail; - -import static com.adobe.cq.wcm.core.components.internal.models.v3.ImageImpl.isNgdmImageReference; - -@Model(adaptables = SlingHttpServletRequest.class, - adapters = {NextGenDMThumbnail.class}, - resourceType = NextGenDMThumbnailImpl.RESOURCE_TYPE) -@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) -public class NextGenDMThumbnailImpl implements NextGenDMThumbnail { - - private static final Logger LOGGER = LoggerFactory.getLogger(NextGenDMThumbnailImpl.class); - protected static final String RESOURCE_TYPE = "core/wcm/components/image/v3/image/nextgendmthumbnail"; - - /** - * The current resource. - */ - @SlingObject - protected Resource resource; - - @Self - private SlingHttpServletRequest request; - - @OSGiService - @Optional - private NextGenDynamicMediaConfig nextGenDynamicMediaConfig; - - private String componentPath; - - private String src; - - private String altText = ""; - - @PostConstruct - private void initModel() { - componentPath = request.getRequestPathInfo().getSuffix(); - Resource component = request.getResourceResolver().getResource(componentPath); - ValueMap properties = component.getValueMap(); - String fileReference = properties.get("fileReference", String.class); - String smartCrop = properties.get("smartCropRendition", String.class); - ValueMap configs = resource.getValueMap(); - int width = configs.get("width", 480); - int height = configs.get("height", 480); - altText = configs.get("alt", "image thumbnail"); - if (isNgdmImageReference(fileReference)) { - NextGenDMImageURIBuilder builder = new NextGenDMImageURIBuilder(nextGenDynamicMediaConfig, fileReference) - .withPreferWebp(true) - .withWidth(width) - .withHeight(height); - if (StringUtils.isNotEmpty(smartCrop)) { - builder.withSmartCrop(smartCrop); - } - this.src = builder.build(); - } - } - - @Override - public String getSrc() { - return src; - } - - @Override - public String getAlt() { - return altText; - } -} diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/editor/dialog/nextgendm/NextGenDMThumbnailTest.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/editor/dialog/nextgendm/NextGenDMThumbnailTest.java deleted file mode 100644 index 75c52c13b5..0000000000 --- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/commons/editor/dialog/nextgendm/NextGenDMThumbnailTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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 com.adobe.cq.wcm.core.components.commons.editor.dialog.nextgendm; - -import org.junit.jupiter.api.Test; - -import com.adobe.cq.wcm.core.components.commons.editor.nextgendm.NextGenDMThumbnail; - -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.Mockito.spy; - -public class NextGenDMThumbnailTest { - @Test - void testNextGenThumbnailDefaultMethods() { - NextGenDMThumbnail nextGenDMThumbnail = spy(NextGenDMThumbnail.class); - assertNull(nextGenDMThumbnail.getAlt()); - assertNull(nextGenDMThumbnail.getSrc()); - } -} diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImplTest.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImplTest.java deleted file mode 100644 index df8ce8c1af..0000000000 --- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMThumbnailImplTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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 com.adobe.cq.wcm.core.components.internal.models.v3; - -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ValueMap; -import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoSettings; -import org.mockito.quality.Strictness; - -import com.adobe.cq.wcm.core.components.Utils; -import com.adobe.cq.wcm.core.components.context.CoreComponentTestContext; -import com.adobe.cq.wcm.core.components.commons.editor.nextgendm.NextGenDMThumbnail; -import com.adobe.cq.wcm.core.components.testing.MockNextGenDynamicMediaConfig; -import io.wcm.testing.mock.aem.junit5.AemContext; -import io.wcm.testing.mock.aem.junit5.AemContextExtension; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -@ExtendWith(AemContextExtension.class) -public class NextGenDMThumbnailImplTest { - protected final AemContext context = CoreComponentTestContext.newAemContext(); - - private static final String NGDM_IMAGE_PATH = "/content/ngdm_test_page/jcr:content/root/ngdm_test_page_image1"; - - protected static final String TEST_CONTENT_ROOT = "/content"; - - protected static final String TEST_APPS_ROOT = "/apps"; - private static final String TEST_ASSET_ID = "urn:aaid:aem:e82c3c87-1453-48f5-844b-1822fb610911"; - private static final String TEST_SEO_NAME = "cutfruits.png"; - private static final String IMAGE_DELIVERY_BASE_PATH = "/adobe/dynamicmedia/deliver/{asset-id}/{seo-name}.{format}"; - private static final String REPOSITORY_ID = "delivery-pxxxx-exxxx-cmstg.adobeaemcloud.com"; - private static final String BASE_URI_TEMPLATE = "https://" + REPOSITORY_ID + IMAGE_DELIVERY_BASE_PATH; - - private static final String altText = "Smart crop preview"; - - private static final String BASE_URI = BASE_URI_TEMPLATE.replace("{asset-id}", TEST_ASSET_ID).replace("{seo-name}.{format}", TEST_SEO_NAME); - - - @Mock - private Resource resource; - @Mock - private ValueMap valueMap; - - private NextGenDMThumbnail nextGenDMThumbnail; - - - @BeforeEach - public void setUp() { - context.load().json("/image/v3" + CoreComponentTestContext.TEST_CONTENT_JSON, TEST_CONTENT_ROOT); - context.load().json("/image/v3" + CoreComponentTestContext.TEST_APPS_JSON, TEST_APPS_ROOT); - - MockNextGenDynamicMediaConfig config = new MockNextGenDynamicMediaConfig(); - config.setEnabled(true); - config.setRepositoryId(REPOSITORY_ID); - context.contentPolicyMapping(NextGenDMThumbnailImpl.RESOURCE_TYPE); - context.requestPathInfo().setSuffix(NGDM_IMAGE_PATH); - context.registerInjectActivateService(config); - - nextGenDMThumbnail = getNextGenImageThumbnail("/apps/ngdm-smartcropthumbnail"); - } - - @Test - @MockitoSettings(strictness = Strictness.LENIENT) - public void testThumbnailSrc() { - assertTrue(nextGenDMThumbnail.getSrc().contains(BASE_URI)); - assertTrue(nextGenDMThumbnail.getSrc().contains("width=260")); - assertTrue(nextGenDMThumbnail.getSrc().contains("height=260")); - } - - @Test - @MockitoSettings(strictness = Strictness.LENIENT) - public void testThumbnailAlt() { - assertTrue(nextGenDMThumbnail.getAlt().equals(altText)); - } - - protected NextGenDMThumbnail getNextGenImageThumbnail(String resourcePath) { - Utils.enableDataLayer(context, true); - context.currentResource(resourcePath); - MockSlingHttpServletRequest request = context.request(); - return request.adaptTo(NextGenDMThumbnail.class); - } -} diff --git a/bundles/core/src/test/resources/image/v3/test-apps.json b/bundles/core/src/test/resources/image/v3/test-apps.json index 091c590f11..7eaa771a2d 100644 --- a/bundles/core/src/test/resources/image/v3/test-apps.json +++ b/bundles/core/src/test/resources/image/v3/test-apps.json @@ -12,12 +12,5 @@ "componentGroup": ".core-wcm" } } - }, - "ngdm-smartcropthumbnail": { - "jcr:primaryType": "nt:unstructured", - "height": 260, - "alt": "Smart crop preview", - "width": 260, - "sling:resourceType": "core/wcm/components/image/v3/image/nextgendmthumbnail" } } diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/.content.xml b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/.content.xml deleted file mode 100644 index 66512792da..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/.content.xml +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css.txt b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css.txt deleted file mode 100644 index 107f114350..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css.txt +++ /dev/null @@ -1,18 +0,0 @@ -############################################################################### -# Copyright 2023 Adobe -# -# Licensed 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. -############################################################################### - -#base=css -smartcrop.css \ No newline at end of file diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css/smartcrop.css b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css/smartcrop.css deleted file mode 100644 index eca2eacc21..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/css/smartcrop.css +++ /dev/null @@ -1,64 +0,0 @@ -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -.smartcrop-preview-column { - width: 290px; - height: 290px; - background: #e9e9e9; - text-align: center; - border-radius: .25rem; -} - -.smartcropdialog { - padding-top: .9375rem; - padding-bottom: .9375rem; -} - -.cq-dialog-floating .cq-dialog-content.smartcropdialog { - height: auto; -} - -.cq-dialog-content.smartcropdialog .coral-FixedColumn.smartcrop-dialog-columns .coral-FixedColumn-column.smartcrop-options-column { - width: 235px; - margin-left: .81rem; - margin-right: 0; -} - -.smartcrop-ratio-field { - display: inline-block; -} - -.smartcrop-ratio-fields-container { - display: inline-flex; -} - -.smartcrop-ratio-fields-container .smartcrop-ratio-field.smartcrop-ratio-left, .smartcrop-ratio-fields-container .smartcrop-ratio-field.smartcrop-ratio-right { - width: 5.7rem; - display: inline-block; -} - -.smartcrop-ratio-fields-container .smartcrop-ratio-field [is="coral-button"] { - display: none; -} - -.smartcrop-ratio-fields-container .smartcrop-ratio-field [is="coral-textfield"] { - min-width: 3rem; - width: 5.7rem; - border-radius: 0; -} - -.smartcrop-ratio-field.smartcrop-ratio-swap { - min-width: 3rem; -} diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js.txt b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js.txt deleted file mode 100644 index 4126a2fa95..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js.txt +++ /dev/null @@ -1,21 +0,0 @@ -############################################################################### -# Copyright 2023 Adobe -# -# Licensed 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. -############################################################################### - -#base=js -namespace.js -smartcropdialog.js -smartcropaction.js -smartcroppreview.js diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/namespace.js b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/namespace.js deleted file mode 100644 index 38841a7113..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/namespace.js +++ /dev/null @@ -1,25 +0,0 @@ - -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -(function() { - "use strict"; - - window.CQ = window.CQ || {}; - window.CQ.CoreComponents = window.CQ.CoreComponents || {}; - window.CQ.CoreComponents.image = window.CQ.CoreComponents.image || {}; - window.CQ.CoreComponents.image.v3 = window.CQ.CoreComponents.image.v3 || {}; - window.CQ.CoreComponents.image.v3.actions = {}; -})(); diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropaction.js b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropaction.js deleted file mode 100644 index 7dbe516030..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropaction.js +++ /dev/null @@ -1,39 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -/* global CQ */ -(function($, ns, authorNs) { - "use strict"; - ns.image.v3.actions.smartCrop = function() { - const editable = this; - if (this.authorNs) { - authorNs.DialogFrame.openDialog(new ns.image.v3.smartCropDialog(editable)); - } - }; - - ns.image.v3.actions.smartCrop.condition = function(editable) { - if (this.authorNs) { - return authorNs.pageInfoHelper.canModify() && hasNGDMSmartCropAction(editable) && isNGDMImage(editable); - } - }; - - function hasNGDMSmartCropAction(editable) { - return editable.config.editConfig.actions.some((action) => (typeof action === "object" && action.name === "ngdm-smartcrop")); - } - - function isNGDMImage(editable) { - return ($(editable.dom).find(".cq-dd-image[data-cmp-filereference^='/urn:']").length > 0); - } -})(jQuery, CQ.CoreComponents, Granite.author); diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropdialog.js b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropdialog.js deleted file mode 100644 index 564d2dcb3a..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcropdialog.js +++ /dev/null @@ -1,93 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -(function($, ns, components, channel) { - "use strict"; - - components.image.v3.smartCropDialog = function(editable) { - this.editable = editable; - }; - - ns.util.inherits(components.image.v3.smartCropDialog, ns.ui.Dialog); - - components.image.v3.smartCropDialog.prototype.getConfig = function() { - return { - src: `/mnt/overlay/core/wcm/components/image/v3/image/smartcropdialog.html${this.editable.path}`, - loadingMode: this.editable.config.dialogLoadingMode, - layout: this.editable.config.dialogLayout || "auto" - }; - }; - - components.image.v3.smartCropDialog.prototype.getRequestData = function() { - return { - resourceType: this.editable.type - }; - }; - - /** - * Success handler. - * @function Granite.author.edit.Dialog#onSuccess - * - * @fires Document#cq-persistence-after-update - * - * @param {jQuery} currentDialog The jQuery element representing the current dialog - * @param {jQuery} currentFloatingDialog The jQuery element representing the current floating dialog - */ - components.image.v3.smartCropDialog.prototype.onSuccess = function(currentDialog, currentFloatingDialog) { - const self = this; - let properties = {}; - - if (currentFloatingDialog) { - const propertiesArray = currentFloatingDialog.serializeArray(); - - propertiesArray.forEach(function(propertyNameValue) { - properties[propertyNameValue.name] = propertyNameValue.value; - }); - } - - channel.trigger("cq-persistence-after-update", [this.editable, properties]); - - const history = ns.history.Manager.getHistory(); - history && history.clear(); - - // refresh the editable and recreate its overlay - ns.edit.EditableActions.REFRESH.execute(this.editable) - .then(function() { - ns.selection.select(self.editable); - self.editable.afterEdit(); - - const editableParent = ns.editables.getParent(self.editable); - editableParent && editableParent.afterChildEdit(self.editable); - }); - }; - - components.image.v3.smartCropDialog.prototype.onFocus = function() { - if (ns.EditorFrame.editableToolbar && ns.EditorFrame.editableToolbar.close) { - ns.EditorFrame.editableToolbar.close(); - } - }; - - components.image.v3.smartCropDialog.prototype.onOpen = function() { - ns.history.Manager.setBlocked(true); - - }; - - components.image.v3.smartCropDialog.prototype.onClose = function() { - if (this.editable && this.editable.overlay && this.editable.overlay.dom) { - this.editable.overlay.dom.focus(); - } - ns.history.Manager.setBlocked(false); - }; -}(jQuery, Granite.author, window.CQ.CoreComponents, jQuery(document))); diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcroppreview.js b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcroppreview.js deleted file mode 100644 index 2f9571b992..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/ngdmsmartcrop/js/smartcroppreview.js +++ /dev/null @@ -1,106 +0,0 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Copyright 2023 Adobe - ~ - ~ Licensed 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -(function($, channel) { - "use strict"; - - const selectorLeftInput = ".smartcrop-ratio-left"; - const selectorRightInput = ".smartcrop-ratio-right"; - const selectorSmartCropSelect = ".image-v3-dialog-smartcrop-select"; - - channel.on("change", ".image-v3-dialog-smartcrop-select", function(event, from) { - let newUrl; - const value = this.value; - const $dialog = $(this).closest("coral-dialog.cq-Dialog"); - const $ele = $dialog.find(".ngdm-smartcrop-thumbnail"); - const src = $ele.attr("src"); - if (src) { - const cropStr = value === "" ? "" : `&crop=${value},smart`; - if (src.search(/crop=.+,smart/g) > -1) { - newUrl = src.replaceAll(/&crop=.+,smart/g, cropStr); - } else if (value !== "") { - newUrl = src + "&" + cropStr; - } - $("coral-dialog.cq-Dialog .ngdm-smartcrop-thumbnail").attr("src", newUrl); - } - - if (!(from && from === "from-input-fields")) { - const newLeft = value !== "" ? value.split(":")[0] : ""; - const newRight = value !== "" ? value.split(":")[1] : ""; - - const $left = $(selectorLeftInput); - const $right = $(selectorRightInput); - const leftValue = $left.val(); - const rightValue = $right.val(); - if (newLeft !== leftValue || newRight !== rightValue) { - $left.val(newLeft); - $right.val(newRight); - } - } - }); - - channel.on("click", "button.smartcrop-ratio-swap", function() { - const $left = $(selectorLeftInput); - const $right = $(selectorRightInput); - const leftValue = $left.val(); - const rightValue = $right.val(); - $left.val(rightValue); - $right.val(leftValue); - Coral.commons.nextFrame(function() { - $(selectorRightInput).trigger("change"); - }); - - }); - - function setValueToSelect(value) { - const $smartCropSelect = $(selectorSmartCropSelect); - $smartCropSelect.val(value); - // set custom value - if ($smartCropSelect.val() === "") { - $smartCropSelect[0].items.getAll()[0].value = value; - $smartCropSelect.val(value); - } - } - - channel.on("change", `${selectorLeftInput}, ${selectorRightInput}`, function() { - const leftValue = $(selectorLeftInput).val(); - const rightValue = $(selectorRightInput).val(); - let value = ""; - if (leftValue !== "" && rightValue !== "" && leftValue > 0 && rightValue > 0) { - value = leftValue + ":" + rightValue; - setValueToSelect(value); - } else if (leftValue === "" && rightValue === "") { - // clear crop and show original - setValueToSelect(""); - } - Coral.commons.nextFrame(function() { - $(selectorSmartCropSelect).trigger("change", ["from-input-fields"]); - }); - }); - - channel.on("foundation-contentloaded", function() { - Coral.commons.ready($(".smartcrop-ratio-field"), function() { - const $smartCropVal = $(".smartcrop-ratio-value"); - let value = $smartCropVal.val(); - $smartCropVal.removeAttr("name"); - if (value && value !== "") { - $(selectorLeftInput).attr("value", value.split(":")[0]); - $(selectorRightInput).attr("value", value.split(":")[1]); - } - setValueToSelect(value); - }); - }); - -})(jQuery, jQuery(document)); diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/nextgendmthumbnail/nextgendmthumbnail.html b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/nextgendmthumbnail/nextgendmthumbnail.html deleted file mode 100644 index 865e19a109..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/nextgendmthumbnail/nextgendmthumbnail.html +++ /dev/null @@ -1,18 +0,0 @@ - - - ${thumbnail.alt} - diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/smartcropdialog/.content.xml b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/smartcropdialog/.content.xml deleted file mode 100644 index 3f756d49fe..0000000000 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/smartcropdialog/.content.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testing/it/e2e-selenium-utils/src/main/java/com/adobe/cq/wcm/core/components/it/seljup/util/components/image/BaseImage.java b/testing/it/e2e-selenium-utils/src/main/java/com/adobe/cq/wcm/core/components/it/seljup/util/components/image/BaseImage.java index 4be1b95064..2115456a31 100644 --- a/testing/it/e2e-selenium-utils/src/main/java/com/adobe/cq/wcm/core/components/it/seljup/util/components/image/BaseImage.java +++ b/testing/it/e2e-selenium-utils/src/main/java/com/adobe/cq/wcm/core/components/it/seljup/util/components/image/BaseImage.java @@ -16,8 +16,6 @@ package com.adobe.cq.wcm.core.components.it.seljup.util.components.image; import com.adobe.cq.testing.selenium.pagewidgets.common.BaseComponent; -import com.adobe.cq.wcm.core.components.it.seljup.util.Commons; -import com.adobe.cq.wcm.core.components.it.seljup.util.constant.RequestConstants; import com.codeborne.selenide.WebDriverRunner; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -28,7 +26,6 @@ import static com.codeborne.selenide.Selenide.$; -import static org.junit.jupiter.api.Assertions.assertTrue; public class BaseImage extends BaseComponent { private static String assetPath = "[name='assetfilter_image_path']"; @@ -41,7 +38,6 @@ public class BaseImage extends BaseComponent { private static String imageLink = ".cmp-image__link"; - private static String element = ".cmp-image"; private static String imageElement = ".cmp-image__image"; public static String mapElement = "[data-cmp-hook-image='map']"; public static String areaElement = "[data-cmp-hook-image='area']"; @@ -51,16 +47,6 @@ public class BaseImage extends BaseComponent { public static String imageWithAltText = ".cmp-image__image[src*='%s/_jcr_content/root/responsivegrid/image.coreimg.'][alt='%s']"; public static String imageWithFileName = ".cmp-image__image[src*='/%s']"; public static String imageWithSmartCrop = ".cmp-image__image[src*='/smartcrop=%s']"; - private static final String ngdmSmartCropButton = "button.cq-editable-action[data-action='ngdm-smartcrop']"; - private static final String ngdmSmartCropDialog = ".smartcropdialog"; - private static final String ngdmSmartCropAspectRatioSelector = ".image-v3-dialog-smartcrop-select button"; - private static final String ngdmSmartCropAspectRatioSelectorOption = "coral-selectlist coral-selectlist-item[value='%s']"; - private static final String ngdmSmartCropPreview = ".ngdm-smartcrop-thumbnail"; - private static final String ngdmSmartCropAspectRatioInputLeft = ".smartcrop-ratio-left input"; - private static final String ngdmSmartCropAspectRatioInputRight = ".smartcrop-ratio-right input"; - private static final String ngdmSmartCropAspectRatioFlipButton = ".smartcrop-ratio-swap"; - - private static final String ngdmSmartCropDialogSaveButton = ".cq-dialog-submit"; protected String title; protected String imgWithAltText; @@ -184,66 +170,4 @@ public boolean checkLinkPresentWithTarget(String link, String target) { return $("a[href='" + link + "'][target='" + target + "']").isDisplayed(); } - public void openNGDMSmartCropDialog(String compPath) throws InterruptedException { - String component = "[data-type='Editable'][data-path='" + compPath + "']"; - final WebDriver webDriver = WebDriverRunner.getWebDriver(); - WebElement element = webDriver.findElement(By.cssSelector(component)); - ((JavascriptExecutor) webDriver).executeScript("arguments[0].setAttribute('style', 'width:100%;height:5px');", element); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - $(component).click(); - assertTrue(this.isNGDMSmartCropButtonVisible(), "NextGen SmartCrop button should be present."); - this.clickNGDMSmartCropButton(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - assertTrue(this.isNGDMSmartCropDialogVisible(), "Smart Crop dialog should be visible."); - } - - public void selectAspectRatioInNGDMSmartCropDialog(String ratio) throws InterruptedException { - assertTrue($(ngdmSmartCropAspectRatioSelector).isDisplayed(), "Aspect Ration selector should be visible."); - $(ngdmSmartCropAspectRatioSelector).click(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - assertTrue($(String.format(ngdmSmartCropAspectRatioSelectorOption, ratio)).isDisplayed(), "Aspect Ratio option should be visible for : " + ratio); - $(String.format(ngdmSmartCropAspectRatioSelectorOption, ratio)).click(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - assertTrue($(ngdmSmartCropPreview).isDisplayed(), "Smart Crop preview image should be visible."); - validateNGDMAspectRationSelectorLabel("Wide Landscape"); - } - - public void validateNGDMSmartCropInImageUrl(String ratio) { - String src = $(ngdmSmartCropPreview).getAttribute("src"); - assertTrue(src.contains("crop=" + ratio + ",smart"), "Image src should have smart crop parameters."); - } - - public void addCustomAspectRatioInNGDMSmartCropDialog(String ratio) throws InterruptedException { - String[] values = ratio.split(":"); - $(ngdmSmartCropAspectRatioInputLeft).setValue(values[0]); - $(ngdmSmartCropAspectRatioInputRight).setValue(values[1]); - $(ngdmSmartCropPreview).click(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - validateNGDMAspectRationSelectorLabel("Custom"); - } - - public boolean isNGDMSmartCropButtonVisible() { - return $(ngdmSmartCropButton).isDisplayed(); - } - - public void clickNGDMSmartCropButton() { - $(ngdmSmartCropButton).click(); - } - - public boolean isNGDMSmartCropDialogVisible() { - return $(ngdmSmartCropDialog).isDisplayed(); - } - - public void flipNGDMSmartCropDialogAspectRatios() throws InterruptedException { - $(ngdmSmartCropAspectRatioFlipButton).click(); - } - - public void validateNGDMAspectRationSelectorLabel(String label) { - assertTrue(label.equals($(ngdmSmartCropAspectRatioSelector).getText()), "Aspect Ration " + label + " should be selected."); - } - - public void saveNGDMSmartCropDialog() { - $(ngdmSmartCropDialogSaveButton).click(); - } - } diff --git a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java index 9cd75e7c17..141ced5839 100644 --- a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java +++ b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java @@ -502,50 +502,6 @@ public void testSetLinkWithTarget() throws TimeoutException, InterruptedExceptio assertTrue(image.checkLinkPresentWithTarget(link, target),"Title with link " + link + " and target "+ target + " should be present"); } - public void testNGDMSmartCropDialogImageV3() throws TimeoutException, InterruptedException, ClientException { - setUpNGDMImage(); - image.openNGDMSmartCropDialog(compPath); - } - - public void testNGDMSmartCropDialogImageV3_aspectRatioSelection() throws TimeoutException, InterruptedException, ClientException { - setUpNGDMImage(); - image.openNGDMSmartCropDialog(compPath); - image.selectAspectRatioInNGDMSmartCropDialog("5:3"); - image.validateNGDMSmartCropInImageUrl("5:3"); - image.saveNGDMSmartCropDialog(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - image.openNGDMSmartCropDialog(compPath); - image.validateNGDMAspectRationSelectorLabel("Wide Landscape"); - image.validateNGDMSmartCropInImageUrl("5:3"); - } - - public void testNGDMSmartCropDialogImageV3_customAspectRatio() throws TimeoutException, InterruptedException, ClientException { - setUpNGDMImage(); - image.openNGDMSmartCropDialog(compPath); - image.addCustomAspectRatioInNGDMSmartCropDialog("2:7"); - image.validateNGDMSmartCropInImageUrl("2:7"); - image.saveNGDMSmartCropDialog(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - image.openNGDMSmartCropDialog(compPath); - image.validateNGDMAspectRationSelectorLabel("Custom"); - image.validateNGDMSmartCropInImageUrl("2:7"); - } - - public void testNGDMSmartCropDialogImageV3_aspectRatioFlip() throws TimeoutException, InterruptedException, ClientException { - setUpNGDMImage(); - image.openNGDMSmartCropDialog(compPath); - image.selectAspectRatioInNGDMSmartCropDialog("5:3"); - image.validateNGDMSmartCropInImageUrl("5:3"); - image.flipNGDMSmartCropDialogAspectRatios(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - image.validateNGDMAspectRationSelectorLabel("Custom"); - image.validateNGDMSmartCropInImageUrl("3:5"); - image.flipNGDMSmartCropDialogAspectRatios(); - Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); - image.validateNGDMSmartCropInImageUrl("5:3"); - image.validateNGDMAspectRationSelectorLabel("Wide Landscape"); - } - public void testSmartCropOnNGDMImageV3(String cropName) throws TimeoutException, InterruptedException, ClientException { setUpNGDMImage(); Commons.openEditDialog(editorPage, compPath); diff --git a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java index ecdcf3d90b..717c00fbeb 100644 --- a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java +++ b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java @@ -244,42 +244,6 @@ public void testSetAssetWithoutDescription() throws TimeoutException, Interrupte imageTests.testSetAssetWithoutDescriptionV3(); } - @Tag("IgnoreOnSDK") - @Tag("IgnoreOn65") - @Test - @Ignore - @DisplayName("Test : NextGen DM image smart crop dialog.") - public void testSmartCropDialogOnNGDMImageV3() throws TimeoutException, InterruptedException, ClientException { - imageTests.testNGDMSmartCropDialogImageV3(); - } - - @Tag("IgnoreOnSDK") - @Tag("IgnoreOn65") - @Test - @Ignore - @DisplayName("Test : NextGen DM image smart crop - select aspect ratio from list.") - public void testSmartCropDialogOnNGDMImageV3_aspectRatioSelection() throws TimeoutException, InterruptedException, ClientException { - imageTests.testNGDMSmartCropDialogImageV3_aspectRatioSelection(); - } - - @Tag("IgnoreOnSDK") - @Tag("IgnoreOn65") - @Test - @Ignore - @DisplayName("Test : NextGen DM image smart crop - select custom aspect ratio.") - public void testSmartCropDialogOnNGDMImageV3_customAspectRatio() throws TimeoutException, InterruptedException, ClientException { - imageTests.testNGDMSmartCropDialogImageV3_customAspectRatio(); - } - - @Tag("IgnoreOnSDK") - @Tag("IgnoreOn65") - @Test - @Ignore - @DisplayName("Test : NextGen DM image smart crop - flip aspect ratio.") - public void testSmartCropDialogOnNGDMImageV3_flipAspectRatio() throws TimeoutException, InterruptedException, ClientException { - imageTests.testNGDMSmartCropDialogImageV3_aspectRatioFlip(); - } - @Tag("IgnoreOnSDK") @Test @DisplayName("Test : NextGen DM image smart crop : large crop.")