Skip to content
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

COMMERCE-5939 Dataset Fixes + minor updates #865

Closed
wants to merge 2 commits into from

Conversation

fabio-d-m
Copy link

@fabio-d-m fabio-d-m commented Mar 4, 2021

This PR concerns dataset displays, iframes and the way they communicate.

COMMERCE-5939
when a dataset got rendered within an "ostile" container with a display: none css property, cellRef.current.getClientRects() returned an empty array causing this code to break the component.

const {width} = cellRef.current.getClientRects()[0];
registerColumn(columnName, width, resizable);

I used an IntersectionObserver to avoid the problem. The callback gets invoked only the first time the component gets rendered and, eventually (if it is hidden), when it becomes visible, then it disconnects the Observer.

COMMERCE-5968
In order to let customers using Java extension points and allow them to render content using JSPs, we massively deal with iframes. Wherever we want some content to be rendered within a side panel we wrap it within a side-panel-content taglib.

I did some refactoring and I removed the old side panel implementation we had in commerce module since it's now part of the dataset in frontend-taglib-clay.

@liferay-continuous-integration
Copy link
Collaborator

CI is automatically triggering the following test suites:

  •     ci:test:relevant
  •     ci:test:sf

@liferay-continuous-integration
Copy link
Collaborator

❌ ci:test:sf - 0 out of 1 jobs passed in 3 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: eb9498666af6f54db6cdfecd96c3933151df098c

Sender Branch:

Branch Name: COMMERCE-5949
Branch GIT ID: 83227d1c18c9570073dc11d8b224c345e2e00e5b

0 out of 1jobs PASSED
For more details click here.
     [java] java.lang.Exception: Found 1 formatting issues:
     [java] 1: ./modules/apps/commerce/commerce-frontend-taglib/src/main/resources/META-INF/resources/side_panel_content/init.jsp expected:<...p://liferay.com/tld/[clay" prefix="clay" %><%@
     [java] taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend" %><%@
     [java] taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
     [java] 
     [java] <%@ page import="com.liferay.portal.kernel.util.PortalUtil" %><%@
     [java] page import="com.liferay.portal.kernel.util.Validator" %>
     [java] ]
     [java] <%@ page import="ja...> but was:<...p://liferay.com/tld/[aui" prefix="aui" %><%@
     [java] taglib uri="http://liferay.com/tld/clay" prefix="clay" %><%@
     [java] taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend" %><%@
     [java] taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
     [java] 
     [java] <%@ page import="com.liferay.portal.kernel.util.Validator" %>
     [java] <%@ page import="com.liferay.portal.kernel.util.PortalUtil" %>]
     [java] <%@ page import="ja...>
     [java] 
     [java] 	at com.liferay.source.formatter.SourceFormatter.format(SourceFormatter.java:445)
     [java] 	at com.liferay.source.formatter.SourceFormatter.main(SourceFormatter.java:290)
[stopwatch] [run.batch.test.action: 1:22.539 sec]
     [echo] The following error occurred while executing this line:
     [echo] /opt/dev/projects/github/liferay-portal/portal-impl/build.xml:572: The following error occurred while executing this line:
     [echo] /opt/dev/projects/github/liferay-portal/portal-impl/build.xml:706: Java returned: 1
      [get] Getting: http://test-1-2/job/test-portal-source-format/152//consoleText
      [get] To: /opt/dev/projects/github/liferay-portal/20210304142318441.txt
   [delete] Deleting: /opt/dev/projects/github/liferay-portal/20210304142318441.txt
  [typedef] Could not load definitions from resource org/apache/maven/artifact/ant/antlib.xml. It could not be found.
  [taskdef] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.
   [delete] Deleting: /opt/dev/projects/github/liferay-portal/null341658365.properties

merge-test-results:
[mkdir] Created dir: /opt/dev/projects/github/liferay-portal/test-results
[junitreport] Processing /opt/dev/projects/github/liferay-portal/test-results/TESTS-TestSuites.xml to /tmp/null1617407995

@liferay-continuous-integration
Copy link
Collaborator

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:stable - 9 out of 9 jobs passed

❌ ci:test:relevant - 19 out of 25 jobs passed in 5 hours 8 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: eb9498666af6f54db6cdfecd96c3933151df098c

Upstream Comparison:

Branch GIT ID: eb9498666af6f54db6cdfecd96c3933151df098c
Jenkins Build URL: Acceptance Upstream DXP (master) #1605

ci:test:stable - 9 out of 9 jobs PASSED
9 Successful Jobs:
ci:test:relevant - 19 out of 25 jobs PASSED
19 Successful Jobs:
For more details click here.

Failures unique to this pull:


Failures in common with acceptance upstream results at eb94986:
  1. test-portal-acceptance-pullrequest-batch(master)/modules-semantic-versioning-jdk8/0
    Job Results:

    0 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=0,label_exp=!master #330685

      Please fix semantic versioning on FabioDiegoMastrorilli/COMMERCE-5949

           [exec] > Task :apps:commerce:commerce-product-tax-category-web:autoUpdateXml SKIPPED
           [exec] > Task :apps:commerce:commerce-product-tax-category-web:baseline SKIPPED
           [exec] > Task :apps:commerce:commerce-product-tax-category-web:syncVersions
           [exec] > Task :apps:commerce:commerce-inventory-web:compileJSP
           [exec] 
           [exec] > Task :apps:commerce:commerce-subscription-web:compileJSP
           [exec] Note: /opt/dev/projects/github/liferay-portal/modules/apps/commerce/commerce-subscription-web/build/jspc/org/apache/jsp/definition/edit_005finstance_005fsubscription_005finfo_jsp.java uses or overrides a deprecated API.
           [exec] Note: Recompile with -Xlint:deprecation for details.
           [exec] Note: /opt/dev/projects/github/liferay-portal/modules/apps/commerce/commerce-subscription-web/build/jspc/org/apache/jsp/my_005fsubscriptions/view_jsp.java uses unchecked or unsafe operations.
           [exec] Note: Recompile with -Xlint:unchecked for details.
           [exec] 
           [exec] > Task :apps:commerce:commerce-inventory-web:jar
           [exec] > Task :apps:commerce:commerce-inventory-web:autoUpdateXml SKIPPED
           [exec] > Task :apps:commerce:commerce-inventory-web:baseline SKIPPED
           [exec] > Task :apps:commerce:commerce-inventory-web:syncVersions
           [exec] > Task :apps:commerce:commerce-subscription-web:jar
           [exec] > Task :apps:commerce:commerce-subscription-web:autoUpdateXml SKIPPED
           [exec] > Task :apps:commerce:commerce-subscription-web:baseline SKIPPED
           [exec] > Task :apps:commerce:commerce-subscription-web:syncVersions
           [exec] Gradle build finished at 2021-03-05 05:20:09.007.
           [exec] 686 actionable tasks: 673 executed, 13 up-to-date
           [exec] 
           [exec] 
           [exec] FAILURE: Build failed with an exception.
           [exec] 
           [exec] * What went wrong:
           [exec] Execution failed for task ':apps:commerce:commerce-theme-minium:commerce-theme-minium-api:baseline'.
           [exec] > A failure occurred while executing com.liferay.gradle.plugins.baseline.internal.work.BaselineWorkAction
           [exec]    > org.gradle.api.GradleException: Semantic versioning is incorrect while checking /opt/dev/projects/github/liferay-portal/tools/sdk/dist/com.liferay.commerce.theme.minium.api-5.0.0.jar against /opt/dev/projects/github/liferay-portal/.gradle/caches/modules-2/files-2.1/com.liferay.commerce/com.liferay.commerce.theme.minium.api/4.0.5/bfcd15127c565751df3aa4cf18de2068a65098b9/com.liferay.commerce.theme.minium.api-4.0.5.jar

@fabio-d-m
Copy link
Author

ci:test:sf

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:sf - 1 out of 1 jobs passed in 4 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 7deedb562a6145be11b327fc35f9693b6b4e1541

Sender Branch:

Branch Name: COMMERCE-5949
Branch GIT ID: 6dadcfc829f385b86797fbe83d883f5cae7aca16

1 out of 1jobs PASSED
1 Successful Jobs:
For more details click here.

@liferay-continuous-integration
Copy link
Collaborator

@liferay-continuous-integration
Copy link
Collaborator

@jbalsas jbalsas changed the title Dataset Fixes + minor updates @COMMERCE-5949 Dataset Fixes + minor updates Mar 9, 2021
@jbalsas
Copy link

jbalsas commented Mar 9, 2021

Hey @FabioDiegoMastrorilli, I'm having a hard time wrapping my head around this. Is there an easy way to test the issue? The LPS only mentions a "hostile" environment, but how do we go and reproduce it?

Since this is mostly removals in commerce modules and you still have the most knowledge about this I'd lean towards just forwarding this, but it would be good to be able to see how is this actually being used so we can do a better job at maintaining it and evolving it in the future.

@wincent, do you want to maybe just do a quick 30k feet review in case something triggers your spidey-sense?

@jbalsas jbalsas changed the title @COMMERCE-5949 Dataset Fixes + minor updates COMMERCE-5949 Dataset Fixes + minor updates Mar 9, 2021
Copy link

@wincent wincent left a comment

Choose a reason for hiding this comment

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

do you want to maybe just do a quick 30k feet review in case something triggers your spidey-sense?

30k-foot review didn't turn anything up.

spiderman

I'd be fine with forwarding this.

const [datasetDisplaySupportSidePanelId] = useState(
props.sidePanelId || 'support-side-panel-' + getRandomId()
);
const [datasetDisplaySupportSidePanelId] = useState(props.sidePanelId);
Copy link

Choose a reason for hiding this comment

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

