Skip to content

Conversation

@vsarya
Copy link
Contributor

@vsarya vsarya commented Feb 22, 2022

Q                       A
Fixed Issues? https://github.com/adobe/aem-core-wcm-components/wiki/Table-of-Content-Component
Patch: Bug Fix? No
Minor: New Feature? Yes
Major: Breaking Change? No
Tests Added + Pass? UTs and UI Selenium tests added
Documentation Provided Yes
Any Dependency Changes? Yes (JSOUP)
License Apache License, Version 2.0

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 22, 2022

This pull request introduces 1 alert when merging caa947a into 1b0503c - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

@vsarya vsarya changed the title Main sites 3971 Table of Contents Component Feb 23, 2022
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 23, 2022

This pull request introduces 1 alert when merging d4750e5 into 7434de3 - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #2030 (35a0812) into main (d6ba9ab) will increase coverage by 0.16%.
The diff coverage is 92.00%.

❗ Current head 35a0812 differs from pull request most recent head dab526b. Consider uploading reports for the commit dab526b to get more accurate results

@@             Coverage Diff              @@
##               main    #2030      +/-   ##
============================================
+ Coverage     86.60%   86.77%   +0.16%     
- Complexity     2313     2375      +62     
============================================
  Files           210      214       +4     
  Lines          6161     6361     +200     
  Branches        931      964      +33     
============================================
+ Hits           5336     5520     +184     
- Misses          329      336       +7     
- Partials        496      505       +9     
Impacted Files Coverage Δ
...cq/wcm/core/components/models/TableOfContents.java 88.88% <88.88%> (ø)
...nents/internal/servlets/TableOfContentsFilter.java 90.90% <90.90%> (ø)
...onents/internal/models/v1/TableOfContentsImpl.java 100.00% <100.00%> (ø)
...ponents/internal/servlets/CharResponseWrapper.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6ba9ab...dab526b. Read the comment docs.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 24, 2022

This pull request introduces 1 alert when merging 916d303 into 0767db9 - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 25, 2022

This pull request introduces 1 alert when merging 530f8a1 into 0767db9 - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

@vsarya vsarya force-pushed the main--SITES-3971 branch 3 times, most recently from b5cfed0 to b59c166 Compare February 28, 2022 11:57
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 28, 2022

This pull request introduces 1 alert when merging b59c166 into f4c2da2 - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

restrictStopLevel = currentStyle.get(PN_RESTRICT_STOP_LEVEL, String.class);
includeClasses = currentStyle.get(PN_INCLUDE_CLASSES, String[].class);
ignoreClasses = currentStyle.get(PN_IGNORE_CLASSES, String[].class);
slingHttpServletRequest.setAttribute("contains-table-of-contents", true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefix with cmp to avoid clashes with custom names: cmp:contains-table-of-contents

@jckautzmann
Copy link
Contributor

It would be nice to add a few Selenium tests.

Copy link
Member

@vladbailescu vladbailescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a README file in the version root folder, similar to other components!

CharResponseWrapper responseWrapper = new CharResponseWrapper((HttpServletResponseWrapper) response);
chain.doFilter(request, responseWrapper);
String originalContent = responseWrapper.toString();
Boolean containsTableOfContents = (Boolean) request.getAttribute("contains-table-of-contents");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please isolate all "magic strings" into constants. Also, for Core Components we generally use BEM-style classes (see https://github.com/adobe/aem-core-wcm-components/wiki/css-coding-conventions) so this class would be best refactored to cmp-toc__placeholder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand to use the BEM style for all the CSS classnames used in this PR, this one is not a CSS class but a request attribute. Do we use the same style for request attributes as well or just prepend it with cmp: as pointed by @jckautzmann here?

* @since com.adobe.cq.wcm.core.components.models.tableofcontents 1.0
*/
default String getListType() {
return "unordered";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define all possible values as constants in this class (or an enumeration)!

import java.io.CharArrayWriter;
import java.io.PrintWriter;

public class CharResponseWrapper extends HttpServletResponseWrapper {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work across multiple encodings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper just overrides the writer of the original response. Rest everything is handled by the original response object.
CharResponseWrapper extends HttpServletResponseWrapper which further extends ServletResponseWrapper which has the method setCharacterEncoding.

com.adobe.cq.commerce.*;resolution:=optional,
com.adobe.aem.wcm.seo.*;resolution:=optional,
javax.annotation;version=0.0.0,
javax.annotation.meta;resolution:=optional,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only javax.annotation.* is used in this repo and only javax.annotation.PostConstruct is used in this PR.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Mar 2, 2022

This pull request introduces 1 alert when merging 5fee6ff into e114d7c - view on LGTM.com

new alerts:

  • 1 for Useless comparison test

@jckautzmann
Copy link
Contributor

Please add a README for this component.

@jckautzmann
Copy link
Contributor

Please add a page to the component library with various different configurations of the TOC.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
<div data-sly-use.toc="com.adobe.cq.wcm.core.components.models.TableOfContents"
data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component"
class = "table-of-contents-placeholder"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Vlad's remark above: the class name should be cmp-toc__placeholder

data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component"
class = "table-of-contents-placeholder"
id = "${component.id}"
data-list-type = "${toc.listType}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefix the data attribute with cmp-toc-:

data-cmp-toc-list-type
data-cmp-toc-start-level
data-cmp-toc-include-classes
data-cmp-toc-ignore-classes

@vsarya
Copy link
Contributor Author

vsarya commented Mar 24, 2022

Don’t allow authors to configure invalid options in the dialog by validating the options and preventing a start level that is bigger than the stop level.

@gabrielwalt All improvements except the one mentioned above are done. I'll be back working on this item after my next week's PTO.

cc - @jckautzmann , @vladbailescu

@jckautzmann
Copy link
Contributor

jckautzmann commented Apr 5, 2022

@vsarya I noticed a shift in the customID index. If you have 3 titles with the same text, e.g. mytitle the generated IDs are currently : mytitle, mytitle-2 and mytitle-3. IMHO they should be: mytitle, mytitle-1 and mytitle-2.

@vsarya
Copy link
Contributor Author

vsarya commented Apr 6, 2022

@vsarya I noticed a shift in the customID index. If you have 3 titles with the same text, e.g. mytitle the generated IDs are currently : mytitle, mytitle-2 and mytitle-3. IMHO they should be: mytitle, mytitle-1 and mytitle-2.

@jckautzmann Just pushed the required changes.
commit - acfbf89

@jckautzmann
Copy link
Contributor

@vsarya Please fix the build error due to the baseline error:
https://github.com/adobe/aem-core-wcm-components/runs/5971672041?check_suite_focus=true

@jckautzmann
Copy link
Contributor

jckautzmann commented Apr 11, 2022

@vsarya What is the status with the broken docs links (Github + Adobe)?
Screenshot 2022-04-11 at 15 49 43

@jckautzmann
Copy link
Contributor

I'd change the dialog validation message to: "Stop level is smaller than start level" as the tooltip applies to the stop level field.
Screenshot 2022-04-11 at 15 54 06

@vsarya
Copy link
Contributor Author

vsarya commented Apr 12, 2022

@jckautzmann The sonar check on the PR is failing due to duplicate lines of code in content/src/content/jcr_root/apps/core/wcm/components/search/v2/search/clientlibs/site/js/search.js

# Conflicts:
#	examples/ui.content/src/content/jcr_root/content/core-components-examples/library/core-structure/.content.xml
@vsarya
Copy link
Contributor Author

vsarya commented Apr 13, 2022

@vsarya What is the status with the broken docs links (Github + Adobe)? Screenshot 2022-04-11 at 15 49 43

@jckautzmann I had already created a CQDOC issue for the same as discussed in our weekly meetings - https://jira.corp.adobe.com/browse/CQDOC-18998

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
14.6% 14.6% Duplication

@jckautzmann jckautzmann merged commit ff2b76d into adobe:main Apr 18, 2022
@jckautzmann
Copy link
Contributor

Thx @vsarya for implementing this TOC component!

@vsarya
Copy link
Contributor Author

vsarya commented Apr 19, 2022

Thx @vsarya for implementing this TOC component!

I enjoyed a lot working on it and learned a lot about core components and request filters during its development.

Thanks a lot @jckautzmann and @vladbailescu for guiding me throughout the whole development phase and while doing the POC.

Thank you Varun and @gabrielwalt for giving me the opportunity to work on such an interesting component.
Looking forward to develop more such core components in the future.

@msagolj msagolj added this to the 2.20.0 milestone Apr 27, 2022
chain.doFilter(request, responseWrapper);
String originalContent = responseWrapper.toString();
Boolean containsTableOfContents = (Boolean) request.getAttribute(TableOfContentsImpl.TOC_REQUEST_ATTR_FLAG);
if (responseWrapper.getContentType().contains("text/html") &&
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jckautzmann we observed NPE in this line during our on-call shift

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grubyak thx for your feedback. Could you please create a ticket describing the issue and how it can be reproduced? Thx!

vsarya pushed a commit to vsarya/aem-core-wcm-components that referenced this pull request Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants