-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update page link before submitting page form #2636
Conversation
Code Climate has analyzed commit 4113830 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 92.8% (50% is the threshold). This pull request will bring the total coverage in the repository to 82.7% (0.0% change). View more on Code Climate. |
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.
though I suspect this might also happen on real touch devices
Right, I was able to reproduce the issue using the touch screen.
As I can see now, the proposed changes fix that! 🚀
I think this can be applied to events and locations as well.
UPD.
And the same problem occurs when saving to draft or submitting for approval.
33516ef
to
5082abf
Compare
Right, thanks for catching that! I've added a more general solution. |
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.
Looks good to me, thanks!
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.
Sorry for taking so long to get back to you. Looks like this also happens on the develop branch, so it's unrelated to the changes. However, I think it might be intentional - @osmers, should Observers be able to change titles of pages they can edit? If yes, I can open a new issue; |
I have re-checked: But right, if the title field should be disabled, it will solve the problem anyway :) |
Ah, right. Then I guess it's not unrelated anymore, I'll look into it :D |
5082abf
to
4e56fdf
Compare
AH, I mistakenly thought Observers could not change the title, but in fact it's just that they can't directly change the link (so the automatic link update is, of course, not an issue at all here. I've removed the submission prevention for "submit for approval". |
4e56fdf
to
d501e5a
Compare
I think it makes sense that observers can change the title of the page they are allowed to edit. Either they were given the rights to publish right away which means they are trusted to only do what's expected or they can only submit for review, in which case the changes to the title could be rejected if not wanted, right? |
Observer can now submit a title change for approval (the same behavior as in develop) ✅
Actually it seems they can change a link directly (submit a link change for approval), I have just checked in develop. |
d501e5a
to
fbeb59d
Compare
Alright. I think everythin is working now the same as on develop, plus touch screens work. However, I have not fixed the underlying bug (which is that the I think we should either
I like the second option better, but wasn't sure if there's some unintended consequences. |
fbeb59d
to
373c0e1
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.
Thank you very much! Looks really good! I really would like to have a test for this, but since we don't have JS tests yet, I think we can give it a pass
Yes, fair 😅 Any suggestions on how to handle the |
Oh sorry, I forgot to mention that. I also tend towards the second option. I think the PermissionDenied indicates that somewhere we have a logical thinking error in our permissions. I think changing the permission should be the right thing 🤔 |
Sounds better to me, because if Observer has the right to modify the link directly, then modifying the link should also work for Observer through ajax. I think that would be more consistent. |
373c0e1
to
ebd42da
Compare
Alright, I've lowered the required permissions. "Worst case" someone can generate a slug for a content objects they shouldn't - but since the function only returns the generated slug, not actually saves it, I think that's OK. I have also let the client-side error handling in, just in case anything else occurs server-side we still release the submission lock. |
8af7760
to
7f2d590
Compare
This could be eliminated if we check for "cms.change_page_object" permission instead of "is user.role == Observer". Smthg like:
But I don't insist here, let me know if you would prefer to keep the current implementation. |
9161eae
to
7220a42
Compare
You're absolutely right, that makes a lot more sense. Tbh I completely forgot that checking permissions for a specific object is an option... 😅 |
3bc8dca
to
2be6d88
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.
I've re-tested everything again and found no new problems except the one caused by removing the if-condition in the templates.
As soon as the if-s are returned, I think it's good to go 🤞
Thanks for tackling this tricky issue!
2be6d88
to
87a67ca
Compare
87a67ca
to
4113830
Compare
No, thank YOU for the thorough reviews and attention to detail!! Seriously, without you, this PR might have solved the original issue, but would also have introduced multiple new bugs. Thank you 💛 |
Short description
I had a bit of trouble reproducing the issue. The only way I could trigger it was by entering Firefox's Responsive Design Mode and enabling Touch Simulation (though I suspect this might also happen on real touch devices).
I don't think this is worth an entry in the change log, this really is an edge case.
Proposed changes
slugify
, prevent the submission, then trigger it again once the previous call completed.Side effects
Resolved issues
Fixes: #2624
Pull Request Review Guidelines