-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Remove "actions" for labels for users who can't do actions on labels #5289
Conversation
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 your contribution! Just a small remark on your code.
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 contribution.
Could you put the latest images in the pr description?
Also did you test this on smaller screen widths? The 9-3 vs 10-2 discussion might be more relevant in those cases
Updated the original PR to include the images |
<th><%= t "labels.index.actions" %></th> | ||
<th class="text-end"><%= t "labels.index.exercises" %></th> | ||
<% if policy(Label).edit? %> | ||
<th class="text-end"><%= t "labels.index.actions" %></th> |
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.
<th class="text-end"><%= t "labels.index.actions" %></th> | |
<th class="text-end"></th> |
The label is redundant, so I would remove it.
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.
If so, then we could remove the conditional entirely for the tabel header.
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.
Indeed, it would remove the Actions label. Removing the conditional for the table header is not a good idea. You should have the same number of header columns as body columns.
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.
That seems logical, ok.
I just noticed something too. There are always 3 body columns, as the conditional is seperated into permission to edit and permission to destroy. Both checks happen inside the column tag.
How does that work with there only being 2 columns defined (for users without permission), but 3 actual columns, the last one empty?
...
<colgroup>
<% if policy(Label).edit? %>
<col class="col-6"/>
<col class="col-3"/>
<col class="col-3"/>
<% else %>
<col class="col-10"/>
<col class="col-2"/>
<% end %>
</colgroup>
...
<tbody>
<% labels.each do |label| %>
<tr>
<td><%= link_to label.name, label_path(label) %></td>
<td class="text-end"><%= link_to label.activities.count, activities_path({"labels[]" => label.name}) %></td>
<td class="text-end">
<% if policy(Label).edit? %>
<%= link_to edit_label_path(label), class: "btn btn-icon" do %>
<i class="mdi mdi-pencil"></i>
<% end %>
<% end %>
<% if policy(Label).destroy? %>
<%= link_to label, method: :delete, data: {confirm: t("general.are_you_sure")}, class: "btn btn-icon btn-icon-filled d-btn-danger" do %>
<i class="mdi mdi-delete"></i>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
...
So the question is: are there users who have permissions to edit but not destroy, or vice versa?
- If no, then we could move the tag inside the conditional and combine the two conditionals in one.
- If yes, do we create an extra conditional around the tag with an 'or', or do we leave it like this? (And always have the third (empty) header to have an equal amount? Does the tag need an extra empty column then, or is that not possible?
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 conditions of which users has which permission are handled in a separate file.
This file should not know how these conditionals are related.
Safest way would thus to simply write the check with an or around the <td>
and use the same or around the column definitions
This pull request removes the actions-column entirely for users who don't have the right to perform actions on labels.
For students
Pc normal window
Before:
After:
Small window
(simulated by making window as small as possible and zooming in to 130%)
For admins (Zeus)
Pc normal window
Before:
After:
Small window
(simulated by making window as small as possible and zooming in to 130%)