Skip to content

Commit

Permalink
Simplify/clean up remaining Config XML editing admin view
Browse files Browse the repository at this point in the history
No need to include tabs; these are just links anyway - so can simplify this all. Also corrects
somewhat the display for the group admin editing view which uses weird colours/buttons.
  • Loading branch information
chadlwilson committed Jun 2, 2023
1 parent 559b1ef commit 75ce930
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,9 @@ div#tab_container {
}

#group_edit_form .form_buttons .submit,
#pipeline_snippet_view #view_group .link_as_button,
#pipeline_snippet_view #view_group .form_buttons .link_as_button,
#pipeline_snippet_edit #edit_group .form_buttons .link_as_button,
button.submit {
background: #ccc;
color: #333 !important;
font-size: rem-calc(13px);
font-weight: 600;
border: 0;
Expand Down Expand Up @@ -1818,7 +1816,7 @@ code,
}

.admin-tab-contents {
padding: 20px 30px;
padding: 0 30px;

h1 {
font-weight: 600;
Expand All @@ -1840,14 +1838,9 @@ code,
}

.heading {
border-bottom: 1px solid $border-color;
padding-bottom: 10px;
margin-bottom: 20px;

h2 {
font-size: 20px;
}

span {
margin-top: 12px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
margin-left: 210px;
}

#pipeline_snippet_view #view_group a.edit.link_as_button {
#pipeline_snippet_view #view_group .form_buttons a.edit.link_as_button {
float: right;
background-color: #39c;
}

#pipeline_snippet_edit #edit_group .form_buttons .submit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-%>

<div class="heading">
<h2>Configuration File</h2>
<span><%= go_config.location -%></span>
<span class="label">Configuration File Path: </span>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div id="modifiable_groups">
<h1>Pipeline Groups</h1>
<ul>
<%- scope[:modifiable_groups].each do |group| -%>
<%- class_name = ""%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div id="view_group">
<div class="form_buttons">
<%= link_to 'Edit', pipelines_snippet_edit_path(:group_name => @group_name), :class => 'edit link_as_button ' -%>
<%= link_to 'Edit', pipelines_snippet_edit_path(:group_name => @group_name), :class => 'link_as_button primary', :id => 'edit_config'-%>
</div>
<pre id="content_container" class="wrap_pre"><%= h(@group_as_xml) %></pre>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<div class="page_header">
<div class="row">
<h1 id="page-title" class="entity_title">Administration</h1>
<h1 id="page-title" class="entity_title">Config XML</h1>
</div>
</div>

Expand All @@ -32,50 +32,9 @@
<%== content_wrapper_tag %>
<div class="row">
<div class="bd-container rounded-corner-for-pipeline admin-rounded-container">
<div class="sub_tab_container rounded-corner-for-tab-container">
<div class="sub_tabs_container">
<ul>
<% if is_user_an_admin? || is_user_a_group_admin? %>
<li id="pipeline-groups-tab-button" class="<%= "current_tab" if @tab_name == "pipeline-groups" %>">
<a id="tab-link-of-pipeline-groups" href="<%= spark_url_for({url_builder: controller}, SparkRoutes::AdminPipelines::SPA_BASE) -%>">Pipelines</a>
</li>
<% end %>
<% if is_user_an_admin? || is_user_authorized_to_view_templates? -%>
<li id="templates-tab-button" class="<%= "current_tab" if @tab_name == "templates" %>">
<a id="tab-link-of-templates" href="<%= spark_url_for({url_builder: controller}, SparkRoutes::AdminTemplates::SPA_BASE) -%>">Templates</a>
</li>
<%- end -%>
<% if !is_user_an_admin? && is_user_a_group_admin? %>
<li id="tab-content-of-pipelines-snippet" class="<%= "current_tab" if @tab_name == "pipelines-snippet" %>">
<%= link_to 'Config XML', pipelines_snippet_path, :id => "tab-link-of-pipelines-snippet" -%>
</li>
<li id="package-repositories-tab-button" class="<%= "current_tab" if @tab_name == "package-repositories" %>">
<%= link_to 'Package Repositories', '/go/admin/package_repositories/list', :id => "tab-link-of-package-repositories" %>
</li>
<% end %>
<% if is_user_an_admin? %>
<li id="source-xml-tab-button" class="<%= "current_tab" if @tab_name == "configuration-xml" %>">
<%= link_to 'Config XML', config_view_path, :id => 'tab-link-of-source-xml' -%>
</li>
<li id="user-summary-tab-button" class="<%= "current_tab" if @tab_name == "user-listing" %>">
<%= link_to "Users Management", '/go/admin/users', :id => "tab-link-of-user-listing" %>
</li>
<li id="backup-tab-button" class="<%= "current_tab" if @tab_name == "backup" %>">
<%= link_to "Backup", '/go/admin/backup', :id => "tab-link-of-backup" %>
</li>
<li id="package-repositories-tab-button" class="<%= "current_tab" if @tab_name == "package-repositories" %>">
<%= link_to 'Package Repositories', '/go/admin/package_repositories/new', :id => "tab-link-of-package-repositories" %>
</li>
<% end %>
</ul>
</div>
<div class="sub_tab_container_content admin-tab-contents">
<div id="tab-content-of-<%= @tab_name -%>" style="">
<%= yield %>
</div>
</div>
<div class="sub_tab_container_content admin-tab-contents">
<div id="tab-content-of-<%= @tab_name -%>">
<%= yield %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
render

Capybara.string(response.body).find('div.heading').tap do |div|
expect(div).to have_selector("h2", :text => "Configuration File")
expect(div).to have_selector("span", :text => "Configuration File Path:")
expect(div).to have_selector("span", :text => "path_to_config_xml")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
render

Capybara.string(response.body).find('div.heading').tap do |div|
expect(div).to have_selector("h2", :text => "Configuration File")
expect(div).to have_selector("span", :text => "Configuration File Path:")
expect(div).to have_selector("span", :text => "path_to_config_xml")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
render

Capybara.string(response.body).find('div.heading').tap do |div|
expect(div).to have_selector("h2", :text => "Configuration File")
expect(div).to have_selector("span", :text => "Configuration File Path:")
expect(div).to have_selector("span", :text => "path_to_config_xml")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

Capybara.string(response.body).find('div#view_group').tap do |div|
expect(div).to have_selector("pre#content_container", :text => "<foo></foo>") # user sees <foo></foo>
expect(div).to have_selector("a.edit[href='#{pipelines_snippet_edit_path(:group_name => 'foo')}']", :text => 'Edit')
expect(div).to have_selector("a#edit_config[class='link_as_button primary'][href='#{pipelines_snippet_edit_path(:group_name => 'foo')}']", :text => 'Edit')
end
Capybara.string(response.body).find('div#modifiable_groups').tap do |div|
expect(div).to have_selector("li.selected a.modifiable_group_link[href='#{pipelines_snippet_show_path(:group_name => 'foo')}']", :text => 'foo')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
assign(:user, @user)
assign(:error_count, 0)
assign(:warning_count, 0)
assign(:tab_name, "dummy-tab")
allow(view).to receive(:can_view_admin_page?).and_return(true)
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(true)
Expand All @@ -40,129 +41,8 @@
expect(response.body).to have_selector(".flash p.warning", :text => "Invalid config on disk. Displaying the last known valid config (Editing config through Go will overwrite the invalid copy. Edit it on disk to fix this problem).")
end

describe "user-summary" do
before(:each) do
assign(:tab_name, "user-listing")
end

it "should show content" do
render :inline => '<div>content</div>', :layout => @layout_name
expect(response.body).to have_selector('#tab-content-of-user-listing', :text => 'content')
end
end

describe "pipeline-groups" do
before(:each) do
assign(:tab_name, "pipeline-groups")
end

it "should show content" do
render :inline => '<div>content</div>', :layout => @layout_name
expect(response.body).to have_selector('#tab-content-of-pipeline-groups')
end

it "should show tab button" do
render :inline => "<div>content</div>", :layout => @layout_name
expect(response.body).to have_selector("#pipeline-groups-tab-button.current_tab a#tab-link-of-pipeline-groups[href='http://test.host/go/admin/pipelines']")
end
end

describe "templates" do
before(:each) do
assign(:tab_name, "templates")
end

it "should show content" do
render :inline => '<div>content</div>', :layout => @layout_name

expect(response.body).to have_selector('#tab-content-of-templates')
end

it "should show tab button for super admins" do
render :inline => "<div>content</div>", :layout => @layout_name
expect(response.body).to have_selector("#templates-tab-button.current_tab a#tab-link-of-templates[href='http://test.host/go/admin/templates']")
end

it "should not be visible for group admins" do
allow(view).to receive(:is_user_authorized_to_view_templates?).and_return(false)
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(false)

render :inline => "<div>content</div>", :layout => @layout_name
expect(response.body).to_not have_selector("#templates-tab-button.current_tab a#tab-link-of-templates[href='http://test.host/go/admin/templates']")
end

it "should be visible for template admins" do
allow(view).to receive(:is_user_authorized_to_view_templates?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(false)

render :inline => "<div>content</div>", :layout => @layout_name

expect(response.body).to have_selector("#templates-tab-button.current_tab a#tab-link-of-templates[href='http://test.host/go/admin/templates']")
end

end

describe "xml" do
before(:each) do
assign(:tab_name, "pipelines-snippet")
end

it "should show xml tab for group admin" do
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(false)

render :inline => 'content', :layout => @layout_name

Capybara.string(response.body).find("#tab-content-of-pipelines-snippet.current_tab") do |tab|
expect(tab).to have_selector("a[id='tab-link-of-pipelines-snippet'][href='/admin/pipelines/snippet']")
end
end

it "should not show xml tab for go administrators" do
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(true)

render :inline => 'content', :layout => @layout_name
expect(response.body).to_not have_selector('li#tab-content-of-pipelines-snippet')
end

it "should not show source xml tab for group admin" do
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(false)

render :inline => 'content', :layout => @layout_name

expect(response.body).to_not have_selector('#source-xml-tab-button')
end
end

describe "package-repositories" do
before(:each) do
assign(:tab_name, "package-repositories")
end

it "should show package repositories tab for super admin" do
allow(view).to receive(:is_user_an_admin?).and_return(true)
allow(view).to receive(:is_user_a_group_admin?).and_return(false)


render :inline => 'content', :layout => @layout_name

Capybara.string(response.body).find("#package-repositories-tab-button.current_tab") do |tab|
expect(tab).to have_selector("a[id='tab-link-of-package-repositories'][href='/go/admin/package_repositories/new']")
end
end

it "should show package repositories tab for group admin" do
allow(view).to receive(:is_user_a_group_admin?).and_return(true)
allow(view).to receive(:is_user_an_admin?).and_return(false)

render :inline => 'content', :layout => @layout_name

Capybara.string(response.body).find("#package-repositories-tab-button.current_tab") do |tab|
expect(tab).to have_selector("a[id='tab-link-of-package-repositories'][href='/go/admin/package_repositories/list']")
end
it "should show content for tab" do
render :inline => '<div>content</div>', :layout => @layout_name
expect(response.body).to have_selector('#tab-content-of-dummy-tab')
end
end
end

0 comments on commit 75ce930

Please sign in to comment.