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

LPS-139246 - Create specific autocomplete for ddm #1489

Closed

Conversation

bryceosterhaus
Copy link
Collaborator

issues.liferay.com/browse/LPS-139246

Previous PR: #1471

Alright, I decided to re-work this and go for the simple solution for now. The goal here was to remove the dependency of commerce-frontend-js/components/autocomplete/Autocomplete from ObjectRelationship.js.

Rather that refactor the commerce code, I instead just created a simple autocomplete solution for DDM.

Let me know if you see any issues with this.

I also removed the "value" attribute from the backend because it was redundant of initialValue.

cc @marco-leo @FabioDiegoMastrorilli

@liferay-continuous-integration
Copy link
Collaborator

Please only forward necessary changes to Brian Chan during stabilization. Nonurgent changes should wait until the ongoing DXP 7.4 GA1 and Portal 7.4 GA4 release has been completed. For more details on the release timeline and status, see product-delivery.

@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 - 1 out of 1 jobs passed in 3 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 5f7e960823811f2a65572bfe0ae8d9b0ada1bb94

Sender Branch:

Branch Name: LPS-139246-3
Branch GIT ID: 80dfb5fc4ae90dfde9ffa640347c1ece8c8d7c0c

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 - 11 out of 11 jobs passed

❌ ci:test:relevant - 25 out of 28 jobs passed in 2 hours

Click here for more details.

This pull is eligible for reevaluation. When this upstream build has completed, using the following CI command will compare this pull request result against a more recent upstream result:

ci:reevaluate:1327401_483

Base Branch:

Branch Name: master
Branch GIT ID: 5f7e960823811f2a65572bfe0ae8d9b0ada1bb94

Upstream Comparison:

Branch GIT ID: ddf229019900a7f664471fcfd14cd8aebacf3c2a
Jenkins Build URL: Acceptance Upstream DXP (master) #2337

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

Failures unique to this pull:

  1. test-portal-acceptance-pullrequest-batch(master)/functional-tomcat90-mysql57-jdk8/1
    Job Results:

    24 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=16 #1506
           [exec] * What went wrong:
           [exec] Could not resolve all artifacts for configuration 'classpath'.
           [exec] > Could not resolve com.liferay:com.liferay.gradle.plugins.defaults:7.0.192.
           [exec]   Required by:
           [exec]       unspecified:unspecified:unspecified
           [exec]    > Could not resolve com.liferay:com.liferay.gradle.plugins.defaults:7.0.192.
           [exec]       > Could not get resource 'https://repository-cdn.liferay.com/nexus/content/groups/public/com/liferay/com.liferay.gradle.plugins.defaults/7.0.192/com.liferay.gradle.plugins.defaults-7.0.192.pom'.
           [exec]          > Could not HEAD 'https://repository-cdn.liferay.com/nexus/content/groups/public/com/liferay/com.liferay.gradle.plugins.defaults/7.0.192/com.liferay.gradle.plugins.defaults-7.0.192.pom'.
           [exec]             > repository-cdn.liferay.com
           [exec] > Could not resolve com.liferay:com.liferay.gradle.plugins.maven.plugin.builder:1.2.8.
           [exec]   Required by:
           [exec]       unspecified:unspecified:unspecified
           [exec]    > Could not resolve com.liferay:com.liferay.gradle.plugins.maven.plugin.builder:1.2.8.
           [exec]       > Could not get resource 'https://repository-cdn.liferay.com/nexus/content/groups/public/com/liferay/com.liferay.gradle.plugins.maven.plugin.builder/1.2.8/com.liferay.gradle.plugins.maven.plugin.builder-1.2.8.pom'.
           [exec]          > Could not HEAD 'https://repository-cdn.liferay.com/nexus/content/groups/public/com/liferay/com.liferay.gradle.plugins.maven.plugin.builder/1.2.8/com.liferay.gradle.plugins.maven.plugin.builder-1.2.8.pom'.
           [exec]             > repository-cdn.liferay.com
           [exec] > Could not resolve de.undercouch:gradle-download-task:3.3.0.
           [exec]   Required by:
           [exec]       unspecified:unspecified:unspecified
           [exec]    > Could not resolve de.undercouch:gradle-download-task:3.3.0.
           [exec]       > Could not get resource 'https://repository-cdn.liferay.com/nexus/content/groups/public/de/undercouch/gradle-download-task/3.3.0/gradle-download-task-3.3.0.pom'.
           [exec]          > Could not HEAD 'https://repository-cdn.liferay.com/nexus/content/groups/public/de/undercouch/gradle-download-task/3.3.0/gradle-download-task-3.3.0.pom'.
           [exec]             > repository-cdn.liferay.com
           [exec] > Could not resolve gradle.plugin.org.ysb33r.gradle:gradletest:2.0.
           [exec]   Required by:
           [exec]       unspecified:unspecified:unspecified

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

    1501 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=2 #5730
      1. com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog
        junit.framework.AssertionFailedError: 
        Unable to find corresponding model impl class for table O_20100_A3DaR4ebw
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.scanXMLLogFile(PortalLogAssertorTest.java:171)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:98)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:88)
        	at java.nio.file.Files.walkFileTree(Files.java:2670)
        	at java.nio.file.Files.walkFileTree(Files.java:2742)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog(PortalLogAssertorTest.java:86)
        
Test bundle downloads:

@liferay-continuous-integration
Copy link
Collaborator

@javiergamarra
Copy link

ci:test:relevant

@liferay-continuous-integration
Copy link
Collaborator

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

❌ ci:test:relevant - 25 out of 28 jobs passed in 2 hours 3 minutes

Click here for more details.

This pull is eligible for reevaluation. When this upstream build has completed, using the following CI command will compare this pull request result against a more recent upstream result:

ci:reevaluate:1317401_591

Base Branch:

Branch Name: master
Branch GIT ID: 3190e1b127e5820f3bc484ba50e24d76b4f44ec3

Upstream Comparison:

Branch GIT ID: 0080b5cf1be2008ae06ca2d67ca2612f4a01c4d0
Jenkins Build URL: Acceptance Upstream DXP (master) #2340

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

Failures unique to this pull:


Failures in common with acceptance upstream results at 0080b5c:
  1. test-portal-acceptance-pullrequest-batch(master)/modules-integration-mysql57-jdk8/0
    Job Results:

    1504 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=2 #1589
      1. com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog
        junit.framework.AssertionFailedError: 
        Unable to find corresponding model impl class for table O_20100_AOjGvfOKQ
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.scanXMLLogFile(PortalLogAssertorTest.java:171)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:98)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:88)
        	at java.nio.file.Files.walkFileTree(Files.java:2670)
        	at java.nio.file.Files.walkFileTree(Files.java:2742)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog(PortalLogAssertorTest.java:86)
        
Test bundle downloads:

@liferay-continuous-integration
Copy link
Collaborator

Comment on lines 89 to 90
setSelectedValue('');
setInputValue(event.target.value);

Choose a reason for hiding this comment

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

@bryceosterhaus because it is a Forms field, you need to call onChange here so that the Forms can update the context, so it will be able to submit correctly for example, or if it is in the builder it will be able to preview in the builder what is typed into the predefined value field for example on the Sidebar.

Comment on lines 21 to 55
initialLabel,
initialValue,
initialLabel = '',
initialValue = '',
inputName,
itemsKey,
itemsLabel,
labelKey = 'label',
name,
onChange,
readOnly,
required,
value,
valueKey = 'value',

Choose a reason for hiding this comment

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

These behaviors for the Field seem a little strange, normally the fields have a common contract.

  • value will receive the current value
  • predefinedValue is the initial value that is used when you don't have value
  • onChange the callback will update the value in the Forms

