-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIF-2188 - Expose HTML id attribute in component edit dialogs #639
Conversation
* adding field for HTML id attribute in edit dialog of components * reusing the HTML id generation of core WCM components * updated unit tests
* fixing IT failure
Codecov Report
@@ Coverage Diff @@
## master #639 +/- ##
============================================
+ Coverage 88.28% 88.29% +0.01%
- Complexity 1581 1584 +3
============================================
Files 279 279
Lines 6933 6940 +7
Branches 1036 1037 +1
============================================
+ Hits 6121 6128 +7
Misses 611 611
Partials 201 201
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
public abstract class DataLayerComponent { | ||
public static final String ID_SEPARATOR = "-"; | ||
public static final String ID_SEPARATOR = ComponentUtils.ID_SEPARATOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why redefining the const instead of using ComponentUtils.ID_SEPARATOR
directly via static import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID_SEPARATOR is used at more other places in the codebe in sub-classes of DataLayerComponnet. If you define it here you don't need any static import in many other files. In fact the constant was defined earlier, I've just aligned the definition with ComponentUtils.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the constant was defined earlier and it was wrong. So instead of having the same constant twice I would prefer to remove it and only use ComponentUtils.ID_SEPARATOR
. The static import should not hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 - this is more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've inlined the ID_SEPARATOR constant.
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
public abstract class DataLayerComponent { | ||
public static final String ID_SEPARATOR = "-"; | ||
public static final String ID_SEPARATOR = ComponentUtils.ID_SEPARATOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 - this is more explicit.
String prefix = StringUtils.substringAfterLast(resourceType, "/"); | ||
String path = resource.getPath(); | ||
return StringUtils.join(prefix, ID_SEPARATOR, StringUtils.substring(DigestUtils.sha256Hex(path), 0, 10)); | ||
if (wcmComponent == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can wcmComponent
be null
?
We only have 2 models using an optional default injection strategy (button v1 and v2). For all others the wcmComponent
is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataLayerComponent is also extended by classes which are not Sling models, we handle that case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this detail to the javadoc of the class while you are on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That this abstract class may be extended by classes that are annotated as sling models and others that are not.
* cleaned up ID_SEPARATOR
Related Issue
CIF-2188
How Has This Been Tested?
JUnit, manually.
Types of changes
Checklist: