Skip to content

Commit

Permalink
Reduces number permission checks, most importantly of "can_publish?"
Browse files Browse the repository at this point in the history
  • Loading branch information
fherreazcue committed Sep 8, 2023
1 parent 7a1159d commit 480a543
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 0 additions & 5 deletions app/assets/stylesheets/publishing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ ul.item_for_decision {
.publishing_options {
padding: 0.5em 1em;

&.publishable {
background-color: #fafaff;
border-left-color: $btn-success-bg;
}

&.not-manageable {
border-left-color: $btn-warning-bg;
}
Expand Down
21 changes: 15 additions & 6 deletions app/views/assets/_asset_checkbox_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
checked ||= false
block_published ||= false

can_manage=item.can_manage?
can_view=item.can_view?
published=false
tree_class = 'not-manageable'
tree_class = 'publishable' if item.can_publish? && item.can_manage?
tree_class = 'already-published' if item.is_published?
tree_class = 'not-visible' unless item.can_view?
tree_class = 'manageable' if can_manage
tree_class = 'not-visible' unless can_view
if block_published
if item.is_published?
published=true
tree_class = 'already-published'
end
end


toggle ||=false
cb_parent_selector ||="div\##{item.class.name}_#{item.id}.split_button_parent"
Expand All @@ -20,15 +29,15 @@
<% if toggle %>
<%= render :partial => 'assets/isa-tree-toggle', locals: { cb_parent_selector: cb_parent_selector } -%>
<% end %>
<% if item.can_view? %>
<% if can_view %>
<div style="display: inline; margin-right:1em">
<%= render :partial => 'general/split_button_checkbox',
locals: { checkbox_id: publishing_item_param(item),
checkbox_class: "#{item.class.name}_#{item.id}",
checked: checked,
checkbox_text: "",
published: (item.is_published? && block_published),
cant_manage: !(item.can_manage?),
published: published,
cant_manage: !(can_manage),
toggle: toggle,
cb_parent_selector: cb_parent_selector} -%>
</div>
Expand Down

0 comments on commit 480a543

Please sign in to comment.