Skip to content

Commit

Permalink
Implement next and previous buttons for paginating actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Mar 1, 2023
1 parent 693c935 commit 4c4242b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
10 changes: 9 additions & 1 deletion src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ def show
action_id = params[:request_action_id] || @bs_request.bs_request_actions.first.id
@action = @bs_request.webui_actions(filelimit: @diff_limit, tarlimit: @diff_limit, diff_to_superseded: @diff_to_superseded,
diffs: true, action_id: action_id.to_i, cacheonly: 1).first
@active_action = @bs_request.bs_request_actions.find(action_id)
actions = @bs_request.bs_request_actions
@active_action = actions.find(action_id)
# Change supported_actions below into actions here when all actions are supported
supported_actions = actions.where(type: [:add_role, :submit])
active_action_index = supported_actions.index(@active_action)
if active_action_index
@prev_action = supported_actions[active_action_index - 1] unless active_action_index.zero?
@next_action = supported_actions[active_action_index + 1] if active_action_index + 1 < supported_actions.length
end

target_project = Project.find_by_name(@bs_request.target_project_name)
@request_reviews = @bs_request.reviews.for_non_staging_projects(target_project)
Expand Down
47 changes: 27 additions & 20 deletions src/api/app/views/webui/request/_actions_details.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,33 @@
- if submit_actions_count > 1
.d-flex.align-items-center
%p.mb-0 This request contains #{submit_actions_count} actions
.dropdown.ms-2#request-actions
%button.btn.btn-outline-primary.btn-sm.dropdown-toggle{ 'aria-expanded' => 'false', 'data-bs-toggle' => 'dropdown',
:type => 'button', 'data-boundary' => 'viewport' }
Select Action
%ul.dropdown-menu.dropdown-menu-start.scrollable-dropdown.pt-0
%li.card-header.px-1.sticky-top
%h6.dropdown-header
- if User.session
%span Seen
%span Action
%span.float-end Revision
- submit_actions.each_with_index do |action_item, action_index|
%li.border-top
= link_to((render partial: 'action_text', locals: { action: action_item, action_index: action_index }),
request_show_path(number: bs_request.number,
request_action_id: action_item.id,
full_diff: diff_limit,
diff_to_superseded: diff_to_superseded_id),
class: "dropdown-item #{action_item.id == active_action.id ? 'active' : ''}",
'aria-current': 'true')
.input-group.ms-2.w-auto
= link_to('Previous', request_show_path(number: bs_request.number, request_action_id: prev_action&.id,
full_diff: diff_limit, diff_to_superseded: diff_to_superseded_id),
class: "btn btn-primary btn-sm #{prev_action ? '' : 'disabled'}")
.dropdown#request-actions
%button.btn.btn-outline-primary.btn-sm.dropdown-toggle.rounded-0{ 'aria-expanded' => 'false', 'data-bs-toggle' => 'dropdown',
:type => 'button', 'data-boundary' => 'viewport' }
Select Action
%ul.dropdown-menu.dropdown-menu-start.scrollable-dropdown.pt-0
%li.card-header.px-1.sticky-top
%h6.dropdown-header
- if User.session
%span Seen
%span Action
%span.float-end Revision
- submit_actions.each_with_index do |action_item, action_index|
%li.border-top
= link_to((render partial: 'action_text', locals: { action: action_item, action_index: action_index }),
request_show_path(number: bs_request.number,
request_action_id: action_item.id,
full_diff: diff_limit,
diff_to_superseded: diff_to_superseded_id),
class: "dropdown-item #{action_item.id == active_action.id ? 'active' : ''}",
'aria-current': 'true')
= link_to('Next', request_show_path(number: bs_request.number, request_action_id: next_action&.id,
full_diff: diff_limit, diff_to_superseded: diff_to_superseded_id),
class: "btn btn-primary btn-sm #{next_action ? '' : 'disabled'}")
%p
- if submit_actions_count > 1
- if User.session
Expand Down
1 change: 1 addition & 0 deletions src/api/app/views/webui/request/beta_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
= link_to "##{supersed['number']}", number: supersed['number']

= render partial: 'actions_details', locals: { bs_request: @bs_request, action: @action, active_action: @active_action,
prev_action: @prev_action, next_action: @next_action,
diff_to_superseded_id: @diff_to_superseded_id, diff_limit: @diff_limit }
- if @staging_status
This request is currently
Expand Down

0 comments on commit 4c4242b

Please sign in to comment.