Skip to content

Commit 3facf32

Browse files
authored
CIF-1382 - Create the Core CIF Components library pages - product com… (#267)
* CIF-1382 - Create the Core CIF Components library pages - product component - add proxy product component for the library - add a `page` component that adds the store-view and graphql endpoint for the client-side code - add JSON mock response and images for the product component * CQ-0: added self-signed cert rejection workaround
1 parent 6e79f7f commit 3facf32

File tree

78 files changed

+802
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+802
-321
lines changed

examples/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You can install all 3 artifacts by running `mvn clean install -PautoInstallPacka
2222
## Required configuration
2323

2424
The mock GraphQL server can only serve content via HTTPS because our GraphQL client does not support non-secure connections for security reasons. This means you have to enable HTTPS on your AEM instance if you want to install and use the mock server. To do this, simply follow the [following documentation](https://docs.adobe.com/content/help/en/experience-manager-65/administering/security/ssl-by-default.html).
25+
If the self-signed certificate gets rejected by the browser, try adding it to the OS keychain and mark it as trusted.
2526

2627
You must also enable anonymous access to the mock GraphQL server which will by defaut receive its requests on `https://localhost:8443/apps/cif-components-examples/graphql`. To do that, do the following:
2728
* In the AEM system configuration console, look for `Apache Sling Authentication Service`
@@ -53,4 +54,4 @@ With the less compiler (install it with `npm install -g less`), execute the foll
5354

5455
`lessc --verbose --math=strict venia.less venia.css`
5556

56-
This generates the `venia.css` file that we use for the layout/design of the examples.
57+
This generates the `venia.css` file that we use for the layout/design of the examples.

examples/bundle/src/main/resources/graphql/magento-graphql-products.json

Lines changed: 312 additions & 312 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"data": {
33
"storeConfig": {
4-
"secure_base_media_url": "https://test-url.magentosite.cloud/pub/media/"
4+
"secure_base_media_url": "/content/dam/core-components-examples/library/cif-sample-assets/"
55
}
66
}
77
}

examples/bundle/src/test/java/com/adobe/cq/commerce/core/examples/servlets/GraphqlServletTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
import com.adobe.cq.commerce.core.components.models.categorylist.FeaturedCategoryList;
4343
import com.adobe.cq.commerce.core.components.models.common.ProductListItem;
4444
import com.adobe.cq.commerce.core.components.models.navigation.Navigation;
45+
import com.adobe.cq.commerce.core.components.models.product.Asset;
4546
import com.adobe.cq.commerce.core.components.models.product.Product;
47+
import com.adobe.cq.commerce.core.components.models.product.Variant;
4648
import com.adobe.cq.commerce.core.components.models.productcarousel.ProductCarousel;
4749
import com.adobe.cq.commerce.core.components.models.productlist.ProductList;
4850
import com.adobe.cq.commerce.core.components.models.productteaser.ProductTeaser;
@@ -105,6 +107,8 @@ private static AemContext createContext(String contentPath) {
105107
private static final String FEATURED_CATEGORY_LIST_RESOURCE = PAGE + "/jcr:content/root/responsivegrid/featuredcategorylist";
106108
private static final String NAVIGATION_RESOURCE = PAGE + "/jcr:content/root/responsivegrid/navigation";
107109

110+
private static final String CIF_DAM_ROOT = "/content/dam/core-components-examples/library/cif-sample-assets/";
111+
108112
private GraphqlServlet graphqlServlet;
109113
private MockSlingHttpServletRequest request;
110114
private MockSlingHttpServletResponse response;
@@ -203,8 +207,18 @@ public void testProductModel() throws ServletException {
203207
requestPathInfo.setSelectorString("beaumont-summit-kit");
204208

205209
Product productModel = context.request().adaptTo(Product.class);
206-
Assert.assertEquals("MJ01", productModel.getSku());
210+
Assert.assertEquals("MH01", productModel.getSku());
207211
Assert.assertEquals(15, productModel.getVariants().size());
212+
213+
// We make sure that all assets in the sample JSON response point to the DAM
214+
for (Asset asset : productModel.getAssets()) {
215+
Assert.assertTrue(asset.getPath().startsWith(CIF_DAM_ROOT));
216+
}
217+
for (Variant variant : productModel.getVariants()) {
218+
for (Asset asset : variant.getAssets()) {
219+
Assert.assertTrue(asset.getPath().startsWith(CIF_DAM_ROOT));
220+
}
221+
}
208222
}
209223

210224
@Test
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
3+
jcr:description="Page Component for the CIF Components Library"
4+
jcr:primaryType="cq:Component"
5+
jcr:title="Page"
6+
sling:resourceSuperType="core-components-examples/components/page"
7+
componentGroup=".hidden"/>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
~ Copyright 2016 Adobe
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
16+
<!DOCTYPE HTML>
17+
<html data-sly-use.page="com.adobe.cq.wcm.core.components.models.Page" lang="${page.language}"
18+
data-sly-use.storeView="com.adobe.cq.commerce.core.components.models.storeconfigexporter.StoreConfigExporter"
19+
data-sly-use.head="head.html"
20+
data-sly-use.footer="footer.html"
21+
data-sly-use.redirect="redirect.html">
22+
<head data-sly-call="${head.head @ page = page}"></head>
23+
<body class="${page.cssClassNames}" data-store-view="${storeView.storeView}" data-graphql-endpoint="${storeView.graphqlEndpoint}">
24+
<sly data-sly-test.isRedirectPage="${page.redirectTarget && (wcmmode.edit || wcmmode.preview)}"
25+
data-sly-call="${redirect.redirect @ redirectTarget = page.redirectTarget}"></sly>
26+
<sly data-sly-test="${!isRedirectPage}">
27+
<sly data-sly-include="body.socialmedia_begin.html"></sly>
28+
<sly data-sly-include="body.html"></sly>
29+
<sly data-sly-call="${footer.footer @ page = page}"></sly>
30+
<sly data-sly-include="body.socialmedia_end.html"></sly>
31+
</sly>
32+
</body>
33+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
3+
jcr:description="Product Detail Component for the Core Components Library"
4+
jcr:primaryType="cq:Component"
5+
jcr:title="Product Detail"
6+
sling:resourceSuperType="core/cif/components/commerce/product/v1/product"
7+
componentGroup="Core Components Examples"/>

examples/ui.content/src/main/content/META-INF/vault/filter.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
<filter root="/conf/core-components-examples/settings/wcm/templates/content-page/structure/jcr:content/root/sidebar/accordion/item_1579021109269"/>
77
<filter root="/content/core-components-examples/library/jcr:content/root/responsivegrid/container_1589240807"/>
88
<filter root="/content/core-components-examples/library/commerce"/>
9+
<filter root="/content/dam/core-components-examples/library/cif-sample-assets/"/>
910
<filter root="/content/dam/core-components-examples/library/cif-components"/>
1011
</workspaceFilter>

examples/ui.content/src/main/content/jcr_root/conf/core-components-examples/settings/cloudconfigs/commerce/.content.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
jcr:title="Commerce"
1414
sling:configPropertyInherit="true"
1515
sling:resourceType="commerce/gui/components/configuration/page"
16+
magentoGraphqlEndpoint="/apps/cif-components-examples/graphql"
1617
magentoRootCategoryId="2"
1718
magentoStore="default"/>
1819
</jcr:root>

examples/ui.content/src/main/content/jcr_root/content/core-components-examples/library/.content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
sling:resourceType="core-components-examples/components/teaser"
2323
actionsEnabled="false"
2424
descriptionFromPage="true"
25-
fileReference="/content/dam/core-components-examples/library/components/container.svg"
25+
fileReference="/content/dam/core-components-examples/library/cif-components/product.svg"
2626
linkURL="/content/core-components-examples/library/commerce/product"
2727
textIsRich="true"
2828
titleFromPage="false">

0 commit comments

Comments
 (0)