It is a little odd that you would use useState for something that you never change. If you just want to associate a value once with a component and never update it, useRef is probably the right tool for that (in fact, IIRC, if you look at the implementation of useState in React, you'll see that it is using refs under the covers to associate data with components).

Copy link
Author

Choose a reason for hiding this comment

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

It totally makes sense and I'll bear it in mind for the next PRs but I wouldn't change now. This dataset is the old one which is going to be deleted soon (after the minicart component usage switches to the new one)

Comment on lines 31 to 32
trigger.addEventListener('click', (e) => {
e.preventDefault();
Copy link

Choose a reason for hiding this comment

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

Best not to abbreviate (ie. eevent).

Copy link
Author

Choose a reason for hiding this comment

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

Omg, I'm really terrible with this rule. Sorry guys

Copy link

Choose a reason for hiding this comment

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

I wouldn't worry too much about this. We can actually lint for the common cases (eg. e, evt and friends) and then you won't have to worry about it. I thought we might have an issue for that already but I couldn't find it, so I created this one.

Liferay.on(OPEN_MODAL_FROM_IFRAME, (payload) => {
let firstAvailableModalId = null;

// eslint-disable-next-line no-for-of-loops/no-for-of-loops
Copy link

Choose a reason for hiding this comment

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

Good news is that we're turning this rule off in the next release of @liferay/eslint-config so we'll be able to delete this suppression soon.

return `${iframeHandlerModalNamespace}${counter++}`;
export function subscribeModal(modalNode) {
const id = `${iframeHandlerModalNamespace}${modalsCounter++}`;
registeredModals.set(id, modalNode);
Copy link

Choose a reason for hiding this comment

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

Brian would usually ask for a blank line above this.

@fabio-d-m
Copy link
Author

Hi Chema, this ticked explains the one of the possible scenarios where it breaks.

@jbalsas
Copy link

jbalsas commented Mar 10, 2021

Hi Chema, this ticked explains the one of the possible scenarios where it breaks.

Thanks @FabioDiegoMastrorilli! I feel that's a much better ticket to solve than COMMERCE-5949 since it has all the information... I'd recommend trying to prioritize the more detailed reports over the others. Will make it easier for everyone to track down why things are the way they are :)

If you're going to make any changes, would you mind renaming the commits to point to COMMERCE-5939 instead and close the other one as duplicate?

@fabio-d-m
Copy link
Author

Of course! no problem!

@fabio-d-m fabio-d-m changed the title COMMERCE-5949 Dataset Fixes + minor updates COMMERCE-5939 Dataset Fixes + minor updates Mar 10, 2021
@fabio-d-m
Copy link
Author

ci:forward

@liferay-continuous-integration
Copy link
Collaborator

CI is automatically triggering the following test suites:

  •     ci:test:relevant
  •     ci:test:sf

The pull request will automatically be forwarded to the user brianchandotcom if the following test suites pass:

  •     ci:test:relevant
  •     ci:test:sf
  •     ci:test:stable

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:sf - 1 out of 1 jobs passed in 6 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 98801a652f5794ad71c756c4dd8969d14f842c06

Sender Branch:

Branch Name: COMMERCE-5949
Branch GIT ID: 4f0580cce42c2d43cc67fa817278586b1cf2a9b1

1 out of 1jobs PASSED
1 Successful Jobs:
For more details click here.

@liferay-continuous-integration
Copy link
Collaborator

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:stable - 9 out of 9 jobs passed

✔️ ci:test:relevant - 21 out of 25 jobs passed in 2 hours 35 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 98801a652f5794ad71c756c4dd8969d14f842c06

Upstream Comparison:

Branch GIT ID: 98801a652f5794ad71c756c4dd8969d14f842c06
Jenkins Build URL: Acceptance Upstream DXP (master) #1621

ci:test:stable - 9 out of 9 jobs PASSED
9 Successful Jobs:
ci:test:relevant - 20 out of 25 jobs PASSED
20 Successful Jobs:
For more details click here.

This pull contains no unique failures.


Failures in common with acceptance upstream results at 98801a6:
  1. test-portal-acceptance-pullrequest-batch(master)/modules-semantic-versioning-jdk8/0
    Job Results:

    157 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=0,label_exp=!master #379745
      1. SemanticVersioningTest.testSemanticVersioning[/apps/commerce/commerce-frontend-api]
        java.lang.AssertionError:   PACKAGE_NAME                                       DELTA      CUR_VER    BASE_VER   REC_VER    WARNINGS  
        = ================================================== ========== ========== ========== ========== ==========
        * com.liferay.commerce.frontend.model                MINOR      5.1.0      5.1.0      5.2.0      VERSION INCREASE REQUIRED
        	<   class      com.liferay.commerce.frontend.model.ProductSettingsModel
        		+   method     isBackOrders()
        			+   return     boolean
        		+   method     setBackOrders(boolean)
        			+   return     void
        
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.assertTrue(Assert.java:41)
        at org.junit.Assert.assertFalse(Assert.java:64)
        at com.liferay.semantic.versioning.SemanticVersioningTest.testSemanticVersioning(SemanticVersioningTest.java:82)
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJU...</code></pre></div></li></ol></div></li></ol></div></li></ol></details></details></html><h5>Test bundle downloads:</h5><ul><li><a href="https://files.liferay.com/private/bundles/test-1-24/jobs/test-portal-acceptance-pullrequest(master)/builds/631/liferay-portal-bundle-tomcat.tar.gz">liferay-portal-bundle-tomcat.tar.gz</a> (mirrors: <a href="http://mirrors.dlc.liferay.com/files.liferay.com/private/bundles/test-1-24/jobs/test-portal-acceptance-pullrequest(master)/builds/631/liferay-portal-bundle-tomcat.tar.gz">dlc</a>, <a href="http://mirrors.lax.liferay.com/files.liferay.com/private/bundles/test-1-24/jobs/test-portal-acceptance-pullrequest(master)/builds/631/liferay-portal-bundle-tomcat.tar.gz">lax</a>)</li></ul>
        

@liferay-continuous-integration
Copy link
Collaborator

All required test suite(s) passed.
Forwarding pullrequest to brianchandotcom.

@liferay-continuous-integration
Copy link
Collaborator

Pull request has been successfully forwarded to brianchandotcom#99760

@liferay-continuous-integration
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants