-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASSETS-33747 - named smartcrop in image core v3 component powered by …
…fastly (#2698) * Instead of fastly smartcrops, expect named smartcrops in delivery URLs. * add editor code to render image through delivery URL and support smartcrop. * @trivial fix linting errors. * Show smartcrop renditions group even if DM is disabled but polaris is enabled. * Update code to also show dynamicmedia group when dialog is loaded with remote asset. * Make dependency on clientbuilderfactory optional and check for null. This is to avoid rewriting/fixing all Image test cases. * Minor bug fixes. * Fix test cases. * @trivial Fix existing test cases. * Review comments. Add a separate test case for smartcrop. Add a failing testcase for auto smartcrop. * @trivial Hide the smartcrop option if remote asset does not have smartcrops. * Add test cases for srcset and responsehandler code. * @trivial Move the code to show smartcrop dropdown only after fetching the metadata. * @trivial Fix eslint error. --------- Co-authored-by: Levente Sántha <levente@adobe.com> * ASSETS-33747 named smartcrop in image core v3 component Incorporate review comments. * @trivial review comments. * ASSETS-33747 - named smartcrop in image core v3 component * fixed unit test failures * @trivial Review comments. * Enable ES6 for image editor client library. * ASSETS-33747 named smartcrop in image core v3 component powered by fastly Auto smartcrop for remote assets should not depend on whether widths is configured or not. * Fix the IT and remove the button for fastly smartcrop which is no longer supported. * @trivial Update as per code scanning. * Add selenium test case for smart crop functionality. * @trivial fix test cases. --------- Co-authored-by: Levente Sántha <levente@adobe.com>
- Loading branch information
Showing
27 changed files
with
509 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...dobe/cq/wcm/core/components/internal/models/v3/NextGenDMSrcsetBuilderResponseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2024 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.http.HttpEntity; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.HttpStatus; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.util.EntityUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.IOException; | ||
|
||
public class NextGenDMSrcsetBuilderResponseHandler implements ResponseHandler<String> { | ||
|
||
@Override | ||
public String handleResponse(final @NotNull HttpResponse response) throws IOException { | ||
//Get the status of the response | ||
String responseEntity = ""; | ||
int status = response.getStatusLine().getStatusCode(); | ||
if (status == HttpStatus.SC_OK) { | ||
HttpEntity entity = response.getEntity(); | ||
if (entity != null) { | ||
responseEntity = EntityUtils.toString(entity); | ||
} | ||
} | ||
return responseEntity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...in/java/com/adobe/cq/wcm/core/components/internal/servlets/NGDMEnableRenderCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2024 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.servlets; | ||
|
||
import com.adobe.cq.ui.wcm.commons.config.NextGenDynamicMediaConfig; | ||
import com.adobe.granite.ui.components.rendercondition.RenderCondition; | ||
import com.adobe.granite.ui.components.rendercondition.SimpleRenderCondition; | ||
import java.io.IOException; | ||
import javax.servlet.Servlet; | ||
import javax.servlet.ServletException; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.sling.api.SlingHttpServletRequest; | ||
import org.apache.sling.api.SlingHttpServletResponse; | ||
import org.apache.sling.api.servlets.ServletResolverConstants; | ||
import org.apache.sling.api.servlets.SlingSafeMethodsServlet; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
import org.osgi.service.component.annotations.ReferenceCardinality; | ||
import org.osgi.service.component.annotations.ReferencePolicyOption; | ||
|
||
@Component( | ||
service = { Servlet.class }, | ||
property = { | ||
ServletResolverConstants.SLING_SERVLET_METHODS + "=GET", | ||
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=core/wcm/components/rendercondition/isNGDMEnabled" | ||
} | ||
) | ||
public class NGDMEnableRenderCondition extends SlingSafeMethodsServlet { | ||
|
||
@Reference(cardinality= ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY) | ||
private NextGenDynamicMediaConfig nextGenDynamicMediaConfig; | ||
|
||
@Override | ||
protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) | ||
throws ServletException, IOException { | ||
|
||
boolean isNGDMEnabled = false; | ||
if (nextGenDynamicMediaConfig != null && nextGenDynamicMediaConfig.enabled() && | ||
StringUtils.isNotBlank(nextGenDynamicMediaConfig.getRepositoryId())) { | ||
isNGDMEnabled = true; | ||
} | ||
|
||
request.setAttribute(RenderCondition.class.getName(), new SimpleRenderCondition(isNGDMEnabled)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.