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

EASI-4634 MentionTextArea Tiptap #2882

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

adamodd
Copy link
Contributor

@adamodd adamodd commented Nov 9, 2024

EASI-4634

Description

  • New DiscussionBoard view folder

  • Pulling in from MINT

    • MentionTextArea + support utils
    • DiscussionModalWrapper
    • Sidepanel
  • Adds Tiptap lib

  • i18n text is on hold until Add new discussions i18n file #2886 is in

Test

There is a stubbed button under the GRB Review section to open the panel preview
Screen Shot 2024-11-12 at 3 35 54 PM

PR Author Checklist

  • I have provided a detailed description of the changes in this PR.
  • I have provided clear instructions on how to test the changes in this PR.
  • I have updated tests or written new tests as appropriate in this PR.

PR Reviewer Guidelines

  • It's best to pull the branch locally and test it, rather than just looking at the code online!
  • When approving a PR, provide a reason why you're approving it
    • e.g. "Approving because I tested it locally and all functionality works as expected"
    • e.g. "Approving because the change is simple and matches the Figma design"
  • Don't be afraid to leave comments or ask questions, especially if you don't understand why something was done! (This is often a great time to suggest code comments or documentation updates)
  • Check that all code is adequately covered by tests - if it isn't feel free to suggest the addition of tests.

Tiptap lib
@adamodd adamodd requested a review from a team as a code owner November 9, 2024 00:22
@adamodd adamodd requested review from aterstriep and removed request for a team November 9, 2024 00:22
const [tagAlert, setTagAlert] = useState<boolean>(false);

