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

feat: add status message below prompt editor #284

Merged
merged 13 commits into from
Jun 11, 2024
Merged

feat: add status message below prompt editor #284

merged 13 commits into from
Jun 11, 2024

Conversation

audrey-kho
Copy link
Contributor

@audrey-kho audrey-kho commented May 24, 2024

Description

  • An error message is shown under the prompt editor when an unsupported character is detected
  • Generate button is disabled when an unsupported character is used

Related Issue

https://jira.corp.adobe.com/browse/SITES-21736

Motivation and Context

How Has This Been Tested?

https://experience-qa.adobe.com/?devMode=true&shell_source=workspace&workspace=charerrorui&shell_ims=prod#/aem/generate-variations/

Screenshots (if appropriate):

Screenshot 2024-05-29 at 9 16 44 AM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@audrey-kho audrey-kho marked this pull request as ready for review May 29, 2024 16:24
Comment on lines 242 to 246
<Text>
The characters <span style={{ fontWeight: '600' }}>&#123;</span>, <span style={{ fontWeight: '600' }}>&#125;</span>,
and <span style={{ fontWeight: '600' }}>&quot;</span> are reserved and can&apos;t be used within quoted text values.
Please remove or replace these characters and try again.
</Text>
Copy link
Member

Choose a reason for hiding this comment

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

Localizable text. It's a good opportunity to localize a very complex text string.
Please refer to this example:

{formatMessage(intlMessages.app.consentDialogContent, {

@audrey-kho audrey-kho self-assigned this Jun 3, 2024
Copy link
Member

@askayastha22 askayastha22 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@slitviachenko slitviachenko left a comment

Choose a reason for hiding this comment

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

@audrey-kho , I left some comments, could you please take a look when you have time?
CC: @askayastha22

web-src/src/components/PromptSessionSideView.js Outdated Show resolved Hide resolved
<PromptEditor
isOpen={isOpenPromptEditor}
onClose={() => setIsOpenPromptEditor(false)}
error={promptEditorError}
Copy link
Collaborator

Choose a reason for hiding this comment

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

From my understanding of the app's architecture, the PromptSessionPanel component might be considered a form component. It could have its own validation state, which other child components might call to notify about any validation errors. Child components like PromptSessionSideView and PromptEditor might have their own internal validation states to track their validation logic.

PromptSessionPanel (a form element) - has an internal state to track form validation and form controls
  |-- PromptSessionSideView (an input element)
  |-- PromptEditor (an input element) - has its own internal state to track its validation logic and notifies PromptSessionPanel in case of errors
  • once PromptEditor encounters a validation error, it should notify PromptSessionPanel
  • in turn, PromptSessionPanel should notify PromptSessionSideView to disable GenerateButton

In short, passing promptEditorError isn't needed. PromptEditor should have its own state to control its validation logic and only notify PromptSessionPanel about errors by calling PromptSessionPanel's setPromptEditorError method. However, we need to rename it to something like setPromptValidationError since other child components that we could have might also fail their own validation logic.

However, I need input from @askayastha22 as well.

Copy link
Member

@askayastha22 askayastha22 Jun 10, 2024

Choose a reason for hiding this comment

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

@slitviachenko

  • From my point of view, even though PromptSessionPanel looks like a form element, it's dynamically created via prompt syntax. So, validation logic for each text field is hard to determine beforehand.
  • As for your point about PromptEditor having its own state to control validation logic, it is a good catch and we may refactor the code.

Copy link
Collaborator

@slitviachenko slitviachenko left a comment

Choose a reason for hiding this comment

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

Please remove the console.log statement, the rest LGTM

@audrey-kho audrey-kho merged commit eb92ef0 into main Jun 11, 2024
3 checks passed
@audrey-kho audrey-kho deleted the char-error-ui branch June 11, 2024 17:09
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.

3 participants