From 0e1157bf764838f7325aac778d2be9722c747aee Mon Sep 17 00:00:00 2001 From: Philipp Veller Date: Tue, 19 Nov 2024 17:15:08 +0100 Subject: [PATCH] react/ratings: adapt ratings buttons to have new icons, more modern code and tests --- .../comments/static/comments/Comment.jsx | 3 +- .../__snapshots__/comment.jest.jsx.snap | 100 +++++++++-- .../static/comments_async/comment.jsx | 4 +- .../ratings/static/ratings/RatingBox.jsx | 83 +++++++++ .../ratings/static/ratings/RatingButton.jsx | 40 +++++ .../ratings/__tests__/RatingBox.jest.jsx | 161 ++++++++++++++++++ .../ratings/__tests__/RatingButton.jest.jsx | 37 ++++ .../__snapshots__/RatingBox.jest.jsx.snap | 12 ++ .../ratings/static/ratings/rating_api.js | 102 +++++++++++ .../ratings/static/ratings/react_ratings.jsx | 154 +---------------- .../ratings/templatetags/react_ratings.py | 2 +- changelog/8529.md | 9 + docs/react_ratings.md | 127 ++++++++++++++ jest.config.js | 2 +- setupTests.js | 2 + tests/ratings/test_rating_templatetags.py | 2 +- 16 files changed, 665 insertions(+), 175 deletions(-) create mode 100644 adhocracy4/ratings/static/ratings/RatingBox.jsx create mode 100644 adhocracy4/ratings/static/ratings/RatingButton.jsx create mode 100644 adhocracy4/ratings/static/ratings/__tests__/RatingBox.jest.jsx create mode 100644 adhocracy4/ratings/static/ratings/__tests__/RatingButton.jest.jsx create mode 100644 adhocracy4/ratings/static/ratings/__tests__/__snapshots__/RatingBox.jest.jsx.snap create mode 100644 adhocracy4/ratings/static/ratings/rating_api.js create mode 100644 changelog/8529.md create mode 100644 docs/react_ratings.md diff --git a/adhocracy4/comments/static/comments/Comment.jsx b/adhocracy4/comments/static/comments/Comment.jsx index 62478dbee..397b2b465 100644 --- a/adhocracy4/comments/static/comments/Comment.jsx +++ b/adhocracy4/comments/static/comments/Comment.jsx @@ -1,5 +1,5 @@ const ReportModal = require('../../../reports/static/reports/react_reports').ReportModal -const RatingBox = require('../../../ratings/static/ratings/react_ratings').RatingBox +const RatingBox = require('../../../ratings/static/ratings/RatingBox') const Modal = require('../../../static/Modal') const CommentEditForm = require('./CommentEditForm') const CommentForm = require('./CommentForm') @@ -86,6 +86,7 @@ class Comment extends React.Component { userRating={this.props.userRating} userRatingId={this.props.userRatingId} isReadOnly={this.props.isReadOnly} + isComment /> ) } diff --git a/adhocracy4/comments_async/static/comments_async/__tests__/__snapshots__/comment.jest.jsx.snap b/adhocracy4/comments_async/static/comments_async/__tests__/__snapshots__/comment.jest.jsx.snap index 6003349b8..0deddc9b8 100644 --- a/adhocracy4/comments_async/static/comments_async/__tests__/__snapshots__/comment.jest.jsx.snap +++ b/adhocracy4/comments_async/static/comments_async/__tests__/__snapshots__/comment.jest.jsx.snap @@ -71,38 +71,55 @@ exports[`Comment Component renders comment with creator and comment text 1`] = ` >