const fetchUsers = ({ query }: { query: string }) => {
return [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Static stub of suggestions until grb participants are passed in

DiscussionModalWrapper
Sidepanel
Copy link
Collaborator

@ClayBenson94 ClayBenson94 left a comment

Choose a reason for hiding this comment

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

I'm good with these changes! Feel free to merge or hold if you're waiting for a review from @aterstriep!

@aterstriep
Copy link
Contributor

I'm still working on reviewing this, so please hold off on merging!

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like this component currently works with React Hook Forms since it was created to work with Formik.

  • Bugs when used within a RHF form:
    • The component rerenders with every character typed so the cursor disappears and I have to re-click into the field.
    • If I enter a value and then delete it, the component saves <p></p> as the field value. This prevents field validation from working correctly if the field is required.
    • When I type "@" into the field, I get an error: TypeError: Cannot read properties of undefined (reading '0'). Not sure if that's because tagging isn't fully working yet.
    • RHF fields need a ref for built-in functionality like focus on error to work.
  • If you update the props to use the RHF built-in ControllerRenderProps type, we can just spread the field object like we normally do within a form Controller component. That would replace the existing setFieldValue prop with onChange and initialContent with value.

I also noticed that the editor font needs to be updated to match the rest of the app. Adding usa-textarea height-auto classes to the editor would cover this as well as add the top margin that the rest of our text areas have.

@aterstriep aterstriep mentioned this pull request Nov 15, 2024
3 tasks
Copy link
Contributor

@aterstriep aterstriep left a comment

Choose a reason for hiding this comment

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

From our sync about GRB discussions - I'm going to approve this so we can merge as-is, and Adam will address the RHF changes in a follow up PR.

@adamodd adamodd merged commit a33d63a into feature/EASI-4614_grb_discussions Nov 18, 2024
12 checks passed
@adamodd adamodd deleted the EASI-4634/tiptap branch November 18, 2024 18:20
@adamodd adamodd mentioned this pull request Nov 20, 2024
samoddball added a commit that referenced this pull request Dec 18, 2024
* Empty commit to start feature branch

* Add new discussions i18n file (#2886)

* [NOREF] Discussions translation fixes (#2888)

* Add discussions to translation files index

* Plural i18n translations

* Typos

* [EASI-4635] Initial discussions API schema and migration (#2887)

* initial discussions api schema and migration

* rename migration

* add new table to truncate lists

* formatting

* update postman, remove payload types, add constraint

* EASI-4634 MentionTextArea Tiptap (#2882)

* MentionTextArea
Tiptap lib

* DiscussionBoard folder
DiscussionModalWrapper
Sidepanel

* [EASI-4636] GRB discussions card (#2889)

* DiscussionReply component

* DiscussionsCard component

* Mock types and data

* DiscussionReply component layout

* Merge remote-tracking branch 'origin/EASI-4635/initial-discussions-api' into EASI-4636/discussions-response-component

* Add discussions to GRB review query

* Update component types

* Translations

* Relative date util function

* Discussions admin card

* Discussion board tips

* Rename component

* DiscussionPost unit test

* Empty discussions state

* Discussions unit tests

* Replace mock data with query data

* Responsive styling

* Role fallback text with unit test

* Update reply text and unit tests

* Add Discussions nav link

* Snapshot update

* Add `DiscussionBoard` to Discussions component

* Update DiscussionPost to handle replies

* Unit tests

* Removed snapshot

Snapshot would always be outdated because of "X days ago" text within component

* [EASI-4635] Discussions store methods and resolvers (#2896)

* implement grb discussion store methods and attach to resolvers

* update method comments

* update postman for discussions

* Add functionality in db seed to allow easier user context creation, add discussions seed data, and update postman collection to return more information on GRB Discussion Posts/Replies

---------

Co-authored-by: ClayBenson94 <clay.benson@oddball.io>

* [EASI-4639] Discussions panel views (#2895)

* Merge discussions card work into branch

* Discussions panel view components

* Discussion post and reply mutations

* Basic discussion form

* Fix line height within side panel

* Display discussion and replies

* Discussions list view

* Threaded replies styling

* Show/hide replies

* DiscussionsList component

* Add DiscussionsList to Discussion view

* Add DiscussionsList to discussion board view

* Create discussion and reply mutations

* Discussion board list filtering

* ViewDiscussions unit tests

* Discussion component unit tests

* Success and error messages

* Feature branch merge conflict fix

* MentionTextArea in DiscussionForm (#2898)

* MentionTextArea in DiscussionForm

* Mention area height-auto

* Text

* Rhf-like signature

* .usa-textarea + overrides

* Cleanup

* MentionTextArea React.forwardRef

* Cleanup

* Fix render error when review has no discussions

* Hide replies if array is empty

---------

Co-authored-by: adamodd <97050498+adamodd@users.noreply.github.com>

* Easi 4633/editor html (#2892)

* starting with schema types

* create type

* some extra types and methods

* add magic

* pull from mint, gql

* some cleanup, remove gql stuff that will be part of a different ticket

* testing dummy route to test out tag parsing

* remove what seemed to be extra sanitizations

* clean up test code, still working on things

* still testing, things looking good for ingestion

* integrating dummy with real

* cleanup similar struct

* update postman call

* add fields to postman call

* postman

* whoops - remove hardcoded sys intake id from postman

* update tag types

* remove unneeded

* fix lint

* update sanitization policy and use it

* leave classs as "mention" to match UI

* postman

* remove commented out item

* unused

* return only HTML, skip tags and extra types

* postman

* remove unused fields

* separate out tagged html policy

* s/eua/uuid

* remove extra fields

* only allow <span> and <p> tags for tagged html

* Update postman, remove TaggedContent, remove console.info

* return first err, update test file, fix some comments

* add additional request for group tag test

* naming

---------

Co-authored-by: ClayBenson94 <clay.benson@oddball.io>

* disallow numbered /bullet lists (#2900)

* disallow numbered /bullet lists

* update extensions

* Fix GRB Discussions SQL files with new SQLFluff linter

* [EASI-4614] Initial email work for GRB Discussions (#2875)

* Add email templates and handlers for grb review discussions

* Add tests for the new emails generated by grb review discussions

* lint

* naming

* s/string/models.HTML

* use builtin `template.HTML` for `DiscussionContent` to avoid escape

* add fuller test data

* update the other templates to have template.HTML

* add the other two email types to `cmd/test_email_templates`

---------

Co-authored-by: Clay Benson <clay.benson@oddball.io>
Co-authored-by: Lee Warrick <32332479+mynar7@users.noreply.github.com>
Co-authored-by: samoddball <156127704+samoddball@users.noreply.github.com>
Co-authored-by: samoddball <sam.lawson@oddball.io>

* Easi 4614/follow up items (#2906)

* adding `IsAdmin` field for conditional template rendering

* add conditionals to html

* add mention

* test mention color, fix horizontal divider

* update tests

* add admin version to test and devdata

* fix test

* add doc, update to only one recipient where only one is needed

* use BCC

* fix tests

* EASI-4667 Side Panel Routing / State management (#2901)

* DiscussionMode query handling

* Update tests with MemoryRouter

* Fix closure typo

* DiscussionList keys

* Create new, submit, go to discussions view

* Open to start discussion view

* `useDiscussion` hook

* `discussionId` determines `activeDiscussion`

* `useDiscussionParams` reorganize

* Oops!

* DiscussionForm -> Cancel -> Back to view mode

* Keep extracted reference instead of redefining literals with `DiscussionMode`

* Rename `useDiscussionParams.ts`

* Finally push

* Reset alert on mode change

* [EASI-4639] Discussion views cleanup (#2907)

* Reorder sub navigation items

* MentionTextArea - fix ref prop

- Passed field ref to `MentionTextArea`
- Updated `innerRef` prop to `ref`
- Added `tabIndex` attribute to `EditorContent` to enable focusing on div

* MentionTextArea - font styling to match Figma

* MentionTextArea - prop types

- Removed unused `shouldValidate` param in `setFieldValue`
- Added comments

* MentionTextArea - non-editable component fixes

- Update text to match Figma
- Remove `usa-textarea` class to fix styling

* Add MentionTextArea to DiscussionPost

* Refetch grbDiscussions after form submit

* MentionTextArea - fix form submit clear text bug

* Truncate text in MentionTextArea

* Truncated text unit test

* Fix textarea rerender on type bug

* Fix focusable div bug when not editable

* MentionTextArea unit tests

* MentionTextArea - fix duplicate ID on wrapper

* Only truncate text on GRB review tab

* Unit test fixes

* Unit test fixes

* [EASI-4635] Discussions API tests (#2908)

add tests for discussion API

* Easi 4645/send emails (#2910)

* remove unused

* implement half of tag handling

* use switch as both groups are not handled the same way

* CC itgov box when it is an admin who is tagged

* working on mechanism to dedupe when needed

* whoops - need to use poster role and info, not recipient

* fix CC in test

* remove DiscussionBoardType from input

* clean up skip conditional

* cautiously adding itgov team email...will double check things

* add `UserAccountsByIDsNP` method, implement group messages

* better naming

* fill in reply functionality, will see if there is a way to DRY this up

* use CreatedBy UUID instead of ID

* nil ptr deref fix attempt

* more nil ptr deref fix attempts

* add emailClient

* one more

* trying with mockSender

* add print

* one more

* still working on this e2e test

* nil check emailClient

* one more nil check

* whoops

* s/warn/info

* whoops - use proper ID

* postman

* swap to fmt for spacing consistency

* fix ids, update discussion links

* refactor resolver logic and touchup email templates without fixing tests

* update postman

* clean up tests

* remove unused enum

* cleanup error handling

* address panics first

* some cleanup

* remove bold tags, going one by one on cleaning up for tests

* hopefully getting closer to matching emails

* Update test email templates to have a valid group name

* passing tests

* urlFromPathAndQuery

---------

Co-authored-by: Clay Benson <clay.benson@oddball.io>
Co-authored-by: Lee Warrick <lee.warrick@oddball.io>

* [EASI-4658] Integrate discussions tagging (#2917)

* Fix ID bug

Removed duplicate ID on container in previous PR. Caused a bug where mention suggestions box does not render correctly. Replacing duplicate ID prop for now.

* Rename reviewers query

* Replace mock mention suggestions with grbReviewers

* Fix duplicate ID on `EditorContent`

Use editor element instead of ID to append suggestions popup

* Typed MentionTextArea component files

* Add `data-label` attr for rendering mentions

* Snapshot

* Fix no results translation and padding

* Display most recent discussion

* Update recent activity to consider replies

* remove self-tagging emails and add tests for discussion emails

* Fix typo and content in GRB Discussion usage tips

* Fix duplicate role types on GRB Reviewers (and delete associated resolvers)

* Remove need for type casting

* swap `<b>` for `<p>` (#2927)

* swap <b> for <p>

* wrap entire line

* EASI-4670 Cypress testing (#2914)

* Discussion board e2e tests begin

* Test reply url

* Comment

* Check user info

* Test mention trigger + participants list

* Clean up

---------

Co-authored-by: Ashley Terstriep <60187543+aterstriep@users.noreply.github.com>
Co-authored-by: samoddball <156127704+samoddball@users.noreply.github.com>

* [NOREF] GRB review nav menu / capitalization fixes (#2931)

* Fix capitalization

* Fix auto scroll

* Remove BE todos

---------

Co-authored-by: samoddball <156127704+samoddball@users.noreply.github.com>
Co-authored-by: Nick Downey <68014929+downeyn-cms@users.noreply.github.com>
Co-authored-by: Ashley Terstriep <60187543+aterstriep@users.noreply.github.com>
Co-authored-by: Lee Warrick <32332479+mynar7@users.noreply.github.com>
Co-authored-by: adamodd <97050498+adamodd@users.noreply.github.com>
Co-authored-by: samoddball <sam.lawson@oddball.io>
Co-authored-by: Lee Warrick <lee.warrick@oddball.io>
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