-
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.
Move prjconf actions from project_controller to its own controller
- Loading branch information
Showing
28 changed files
with
1,749 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This is a manifest file that'll be compiled into codemirror, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// the compiled file. | ||
// | ||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | ||
// GO AFTER THE REQUIRES BELOW. | ||
// | ||
//= require codemirror | ||
//= require webui2/cm2/toolbars | ||
//= require webui2/cm2/mode/prjconf | ||
//= require webui2/cm2/use-codemirror |
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
37 changes: 37 additions & 0 deletions
37
src/api/app/controllers/webui/projects/project_configuration_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,37 @@ | ||
module Webui | ||
module Projects | ||
class ProjectConfigurationController < WebuiController | ||
before_action :set_project | ||
after_action :verify_authorized, only: :update | ||
|
||
def show | ||
sliced_params = params.slice(:rev).permit! | ||
@content = @project.config.content(sliced_params.to_h) | ||
switch_to_webui2 | ||
return if @content | ||
flash[:error] = @project.config.errors.full_messages.to_sentence | ||
redirect_to projects_path(nextstatus: 404) | ||
end | ||
|
||
def update | ||
authorize @project, :update? | ||
result = ::ProjectConfigurationService::ProjectConfigurationUpdater.new(@project, User.current, params).call | ||
status = if result.saved? | ||
flash.now[:success] = 'Config successfully saved!' | ||
200 | ||
else | ||
flash.now[:error] = result.errors | ||
400 | ||
end | ||
switch_to_webui2 | ||
render layout: false, status: status, partial: "layouts/#{view_namespace}/flash", object: flash | ||
end | ||
|
||
private | ||
|
||
def view_namespace | ||
switch_to_webui2? ? 'webui2' : 'webui' | ||
end | ||
end | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
src/api/app/services/project_configuration_service/project_configuration_updater.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,31 @@ | ||
module ProjectConfigurationService | ||
class ProjectConfigurationUpdater | ||
def initialize(project, user, params) | ||
@user = user | ||
@project = project | ||
@params = params | ||
end | ||
|
||
def call | ||
@config = @project.config.save(sliced_params, @params[:config]) | ||
self | ||
end | ||
|
||
def saved? | ||
@config.present? || false | ||
end | ||
|
||
def errors | ||
@project.config.errors.full_messages.to_sentence | ||
end | ||
|
||
private | ||
|
||
def sliced_params | ||
@params[:user] = @user.login | ||
sliced_params = @params.slice(:user, :comment) | ||
sliced_params.permit! | ||
sliced_params | ||
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
16 changes: 16 additions & 0 deletions
16
src/api/app/views/webui/projects/project_configuration/show.html.erb
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,16 @@ | ||
<% content_for(:content_for_head, javascript_include_tag('webui/application/cm2/index-prjconf')) %> | ||
<% @pagetitle = "Project Configuration of #{@project}" %> | ||
<% @metarobots = 'noindex' %> | ||
<% project_bread_crumb 'Project Configuration' %> | ||
<%= render :partial => 'webui/project/tabs' %> | ||
|
||
<h3><%= @pagetitle %></h3> | ||
<div style="margin-left: 15px; margin-right: 15px;"> | ||
<% if User.current.can_modify?(@project) %> | ||
<%= render partial: "shared/editor", locals: {text: @content, mode: 'prjconf', save: {url: save_project_config_path, method: 'POST', data: {project: @project.name, submit: 'config'}}} %> | ||
<% else %> | ||
<%= render partial: "shared/editor", locals: {text: @content, mode: 'prjconf', style: {read_only: true}} %> | ||
<% end %> | ||
</div> |
3 changes: 3 additions & 0 deletions
3
src/api/app/views/webui2/webui/projects/project_configuration/_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' } | ||
Project Config |
16 changes: 16 additions & 0 deletions
16
src/api/app/views/webui2/webui/projects/project_configuration/show.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,16 @@ | ||
:ruby | ||
content_for(:content_for_head, javascript_include_tag('webui2/cm2/show-prjconf')) | ||
@pagetitle = "Project Configuration of #{@project}" | ||
@metarobots = 'noindex' | ||
|
||
.card | ||
= render(partial: 'webui/project/tabs', locals: { project: @project }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
- if User.current.can_modify?(@project) | ||
= render partial: 'shared/editor', locals: { text: @content, mode: 'prjconf', | ||
save: { url: save_project_config_path, method: :post, | ||
data: { project: @project.name, submit: 'config' } } } | ||
- else | ||
= render partial: 'shared/editor', locals: { text: @content, mode: 'prjconf', style: { read_only: 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
18 changes: 9 additions & 9 deletions
18
..._add_maintained_project_dialog/1_44_1.yml → ..._add_maintained_project_dialog/1_42_1.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/api/spec/cassettes/Webui_ProjectController/GET_add_maintained_project_dialog/1_45_1.yml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.