-
Notifications
You must be signed in to change notification settings - Fork 855
Forms: Add feedback notes support #46309
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
92f38e0
Forms: Add feedback comments
enejb b4b362c
changelog
enejb 710426f
fix typo
enejb c81d555
fix dependencies
enejb d3b4769
add alt text
enejb 2803dcb
rename file with typo
enejb 59b5896
Make it work nicer on mobile
enejb b957c1a
Make it work with more then 100 comments
enejb bcb68e3
fix linter
enejb 6e575aa
Use the core store to store the comments updates instead of fetch end…
enejb 491c690
fix php tests
enejb d9d72e2
Remove the empty state css
enejb f2fab0d
Make isDeleteing be comment specific.
enejb b67caac
Update projects/packages/forms/src/dashboard/components/feedback-comm…
enejb dcb99b3
Remove perPage from dependencies
enejb 736fed7
fix linter
enejb e8810a7
wrap with safeHTML
enejb 862d432
make notes more locked down
enejb 35f35e6
Update the tests
enejb 2b24fdf
update the pnpm lock files
enejb 518df32
Add support for enabling form notes feature
enejb ad55db8
Pass throwOnError option to deleteEntityRecord
enejb 2c39ce1
Fix typo
enejb 0ebd2c3
minor fix
enejb f150c63
minor fixes
enejb 4e2113f
Minor fixes
enejb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/packages/forms/changelog/add-feedback-comment-support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Type: added | ||
|
|
||
| Forms: add feedback comments | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
projects/packages/forms/src/dashboard/components/feedback-comments/comment-item.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import { DropdownMenu } from '@wordpress/components'; | ||
| import { dateI18n, getSettings as getDateSettings } from '@wordpress/date'; | ||
| import { safeHTML } from '@wordpress/dom'; | ||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { __, sprintf } from '@wordpress/i18n'; | ||
| import { moreVertical, trash } from '@wordpress/icons'; | ||
| import type { FeedbackComment } from '../../../types'; | ||
|
|
||
| export type CommentItemProps = { | ||
| comment: FeedbackComment; | ||
| onDelete: ( id: number ) => void; | ||
| isDeleting: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Format comment date using WP settings. | ||
| * | ||
| * @param dateString - ISO date string from the comment | ||
| * @return Formatted date/time string | ||
| */ | ||
| function formatCommentDate( dateString: string ) { | ||
| return sprintf( | ||
| /* Translators: %1$s is the date, %2$s is the time. */ | ||
| __( '%1$s at %2$s', 'jetpack-forms' ), | ||
| dateI18n( getDateSettings().formats.date, dateString ), | ||
| dateI18n( getDateSettings().formats.time, dateString ) | ||
| ); | ||
| } | ||
|
|
||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Renders a single feedback comment item, including author, date, content, | ||
| * and an options menu to delete the comment. | ||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * @param {CommentItemProps} props - Component props. | ||
| * @param {FeedbackComment} props.comment - The feedback comment to display. | ||
| * @param {(id: number) => void} props.onDelete - Callback invoked when the delete action is selected. | ||
| * @param {boolean} props.isDeleting - Whether a delete operation is currently in progress. | ||
| * @return {JSX.Element} The rendered feedback comment item element. | ||
| */ | ||
| const CommentItem = ( { comment, onDelete, isDeleting }: CommentItemProps ) => { | ||
| return ( | ||
| <div key={ comment.id } className="jp-forms__feedback-comments-comment"> | ||
| <div className="jp-forms__feedback-comments-comment-meta"> | ||
| <strong className="jp-forms__feedback-comments-comment-author"> | ||
| { comment.author_name } | ||
| </strong> | ||
| <span className="jp-forms__feedback-comments-comment-date"> | ||
| { formatCommentDate( comment.date ) } | ||
| </span> | ||
| <DropdownMenu | ||
| icon={ moreVertical } | ||
| label={ __( 'Note options', 'jetpack-forms' ) } | ||
| controls={ [ | ||
| { | ||
| title: __( 'Delete', 'jetpack-forms' ), | ||
| icon: trash, | ||
| onClick: () => onDelete( comment.id ), | ||
| isDisabled: isDeleting, | ||
| }, | ||
| ] } | ||
| /> | ||
| </div> | ||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <div | ||
| className="jp-forms__feedback-comments-comment-content" | ||
| // eslint-disable-next-line react/no-danger | ||
| dangerouslySetInnerHTML={ { __html: safeHTML( comment.content.rendered ) } } | ||
| /> | ||
enejb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommentItem; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.