Conversation
|
@mrcasals @josepjaume @oriolgual I don't know if you have already found the drawback that I comment on the description (for example, with proposals), or even if it is done deliberately to avoid users to perform actions before visiting the resource page. In my case, I'm facing this issue when trying to render some cells on the home page; I don't know if that kind of scenario is on the project roadmap. Also, I've had problems with naming. I couldn't implement the new controller in the verifications gem because its needed to be used from the core gem. On the other hand, I couldn't give the name |
155cf76 to
d30198e
Compare
deivid-rodriguez
left a comment
There was a problem hiding this comment.
@leio10 Looks great to me and I don't think the slight delay when loading modals is an issue, although we might want to add some "loading icon tweaks" to the buttons or something to prevent unresponsiveness.
I added some minor comments but in general totally in favor of doing this!
| data: { disable: true }, | ||
| class: "card__button button expanded success disabled", | ||
| id: "unvote_button" do %> | ||
| <%= button_to decidim_consultations.question_question_votes_path(question), |
There was a problem hiding this comment.
Why was this changed? The interface should be the same and the only change would be that the modal is ajaxly loaded, right?
There was a problem hiding this comment.
Yes, you are right that is not strictly related to this change. Is the same fix than this one but in the consultations module. Both consultations and initiatives are not components, but participatory spaces, so they don't have authorizations. I understand that these helpers are only used to show the login modal if needed.
For these cases, I defined the logged_button_to and logged_link_to and used them in this file and in the initiatives module templates.
But in this very specific case, this is not needed, because it is only rendered if the user is signed in. I guess that is the same reason why @mrcasals has done this.
There was a problem hiding this comment.
Aha, understood! 👍
| class ModalsController < Decidim::ApplicationController | ||
| helper_method :status, :authorize_action_path | ||
|
|
||
| def authorization |
There was a problem hiding this comment.
Regarding the naming issue you mentioned, what about changing the controller name to AuthorizationModalsController and this action to show?
| close_modal: Tanca el modal | ||
| filter: Filtre | ||
| filter_by: Filtra per | ||
| unfold: Desplegar |
There was a problem hiding this comment.
I don't think this key movement is intended.
There was a problem hiding this comment.
Thanks! I catched it in the spanish translation but missed it here.
|
|
||
| it "renders with a block" do | ||
| rendered = helper.action_authorized_link_to("foo", "fake_path") { "Link" } | ||
|
|
There was a problem hiding this comment.
Super tiny style note, you might want to remove this blank line for consistency with the other specs (although I think visually splitting non assertions from assertions reads better, so you might as well add a blank line to the other specs).
There was a problem hiding this comment.
I agree with you that it reads better with an extra space there, and I don't see a clear guideline in other spec files, so I'm adding blank lines to every other specs
There was a problem hiding this comment.
I like having non-assertions and assertions separate, but It's a rule I don't enforce even on myself so... 🤷♂️ There's some inconsistency throughout the code about this.
There was a problem hiding this comment.
Yeah, since rubocop-rspec don't support it, it's hard to enforce. Maybe I'll do a feature request :)
|
@deivid-rodriguez Thanks for the feedback!! ❤️ ❤️ I have "Adding a Loading message" in the pending tasks list, but I didn't see any loading message in the rest of the project, so I don't have a place to copy from. 😞 |
|
Yeah, I don't recall any loading spinners in the project either... And it doesn't look like foundation reveal has anything built-in. Maybe this thread has some ideas: https://foundation.zurb.com/forum/posts/35569-reveal-modal-loading-state. |
|
@leio10 the only "loading" message we have is on the processes list, when you change the filters (below the highlighted processes). I think a spinner would be useful in other places too (eg when filtering proposals list) |
|
@deivid-rodriguez @mrcasals maybe we could just take an icon from https://decidim-design.herokuapp.com/public/library/pattern-library and make it spin with CSS. I guess that |
21ef12f to
70976c9
Compare
|
@deivid-rodriguez I think I've addressed all your suggestions |
|
@leio10 Just tried it. It looks awesome! Screenshot below (don't worry, I added |
| layout false | ||
|
|
||
| def show | ||
| render |
There was a problem hiding this comment.
I don't think you need the render as long as there's an unlerlying template with the right name. I actually learnt from @oriolgual that you don't even need the action at all, as long as the template exists with the right name, although I find that style very obscure...
eb41d7d to
6e8da74
Compare
|
I hope I'm finished this PR with these last commits. I've updated the CHANGELOG file and I've recovered the
|
@leio10 when adding cells, we weren't sure you should be able to vote a proposal from the search page, so we didn't implement it and didn't check if that worked 😅 |
|
@leio10 code looks really good, and the authorizations sections it's something mostly you and @deivid-rodriguez have been working on, so if you two don't see any possible error on it then I'm totally 👍 on the change. About the |
@mrcasals I'm sorry if that seemed like a complain about the code, it was just an argument to justify the need of this PR. I'm very glad with the use of cells, and having that limitation was a little "thorn in the side" (or "stone in the shoe", as we would say in spanish). 😄 |
I didn't take it as a complaint, I just wanted to explain why this isn't currently possible 😄 |
|
Actually, Rails released this feature for this exact use case, no? |
|
Brain storming a bit here. What if we pass the action authorization cache as cell context in the base card? I think we're doing the same thing with the |
I like that feature, but I think is also more for the
I like this approach, I think is the best option for this moment 👍 |
|
@deivid-rodriguez I've been playing for a while with cells context and things get much more complicated (the I would leave it as is, and would evaluate in the future the convenience of having one or more CurrentAttributes classes to store the variables stored in the |
|
Sounds good to me @leio10! 👍 |
726b170 to
3b19f49
Compare
|
Re: Apart from that, everything looks good to me. @deivid-rodriguez do you mind reviewing the code? I trust you more than myself here 😄 |
|
@mrcasals the code doesn't changed since the last @deivid-rodriguez revision, I just rebased it to resolve conflicts and force to report coverage. 😄 |
|
@leio10 nice! So merging it! 😄 |
|
🎉 🎉 Hooray! Thanks @mrcasals! |
|
@leio10 thank you for your contributions to the project! 😄 |

🎩 What? Why?
Currently, authorization modals are rendered in every page of a component, checking in advance the authorization status of the user for each handler related to every authorizable action defined by the component. Then, they can be easily shown when the user tries to perform an unauthorized action. This approach is simple and very performant, but also has drawbacks.
The main drawback of this approach is that it limits the ability to add action buttons outside the component pages, since it would require to render a lot of authorizations modals for a lot of components or write a very complex code that smartly detects which modals are needed on each page. Using cards we can render information of any resource on a participatory space home page or even in the main home page, but we can't add a "Call to action" button, since we are not rendering all its related authorization modals. Instead, we are forced to add a link to a page handled by the component engine, where we can render a button that can use an authorization modal if needed.
This PR changes this behavior, loading the authorization modal contents using AJAX requests when the user tries to perform an unauthorized action. This way, the modal displaying is a little bit slower, but it can dynamically check the authorization status of the user for that action, so it can be used anywhere.
To be more specific, the only requirement to use the
action_authorized_link_toandaction_authorized_button_tohelpers is to have thecurrent_componentdefined, which is currently done in the components base controller and in some cells.📌 Related Issues
📋 Subtasks
CHANGELOGentry📷 Screenshots (optional)