There are other properties but they are not related to this case here.

Comment on lines 79 to 84
<input
id={inputName}
name={inputName}
type="hidden"
value={selectedValue}
/>

Choose a reason for hiding this comment

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

I think I don't even need this hidden input here because FieldBase will take care of that because it also handles various values depending on the language.

itemsKey={itemsKey}
itemsLabel={itemsLabel}
}) {
const [selectedValue, setSelectedValue] = React.useState(initialValue);

Choose a reason for hiding this comment

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

There is usually an idea that a Field's value state is bidirectional, it maintains an internal state and is also updated with some value received via value because this component is also used as a preview in the builder and is also used in Sidebar.

The Sidebar and the user view happens what is called evaluation, every time the user types a value in the field and calls onChange it makes a call to the backend to validate the properties of the field, there are other things that it validates too, it can happen the value will change and you will have to update with what came from the backend. But for this case, I think it doesn't exist.

Usually, the useSyncValue hook is used which will take care of this.

itemsKey={itemsKey}
itemsLabel={itemsLabel}
}) {
const mutatedRef = React.useRef(false);
Copy link

@matuzalemsteles matuzalemsteles Sep 24, 2021

Choose a reason for hiding this comment

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

Just a question about it, is this to help you switch when to use value or initial/predefined value? What problems did you have?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this was to make sure the initial/predefined is only there when the input hasn't been modified. Since the onChange and value come from outside this component, we aren't able to pass it as an initial state.

Otherwise if we do something like value={value || predefinedValue} it would get weird if the user clears the input and then it would render the predefined again.

Choose a reason for hiding this comment

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

Hmm yeah makes sense, a good strategy.

@bryceosterhaus
Copy link
Collaborator Author

ci:test:sf

@bryceosterhaus
Copy link
Collaborator Author

ci:test:relevant

@liferay-continuous-integration
Copy link
Collaborator

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

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: b61478730f9e06b8826633e08c9caf0b7292318d

Sender Branch:

Branch Name: LPS-139246-3
Branch GIT ID: e74fa434f6c4d4251c8bfc105888816b230bd9cc

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 - 11 out of 11 jobs passed

✔️ ci:test:relevant - 27 out of 28 jobs passed in 3 hours 4 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: b61478730f9e06b8826633e08c9caf0b7292318d

Upstream Comparison:

Branch GIT ID: 8682547a1f5f16fec929f7cf2fe187f2f17bc297
Jenkins Build URL: Acceptance Upstream DXP (master) #2352

ci:test:stable - 11 out of 11 jobs PASSED
11 Successful Jobs:
ci:test:relevant - 26 out of 28 jobs PASSED
26 Successful Jobs:
For more details click here.

This pull contains no unique failures.


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

    1520 Tests Passed.
    1 Test Failed.

    1. AXIS_VARIABLE=2 #394711
      1. com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog
        junit.framework.AssertionFailedError: 
        Unable to find corresponding model impl class for table O_20100_AyckwMwAZ
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.scanXMLLogFile(PortalLogAssertorTest.java:171)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:98)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest$1.visitFile(PortalLogAssertorTest.java:88)
        	at java.nio.file.Files.walkFileTree(Files.java:2670)
        	at java.nio.file.Files.walkFileTree(Files.java:2742)
        	at com.liferay.portal.log.assertor.PortalLogAssertorTest.testScanXMLLog(PortalLogAssertorTest.java:86)
        
Test bundle downloads:

@liferay-continuous-integration
Copy link
Collaborator

@bryceosterhaus
Copy link
Collaborator 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

Skipping previously passed test suites:
ci:test:relevant
ci:test:sf

@liferay-continuous-integration
Copy link
Collaborator

All required test suite(s) passed.
Forwarding pull request to brianchandotcom.
Console

@liferay-continuous-integration
Copy link
Collaborator

Pull request has been successfully forwarded to brianchandotcom#107771
Console

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.

5 participants