-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move 'Request Deletion' modal to its own page
This page is shared between projects and packages. Links to the page now use the same icon and have the same capitalization. There's a new controller which uses strong parameters, form builders and nested attributes for the bs_request_actions association of the BsRequest model.
- Loading branch information
Dany Marcoux
committed
May 26, 2020
1 parent
9cbfc3a
commit afcbf5d
Showing
17 changed files
with
112 additions
and
117 deletions.
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
src/api/app/controllers/webui/requests/deletions_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,43 @@ | ||
module Webui | ||
module Requests | ||
class DeletionsController < WebuiController | ||
before_action :require_login | ||
before_action :lockout_spiders | ||
before_action :set_package, only: [:new] | ||
before_action :set_project, only: [:new] | ||
|
||
after_action :verify_authorized | ||
|
||
def new | ||
bs_request_action = BsRequestAction.new(target_package: @package, target_project: @project, type: 'delete') | ||
@bs_request = BsRequest.new(bs_request_actions: [bs_request_action]) | ||
authorize @bs_request, :create? | ||
end | ||
|
||
def create | ||
request = BsRequest.new(bs_request_params) | ||
authorize request, :create? | ||
begin | ||
request.save! | ||
rescue APIError => e | ||
flash[:error] = e.message | ||
redirect_to(controller: :package, action: :show, package: params[:package_name], project: params[:project_name]) && return if @package | ||
redirect_to(controller: :project, action: :show, project: params[:project_name]) && return | ||
end | ||
redirect_to request_show_path(request.number) | ||
end | ||
|
||
private | ||
|
||
def bs_request_params | ||
params.require(:bs_request).permit(:description, bs_request_actions_attributes: [:target_project, :target_package, :type]) | ||
end | ||
|
||
def set_package | ||
return unless params.key?(:package_name) | ||
|
||
@package = Package.find_by(name: params[:package_name]) | ||
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
6 changes: 3 additions & 3 deletions
6
src/api/app/views/webui/package/bottom_actions/_request_deletion.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
%li.list-inline-item | ||
= link_to('#', class: 'nav-link', data: { toggle: 'modal', target: '#delete-request-modal' }) do | ||
%i.fas.fa-list-alt.text-danger | ||
Request deletion | ||
= link_to(new_project_package_deletion_path(project, package), class: 'nav-link') do | ||
%i.fas.fa-times-circle.text-danger | ||
Request Deletion |
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
6 changes: 3 additions & 3 deletions
6
src/api/app/views/webui/package/responsive_ux/show_actions/_request_deletion.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
%li.nav-item | ||
= link_to('#', class: 'nav-link', data: { toggle: 'modal', target: '#delete-request-modal' }) do | ||
%i.fas.fa-list-alt.fa-lg.mr-2 | ||
Request deletion | ||
= link_to(new_project_package_deletion_path(project, package), class: 'nav-link') do | ||
%i.fas.fa-times-circle.fa-lg.mr-2 | ||
Request Deletion |
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
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
30 changes: 0 additions & 30 deletions
30
src/api/app/views/webui/request/_delete_request_dialog.html.haml
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/api/app/views/webui/requests/deletions/_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,7 @@ | ||
- if @package | ||
= render partial: 'webui/package/breadcrumb_items' | ||
- else | ||
= render partial: 'webui/project/breadcrumb_items' | ||
|
||
%li.breadcrumb-item.active{ 'aria-current' => 'page' } | ||
Request Deletion |
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,36 @@ | ||
- @pagetitle = 'Request Deletion' | ||
|
||
.row | ||
.col | ||
.card | ||
- if @package | ||
= render partial: 'webui/package/tabs', locals: { project: @project, package: @package } | ||
- else | ||
= render partial: 'webui/project/tabs', locals: { project: @project } | ||
.card-body | ||
.row | ||
.col-12 | ||
%h3= @pagetitle | ||
.col-12.col-md-9.col-lg-8 | ||
%p | ||
-# FIXME: get rid of the helper project_or_package_link | ||
Do you really want to request the deletion of | ||
= project_or_package_link(project: @project.name, package: @package.try(:name)) | ||
? | ||
.col-12.col-md-9.col-lg-6 | ||
- form_path = @package ? project_package_role_additions_path(@project, @package) : project_role_additions_path(@project) | ||
= form_for(@bs_request, url: form_path) do |f| | ||
= f.fields_for(:bs_request_actions) do |bs_request_actions| | ||
= bs_request_actions.hidden_field(:target_project) | ||
= bs_request_actions.hidden_field(:type) | ||
- if @package | ||
.form-group | ||
= bs_request_actions.hidden_field(:target_package) | ||
= bs_request_actions.label(:target_project, 'In target project:') | ||
= bs_request_actions.text_field(:target_project, disabled: true, class: 'form-control') | ||
.form-group | ||
= f.label(:description, "Please describe your reasons to request the deletion of this #{@package ? 'package' : 'project'}:") | ||
%abbr.text-danger{ title: 'required' } * | ||
= f.text_area(:description, row: 3, class: 'form-control', required: true) | ||
|
||
= submit_tag('Request', class: 'btn btn-primary px-4') |
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
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