-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To exclude and unexclude request in the WebUI. Co-authored-by: David Kang <dkang@suse.com> Co-authored-by: Saray Cabrera Padrón <scabrerapadron@suse.de> Co-authored-by: Victor Pereira <vpereira@suse.com> Co-authored-by: Ana María Martínez Gómez <ammartinez@suse.de>
- Loading branch information
1 parent
995715e
commit 81ff200
Showing
8 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/api/app/controllers/webui/staging/excluded_requests_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
module Webui | ||
module Staging | ||
class ExcludedRequestsController < WebuiController | ||
layout 'webui2/webui' | ||
|
||
before_action :require_login, except: [:index] | ||
before_action :switch_to_webui2 | ||
before_action :set_staging_workflow | ||
before_action :set_project | ||
before_action :set_request_exclusion, only: [:destroy] | ||
after_action :verify_authorized, except: [:index] | ||
|
||
def index | ||
@request_exclusions = @staging_workflow.request_exclusions | ||
@requests = @staging_workflow.unassigned_requests | ||
end | ||
|
||
def create | ||
authorize @staging_workflow | ||
|
||
staging_request_exclusion = params[:staging_request_exclusion] | ||
|
||
request = @staging_workflow.target_of_bs_requests.find_by(number: staging_request_exclusion[:number]) | ||
unless request | ||
redirect_back(fallback_location: root_path, error: "Request #{params[:number]} doesn't exist or it doesn't belong to this project") | ||
return | ||
end | ||
|
||
request_exclusion = @staging_workflow.request_exclusions.build(bs_request: request, description: staging_request_exclusion[:description]) | ||
|
||
if request_exclusion.save | ||
flash[:success] = 'The request was successfully excluded' | ||
else | ||
flash[:error] = request_exclusion.errors.full_messages.to_sentence | ||
end | ||
redirect_to staging_workflow_excluded_requests_path(@staging_workflow) | ||
end | ||
|
||
def destroy | ||
authorize @staging_workflow | ||
|
||
if @request_exclusion.destroy | ||
flash[:success] = 'The request is not excluded anymore' | ||
else | ||
flash[:error] = "Request #{@request_exclusion.number} couldn't be unexcluded" | ||
end | ||
redirect_to staging_workflow_excluded_requests_path(@staging_workflow) | ||
end | ||
|
||
private | ||
|
||
def switch_to_webui2 | ||
prepend_view_path('app/views/webui2') | ||
end | ||
|
||
def set_staging_workflow | ||
@staging_workflow = ::Staging::Workflow.find_by(id: params[:staging_workflow_id]) | ||
return if @staging_workflow | ||
|
||
redirect_back(fallback_location: root_path, error: "Staging Workflow #{params[:staging_workflow_id]} does not exist") | ||
end | ||
|
||
def set_project | ||
@project = @staging_workflow.project | ||
return if @project | ||
|
||
redirect_back(fallback_location: root_path, error: "Staging Workflow #{params[:staging_workflow_id]} is not assigned to a project") | ||
end | ||
|
||
def set_request_exclusion | ||
@request_exclusion = ::Staging::RequestExclusion.find_by(id: params[:id]) | ||
return if @request_exclusion | ||
|
||
redirect_back(fallback_location: staging_workflow_excluded_requests_path(@staging_workflow), error: "Request doesn't exist") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/api/app/views/webui2/webui/staging/excluded_requests/_breadcrumb_items.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= render partial: 'webui/project/breadcrumb_items' | ||
%li.breadcrumb-item.active{ 'aria-current' => 'page' } | ||
Staging workflow excluded requests |
18 changes: 18 additions & 0 deletions
18
src/api/app/views/webui2/webui/staging/excluded_requests/_create_dialog.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.modal.fade#exclude-request-modal{ tabindex: -1, role: 'dialog', aria: { labelledby: 'exclude-request-modal-label', hidden: true } } | ||
.modal-dialog.modal-dialog-centered{ role: 'document' } | ||
.modal-content | ||
.modal-header | ||
%h5.modal-title#exclude-request-modal-label Exclude Request | ||
%a.close{ type: 'button', data: { dismiss: 'modal' }, aria: { label: 'Close' } } | ||
%span{ aria: { hidden: true } } × | ||
= form_for Staging::RequestExclusion.new, url: staging_workflow_excluded_requests_path do |f| | ||
.modal-body | ||
.form-group | ||
= f.label :number, 'Request' | ||
= f.number_field :number, required: true, class: 'form-control' | ||
.form-group | ||
= f.label :description | ||
= f.text_area :description, | ||
required: true, placeholder: 'Explain why this request will be excluded', class: 'form-control', maxlength: 255 | ||
.modal-footer | ||
= render partial: 'webui2/shared/dialog_action_buttons' |
14 changes: 14 additions & 0 deletions
14
src/api/app/views/webui2/webui/staging/excluded_requests/_delete_dialog.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.modal.fade{ id: "delete-excluded-request-modal-#{request_exclusion.bs_request_id}", | ||
tabindex: -1, role: 'dialog', aria: { labelledby: 'delete-modal-label', hidden: true } } | ||
.modal-dialog.modal-dialog-centered{ role: 'document' } | ||
.modal-content | ||
.modal-header | ||
%h5.modal-title | ||
Stop excluding this request? | ||
.modal-body | ||
%p Please confirm that you want to stop excluding this request | ||
= form_tag staging_workflow_excluded_request_path(staging_workflow, request_exclusion), method: :delete do | ||
.modal-footer | ||
%a.btn.btn-sm.btn-outline-secondary.px-4{ data: { dismiss: 'modal' } } | ||
Cancel | ||
= submit_tag('Accept', class: 'btn btn-sm btn-danger px-4') |
33 changes: 33 additions & 0 deletions
33
src/api/app/views/webui2/webui/staging/excluded_requests/index.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.row | ||
.col-xl-12 | ||
.card.mb-3 | ||
.card-body | ||
%h3 Excluded Requests | ||
%table.responsive.table.table-striped.table-bordered#excluded-requests-datatable | ||
%thead | ||
%tr.text-center | ||
%th Request | ||
%th Description | ||
%th Actions | ||
%tbody | ||
- @request_exclusions.each do |request_exclusion| | ||
%tr | ||
%td= request_exclusion.bs_request.number | ||
%td= request_exclusion.description | ||
%td | ||
= link_to('#', data: { toggle: 'modal', target: "#delete-excluded-request-modal-#{request_exclusion.bs_request_id}" }, | ||
title: 'Stop excluding request') do | ||
%i.fas.fa-times-circle.text-danger | ||
= render(partial: 'delete_dialog', | ||
locals: { staging_workflow: @staging_workflow, request_exclusion: request_exclusion }) | ||
= link_to('#', data: { toggle: 'modal', target: '#exclude-request-modal' }) do | ||
%i.fas.fa-plus-circle.text-primary | ||
Exclude request | ||
|
||
= render partial: 'create_dialog', locals: { requests: @requests } | ||
|
||
= content_for :ready_function do | ||
:plain | ||
$('#excluded-requests-datatable').DataTable({ | ||
responsive: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters