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
825 add toggle to add/remove current site to/from element sites #875
base: dev-2.2.0
Are you sure you want to change the base?
825 add toggle to add/remove current site to/from element sites #875
Conversation
need to re-do the commits and add the tests but buttons seem to be working like this |
8b60c37
to
23767c6
Compare
23767c6
to
395ce52
Compare
ca32db7
to
d10fa87
Compare
2bd6281
to
c3abc7a
Compare
c3abc7a
to
64f1fec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work. I have some minor suggestions.
const ToggleCurrentSiteLink = ({ has_current_site, locked, onClick, disabled }) => { | ||
const className = classNames({ | ||
'element-btn-link fa': true, | ||
'fa-plus-square-o': !has_current_site, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The icons are not super, but I don't have a better suggestion. Maybe the transition to material symbols will solve this at one point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fa-plus-square
and fa-minus-square
…ion mixins, makes urls part of api/v1
const ToggleCurrentSiteLink = ({ has_current_site, locked, onClick, disabled }) => { | ||
const className = classNames({ | ||
'element-btn-link fa': true, | ||
'fa-plus-square-o': !has_current_site, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ToggleCurrentSiteLink = ({ has_current_site, locked, onClick, disabled }) => { | ||
const className = classNames({ | ||
'element-btn-link fa': true, | ||
'fa-plus-square-o': !has_current_site, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fa-plus-square
and fa-minus-square
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
… rename hasCurrentSite Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
65ef10e
to
8757d2c
Compare
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this whole file to rdmo/core/tests/utils.py
? I am not a big fan of to much indirection in tests (I got that from 2 scoops of django), but I guess it makes sense here. I a bigger test cleanup we could also move some of the constants to this file as well. Maybe a constants.py
and a utils.py
.
Another idea would be to use fixtures for this (the utils part).
return function(dispatch, getState) { | ||
dispatch(storeElementInit(element)) | ||
|
||
dispatch(storeElementInit(element, elementAction)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think elementAction
is not needed here.
Description
The new endpoints that add or remove the current site from the
sites
of an element are:Django back-end
questions
PUT /api/v1/questions/catalogs/{id}/toggle-site/
tasks
PUT /api/v1/tasks/tasks/{id}/toggle-site/
views
PUT /api/v1/views/views/{id}/toggle-site/
These are defined in a new
ViewSetMixin
,ElementToggleCurrentSiteViewSetMixin
inrdmo/management/viewsets.py
. This mixin has one actiontoggle-site
and only forput
is allowed.It adds or removes the current site from the object, depending on whether is was there already or not (like a toggle).
For permissions it uses a new (rules-based)
CanToggleElementCurrentSite
permission class.The mixin class could be simplified by removing the
serializer_class
and theget_queryset
method.Could we adapt the
ElementSucces
reducer to not need the serialized object for these actions?Permissions could by checked right in the action methods by eg.
test_rule()
.React front-end:
ToggleCurrentSiteLink
inrdmo/management/assets/js/components/common/Links.js
elementAction
tostoreElement
andstoreElementInit
MultiSiteApi.js
storeElement
via theaction
Related issue: #825
Motivation and Context
How has this been tested?
Screenshots (if appropriate)
Logged in as example-editor.
Types of Changes
Checklist