0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
Commit graph

730 commits

Author SHA1 Message Date
Kevin Ansfield
3dd33968f5 Improved various aspects of comments app
ref https://linear.app/ghost/issue/PLG-300/

Full details available soon on https://ghost.org/changelog/

- removed `commentImprovements` labs flag conditionals
2024-12-12 19:03:23 +00:00
Sanne de Vries
86ee480d45
Updated avatar icon for removed comments (#21864)
No ref
- The previous avatar icon was too busy visually.
2024-12-11 10:10:22 +00:00
Kevin Ansfield
e86d44ff85 Fixed replies line showing after all replies have been deleted
ref https://linear.app/ghost/issue/PLG-267

- updated delete comment action so it removes comments rather than just updating their status to `'deleted'`
- deleted comments that still have replies have their status updated so the replies remain visible
- matches updated API behaviour where deleted comments are not shown at all
2024-12-11 08:41:27 +00:00
Kevin Ansfield
0f9449137f Fixed comment count in comments-ui when logged in as admin
closes https://linear.app/ghost/issue/PLG-297

- we were setting the comment count Admin API browse comments response meta pagination data which will never be correct because it only counts top-level comments for pagination purposes
- we have a public comment counts endpoint that is already fetched, there's no need to override that when using the Admin API because the overall count doesn't change across API's, even when the Admin API includes hidden comments because those don't impact the visible count
- updated test setup so the title and count is shown so it can be asserted against
- updated mocked api to correctly return count of all published comments+replies
2024-12-10 18:59:49 +00:00
Kevin Ansfield
1fb417b6a3 Fixed dropdown menu being cut off in comments-ui
closes https://linear.app/ghost/issue/PLG-273

- removed previous fix which only worked on last comment but not last reply
  - keeping track of last comment/reply spread a lot of domain knowledge around for a UI-only concern and wouldn't scale if we have other dropdowns in the future
- added `useOutOfViewportClasses` hook
  - accepts an object with top/bottom/right/left containing default and outOfViewPort classes
  - applies the correct classes using the DOM rather than React so that we avoid re-renders and associated flickering or broken rendering
2024-12-10 17:15:29 +00:00
Ronald Langeveld
04f0b9fc3f
Fixed comment likes being incorrect when logged in as an Admin (#21833)
ref https://linear.app/ghost/issue/PLG-296/

When logged in as an Admin, comments-ui switches comment reads from the Members API over to the Admin API so that hidden comments can be displayed to allow moderation activities. However, the Admin API not using member authentication and CORS preventing the front-end members auth cookie being passed over to the Admin API domain meant that the logged-in member's likes were missing when fetching via the Admin API as there is no available reference to the logged in member.

This change works around the problem by introducing an `impersonate_member_uuid` param to the comments read/browse endpoints of the Admin API. When passed, the provided uuid is used to simulate that member being logged in so that likes are correctly shown.

- Introduced `impersonation_member_id` parameter to resolve issues with admin API not returning correct "liked" status for comments when an admin is logged in.
- Updated API endpoints in `comment-replies.js` and `comments.js` to handle `impersonation_member_id`.
- Adjusted `CommentsController` to validate and process the `impersonation_member_id` parameter before passing it to database queries.
- Enhanced test coverage to ensure proper handling of the new parameter and accurate "liked" status behavior.
2024-12-10 14:44:15 +00:00
Kevin Ansfield
5ec9f59411 Removed unused useSecondUpdate hook in comments-ui
no issue

- left over after cleanup of secondary form code
2024-12-09 14:51:27 +00:00
Sanne de Vries
972cc82958
Prevented top-level comment input from closing when it has text (#21795)
REF https://linear.app/ghost/issue/PLG-298/

- When you're typing a comment, and exit the input field, it collapses into a non-editable state; you first have to click on it again to "open" the form. This means you can't select the text or instantly start typing again. When the input has a value, we should stop it from closing.
- added custom `useEditor` hook that wraps TipTap and exposes both the `editor` and `hasContent` props keeping logic out of the consuming components

---------

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2024-12-09 13:42:24 +00:00
Ronald Langeveld
dbcbabb99a
Add comments loading state action (#21834)
ref https://github.com/TryGhost/Ghost/pull/21788#discussion_r1869802093

- Introduced `setCommentsIsLoading` action to handle the loading state
of comments dynamically.
- Updated `setOrder` function to dispatch the `setCommentsIsLoading`
action, ensuring proper UI feedback during asynchronous operations.
2024-12-09 16:09:14 +08:00
Sanne de Vries
9350ccf1db Removed hover effect on replied-to refs for unpublished comments
REF https://linear.app/ghost/issue/PLG-294/remove-link-from-replied-to-[hiddenremoved]
2024-12-05 18:02:38 +00:00
Kevin Ansfield
7e60172027 Removed link from replied-to ref when deleted/hidden
closes https://linear.app/ghost/issue/PLG-294

- making the `replied to: [removed]` text a link was a bit confusing because clicking it does nothing
- if the replied-to comment doesn't exist (e.g. hidden/deleted and not returned in API response) or has been unpublished we replace the `<a>` with a `<span>` to remove the link behaviour
2024-12-05 18:02:38 +00:00
Kevin Ansfield
0651d7178b Extracted <RepliedToSnippet> component from <CommentHeader>
no issue

- keeps logic inside `<CommentHeader>` single-purpose
- allows for cleaner code when adding logic to remove the link when the replied-to comment is removed
- switched `queryByText` to `getByText` in the test to make debugging easier, the latter will print the current DOM if it fails to find an element

# Conflicts:
#	apps/comments-ui/src/components/content/Comment.tsx
2024-12-05 18:02:38 +00:00
Sanne de Vries
f06de99410
Added highlight animation when scrolling to replied-to comment (#21781)
REF https://linear.app/ghost/issue/PLG-284

When clicking on a replied-to reference, you scroll up to the parent comment. To guide the eye, the parent comment is highlighted with a yellow background.

- added `dispatchAction` to the `ActionHandler` function call arguments, allowing actions to call other actions
- added `commentIdToHighlight` app context state and associated `highlightComment` action to set it
- updated `Comment` (and related sub-components) to match `commentIdToHighlight` when rendering to determine whether to apply highlighting of comment contents
- for the highlight, `<mark>` is used to wrap any paragraphs inside the comment contents and appropriate tailwind highlight animation classes applied
  - uses the inline `<mark>` element so that background highlight only applies to the text bounding boxes rather than the entire wrapping element

---------

Co-authored-by: Ronald Langeveld <hi@ronaldlangeveld.com>
2024-12-05 17:46:16 +00:00
Ronald Langeveld
7c1d7080e9
Bumped comments-ui to 0.24.1 (#21797)
ref PLG-293
2024-12-04 02:48:20 +00:00
Ronald Langeveld
55dc9d997f
Added loading state when ordering comments (#21788)
PLG-280

- Added a loading state implementation when changing the ordering of
comments.
- This improves the overall UX particularly with slower connections.
- Due to the nature of how comments and ordering are handled, we
approached it with a simple state that determines whether it's done
loading or not around the API query.

---------

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
2024-12-04 10:16:58 +08:00
Sanne de Vries
0757f270eb
Updated hidden/removed comment copy on API side (#21796)
REF
https://linear.app/ghost/issue/PLG-295/change-copy-for-replied-to-[hiddenremoved]
- Updated the copy from hidden/removed to removed on API side and in
i18n context.json for consistency
2024-12-03 19:05:42 +00:00
Sanne de Vries
4fa929e1c4
Fixed z-index issue of sorting dropdown and hidden comments (#21793)
REF
https://linear.app/ghost/issue/PLG-292/sorting-dropdown-z-index-issue-with-hidden-comments
- The dropdown would appear behind hidden comments
2024-12-03 17:04:00 +00:00
Sanne de Vries
99d5dea877
Updated copy for replied-to reference of removed comments (#21792)
REF
https://linear.app/ghost/issue/PLG-295/change-copy-for-replied-to-[hiddenremoved]
- No distinguishing needed between hidden and removed comments, which is
the same to the reader. "Removed" is more simple and understandable.
2024-12-03 16:57:50 +00:00
Kevin Ansfield
badd6d8f97 Shipped comments-ui@0.24.0
no issue

- bumped minor to delay comments-ui update until next Ghost release
- includes numerous styling fixes, display of replies when editing a comment, and updates to in-reply-to snippets when deleting/hiding comments
2024-12-02 23:37:44 +00:00
Kevin Ansfield
9da9757f1f
Changed in-reply-to snippet to show [hidden/removed] (#21731)
closes https://linear.app/ghost/issue/PLG-263/

When hiding a reply as an Admin, if there were other replies that referenced it then those snippets would still show the hidden content because there was no immediate update in the comments-ui client. This made it look like hidden content would still be visible even though at the API level snippets were entirely removed so no other user would see it.

- added client-side handling so in-reply-to snippets immediately show `[hidden/removed]` which means we don't have to fetch every reply from the API
- updated the API to use `[hidden/removed]` as the snippet when referencing a hidden reply instead of removing all `in_reply_to_` data
  - keeping `in_reply_to_id` and `in_reply_to_snippet` means comments-ui still displays the replied-to reference text (albeit not directly showing the API-supplied string so `[hidden/removed]` can be translated)
  - returns the full `in_reply_to_snippet` text for Admin API requests so that showing a comment that has been loaded from the API can immediately show the contents for any displayed references to the comment
2024-12-02 23:12:01 +00:00
Sanne de Vries
4e806f7de4
Ensured replies remain visible when parent comment is being edited (#21756)
REF https://linear.app/ghost/issue/PLG-274/

- Currently, replies are hidden when the parent comment is being edited. This PR ensures that replies remain visible when the parent comment is being edited.
- To achieve this, the `CommentComponent` now checks if the parent comment is being edited. If so, the comment content is swapped by the EditForm, while the comment's avatar, header, menu, and replies remain visible.
- The Form component now only renders the FormEditor. A FormWrapper component is used to wrap the avatar and comment header.
- This Form component is used in the EditForm without the FormWrapper, as it is already wrapped in the CommentComponent.
- The ReplyForm and the MainForm use the FormWrapper.
- The Avatar component now also accepts a `member` prop, which is used to display the avatar image. This is because it's no longer used inside the Form component.
2024-12-02 22:17:15 +00:00
Sanne de Vries
5c3e26351a
Change blockquote border color to accent color (#21780)
REF
https://linear.app/ghost/issue/PLG-291/add-support-for-blockquote-border-in-darkmode
- The border color was invisible in dark mode. Instead of adding a white
border for dark mode, it now uses the accent color. This matches link
and buttoncolors in comments, and makes it stand out more.
2024-12-02 15:45:58 +00:00
Sanne de Vries
029177fa69
Fixed delete button being clickable multiple times (#21736)
REF
https://linear.app/ghost/issue/PLG-287/fix-double-click-on-delete-button-impacting-comment-count
2024-11-27 12:43:30 +01:00
Sanne de Vries
52d15cf955
Updated comments spinner style for light mode sites (#21734)
REF
https://linear.app/ghost/issue/PLG-272/look-into-potential-spinner-regression
2024-11-27 10:55:40 +01:00
Kevin Ansfield
04f337e085 Fixed comments-ui tests not properly mocking actions on replies
no issue

- `MockedApi.browseComments` only worked on top-level comments, it couldn't find replies when passed `filter:'id:123'` such is used when liking and editing replies
- fixed missing get handler for fetching single comment via Admin API (used after showing a hidden comment)
- added `flattenComments` and `findCommentById` helper functions to facilitate easier finding of a comment or reply within the nested structure
- added tests for liking and hiding replies
2024-11-26 18:34:02 +00:00
Kevin Ansfield
cdea73b873 Refactored comments-ui admin moderation tests
no issue

- expanded e2e test behaviour to route Admin requests through our MockedApi instance so we have the same test experience for normal and admin comments requests
- extracted page route method bodies to enable request methods to be spied on
- updated admin moderation tests to properly use admin requests
2024-11-26 14:30:23 +00:00
Sanne de Vries
6c064b73e4
Fixed spinner being invisible in light mode (#21727)
REF
https://linear.app/ghost/issue/PLG-272/look-into-potential-spinner-regression
2024-11-26 14:00:23 +01:00
Ronald Langeveld
781bfdd60f
Wired up admin api for hidden comments (#21724)
ref PLG-270

- Updated the getCommentByID service to filter out hidden and deleted
replies.
- Ensured all replies are loaded before applying the filter.
- Simplified logic to handle non-paginated routes by directly removing
unwanted replies.
- Wired up new Admin Endpoint that shows hidden replies but not deleted
replies.
- Updated comments-ui client
- Added unit tests for mocking apiClient event listeners.
- added eventlistener playwright tests to ensure it fires on UI clicks.
2024-11-26 16:56:17 +08:00
Sanne de Vries
5b70c7d1d7
Improved vertical indentation alignment (#21718)
REF
https://linear.app/ghost/issue/PLG-275/improve-vertical-indentation-alignment
2024-11-25 14:39:17 +00:00
Sanne de Vries
5e42c3146d
Improved disabled state for "Add comment" button (#21717)
REF
https://linear.app/ghost/issue/PLG-281/change-button-to-being-disabled-without-input
2024-11-25 13:12:49 +00:00
Sanne de Vries
8371b6699f
Added confirmation popup for comment deletion (#21715)
REF
https://linear.app/ghost/issue/PLG-285/add-confirmation-modal-upon-comment-deletion
2024-11-25 12:04:31 +00:00
Sanne de Vries
2d9b593844
Added hover styles to comment context menus (#21714)
REF https://linear.app/ghost/issue/PLG-283/add-hover-state-to-menu-items
2024-11-25 11:41:10 +00:00
Sanne de Vries
1a0a36b64c
Changed click target for comment replied-to ref (#21713)
REF
https://linear.app/ghost/issue/PLG-282/change-click-target-for-replied-to-reference
2024-11-25 11:34:40 +00:00
Sanne de Vries
ac3467165d
Updated "Replied to comment" copy (#21711)
REF
https://linear.app/ghost/issue/PLG-278/update-replied-to-comment-copy
2024-11-25 11:10:00 +00:00
Kevin Ansfield
d204d67d1f Cleaned up comments-ui actions test setup duplication
no issue

- repeated use of the same init data made tests longer than they needed to be, especially as the number of tests grows
- added `initializeTest()` function to remove unnecessary duplication
2024-11-25 10:52:31 +00:00
Sanne de Vries
f06a766189
Replaced reply icon in comments-ui (#21710)
REF https://linear.app/ghost/issue/PLG-271/replace-reply-icon
2024-11-25 08:59:19 +00:00
Ronald Langeveld
253e596138
Reverting 2 commits (#21709)
no issue

- need to add an additional change.
2024-11-25 08:58:06 +00:00
Ronald Langeveld
6c3753f403
Bumped comments-ui to a new minor (#21708)
no issue

- Bumping to a new minor due to API changes.
2024-11-25 08:42:31 +00:00
Ronald Langeveld
31a80cf9b8
Fixed hidden/deleted replies in getCommentByID (#21707)
ref PLG-270

- Updated the getCommentByID service to filter out hidden and deleted
replies.
- Ensured all replies are loaded before applying the filter.
- Simplified logic to handle non-paginated routes by directly removing
unwanted replies.
- Wired up new Admin Endpoint that shows hidden replies but not deleted
replies.
- Updated comments-ui client.
2024-11-25 08:15:08 +00:00
Kevin Ansfield
0ac36bd324 Shipped comments-ui@0.22.4
no issue

- includes fix for reply-to-reply form not showing when parent comment is hidden
2024-11-21 18:49:18 +00:00
Kevin Ansfield
d1019a8e54 Fixed reply-to-reply comment form not showing when parent is hidden
closes https://linear.app/ghost/issue/PLG-266

- the reply form is a child of the parent comment component but we have different comment components for published vs unpublished with the bug coming from the latter missing the logic to display the form
- added missing form display and added a regression test
2024-11-21 18:44:23 +00:00
Kevin Ansfield
e5a21aaf54 Shipped comments-ui@0.22.3
no issue

- includes fix for missing progress indicator when submitting forms
2024-11-21 16:12:31 +00:00
Kevin Ansfield
0b806cc01b 🐛 Fixed missing progress indicator when submitting comments
closes https://linear.app/ghost/issue/PLG-265

- wrapped the async part of `dispatchAction` in a Promise so code that calls it can await the action completion
  - this was a regression introduced a long time ago when we switched to Typescript and React hooks
- added a `setDelay()` method to our `MockedApi` class to make it easier to test interstitial loading states
2024-11-21 16:03:30 +00:00
Ronald Langeveld
4202cf137e
Bumped Comments-UI to 0.22.2 (#21678)
no issue
2024-11-21 11:04:41 +00:00
Ronald Langeveld
cf6884d098
Wired up Admin Comment Endpoints to UI (#21661)
ref PLG-227

- Updated logic that allows Admin Users on comments to interact with
some endpoints from a specific admin-only route.
- It pulls 2 admin specific routes:
- 1. an admin specific 'browse' route that includes hidden comments that
would otherwise be hidden from regular users and members.
- 2. A specific replies route, that would also include hidden comments
- This was needed in order to get accurate pagination.

- Additionally, it wires up the routes via `message-handler` that deal
with the potential cors issues.
- Includes style updates

---------

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2024-11-21 10:52:36 +00:00
Kevin Ansfield
33709e7d0c Shipped comments-ui@0.22.1
no issue

- includes updated timestamp formatting
2024-11-20 15:30:53 +00:00
Sanne de Vries
ea1b786136
Updated timestamp format for comments (#21515)
ref https://linear.app/ghost/issue/PLG-235

- Any comments older than yesterday are now shown with the date instead of relative time
- Comments from the current year are now shown with just the month and day

---------

Co-authored-by: Kevin Ansfield <kevin@ghost.org>
2024-11-20 15:25:49 +00:00
Kevin Ansfield
46bdbaa3b8 Shipped comments-ui@0.22.0
no issue

- includes updates behind `commentImprovements` flag
- bumped to 0.22 to avoid changes going live before next Ghost release
2024-11-20 12:33:53 +00:00
Sanne de Vries
5bbb98b661
Hooked up the CTA popup to the reply button (#21663)
REF
https://linear.app/ghost/issue/PLG-262/unhide-the-reply-button-when-comments-is-paywalled
- Previously, the reply button was hidden when the comments were
paywalled. Now, the button is visible and triggers a signup or upgrade
popup.
2024-11-20 10:10:50 +01:00
Kevin Ansfield
52e727a28c
Added in-reply-to references to comments-ui (#21656)
ref https://linear.app/ghost/issue/PLG-230

When clicking "Reply" on a reply we now show an "In reply to" reference on the form and when saved show that reference in the rendered view, making it easier to follow discussions within comment replies.

- updated calls to `openCommentForm` action when opening a reply to add the in-reply-to data to the `openForm` instance
- updated Form comment to use the `openForm` instance data when rendering the in-reply-to reference
- updated Comment component to render the in-reply-to reference from the API-provided data
  - includes click handler to scroll to the referenced comment
- added `getCommentInReplyToSnippet` helper function so strip a comment back to plaintext for display in the reply-to reference on the comment form (snippets on other comments are generated server-side)

---------

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
2024-11-19 17:30:18 +00:00