Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[53809] Update PageHeaders & SubHeaders in the (rails) global index pages (fix issues) #16882

Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions app/components/add_button_component.html.erb

This file was deleted.

76 changes: 0 additions & 76 deletions app/components/add_button_component.rb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you just change this component to use a Primer Button? Now, you duplicated a lot of code in the individual modules. The SubHeader can deal with custom components on the right side, so that should not be a problem.

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/homescreen/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ See COPYRIGHT and LICENSE files for more details.
end
%>

<h2 class="headline--application">
<span><%= organization_icon %></span>
<%= organization_name %>
</h2>

<%= render partial: 'announcements/show' %>

<% if @homescreen[:blocks].any? %>
Expand Down
58 changes: 0 additions & 58 deletions modules/boards/app/components/boards/add_button_component.rb

This file was deleted.

9 changes: 9 additions & 0 deletions modules/boards/app/controllers/boards/boards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ class BoardsController < BaseController
menu_item :boards

def index
@show_create_button = show_create_button
render "index", locals: { menu_name: project_or_global_menu }
end

def show
render layout: "angular/angular"
end

def show_create_button
if @project
User.current.allowed_in_project?(:manage_board_views, @project)
else
User.current.allowed_in_any_project?(:manage_board_views)
end
end

def default_breadcrumb; end

def show_local_breadcrumb
Expand Down
23 changes: 16 additions & 7 deletions modules/boards/app/views/boards/boards/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,28 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t("boards.label_boards") }
header.with_breadcrumbs([{ href: home_path, text: organization_name},
header.with_breadcrumbs([{ href: home_path, text: organization_name },
*([href: project_overview_path(@project.id), text: @project.name] if @project),
t("boards.label_boards")])
end
%>

<%=
render Primer::OpenProject::SubHeader.new do |subheader|
subheader.with_action_component(data: { "test-selector": "add-board-button"}) do
render Boards::AddButtonComponent.new(current_project: @project)
<% if @show_create_button %>
<%=
render Primer::OpenProject::SubHeader.new do |subheader|
subheader.with_action_button(scheme: :primary,
aria: { label: I18n.t("boards.label_create_new_board") },
title: I18n.t("boards.label_board"),
tag: :a,
id: "add-board-button",
href: polymorphic_path([:new, @project, :work_package_board]),
data: { "test-selector": "add-board-button"}) do |button|
button.with_leading_visual_icon(icon: :plus)
I18n.t("boards.label_board")
end
end
end
%>
%>
<% end %>

<% if @board_grids.empty? -%>
<%= no_results_box %>
Expand Down
26 changes: 24 additions & 2 deletions modules/boards/app/views/boards/boards/overview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,30 @@ See COPYRIGHT and LICENSE files for more details.

<% html_title(t('boards.label_boards')) -%>

<%= toolbar title: t('boards.label_boards') do %>
<%= render Boards::AddButtonComponent.new %>
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t("boards.label_boards") }
header.with_breadcrumbs([{ href: home_path, text: organization_name},
*([href: project_overview_path(@project.id), text: @project.name] if @project),
t("boards.label_boards")])
end
%>

<% if @show_create_button %>
<%=
render Primer::OpenProject::SubHeader.new do |subheader|
subheader.with_action_button(scheme: :primary,
aria: { label: I18n.t("boards.label_create_new_board") },
title: I18n.t("boards.label_board"),
tag: :a,
id: "add-board-button",
href: polymorphic_path([:new, @project, :work_package_board]),
data: { "test-selector": "add-board-button"}) do |button|
button.with_leading_visual_icon(icon: :plus)
I18n.t("boards.label_board")
end
end
%>
<% end %>

<% if @board_grids.empty? -%>
Expand Down
4 changes: 1 addition & 3 deletions modules/boards/spec/features/support/board_index_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ def expect_board(name, present: true)

def create_board(action: "Basic", title: "#{action} Board", expect_empty: false, via_toolbar: true)
if via_toolbar
within '[data-test-selector="add-board-button"]' do
click_link "Board"
end
find('[data-test-selector="add-board-button"]').click
else
find('[data-test-selector="boards--create-button"]').click
end
Expand Down
8 changes: 2 additions & 6 deletions modules/boards/spec/features/support/board_list_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ def visit!
end

def expect_create_button
within '[data-test-selector="add-board-button"]' do
expect(page).to have_link "Board"
end
expect(page).to have_css('[data-test-selector="add-board-button"]', text: "Board")
end

def expect_no_create_button
within '[data-test-selector="add-board-button"]' do
expect(page).to have_no_link "Board"
end
expect(page).to have_no_css('[data-test-selector="add-board-button"]', text: "Board")
end

def expect_delete_buttons(*boards)
Expand Down
4 changes: 1 addition & 3 deletions modules/boards/spec/features/support/board_new_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def visit!
def navigate_by_create_button
visit work_package_boards_path unless page.current_path == work_package_boards_path

within '[data-test-selector="add-board-button"]' do
click_link "Board"
end
find('[data-test-selector="add-board-button"]').click
end

def set_title(title)
Expand Down

This file was deleted.

62 changes: 0 additions & 62 deletions modules/calendar/app/components/calendar/add_button_component.rb

This file was deleted.

18 changes: 18 additions & 0 deletions modules/calendar/app/controllers/calendar/calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CalendarsController < ApplicationController

def index
@views = visible_views
@show_create_button = show_create_button?
@dynamic_path = dynamic_path
render "index", locals: { menu_name: project_or_global_menu }
end

Expand Down Expand Up @@ -109,5 +111,21 @@ def find_calendar
rescue ActiveRecord::RecordNotFound
render_404
end

def show_create_button?
if @project
User.current.allowed_in_project?(:manage_calendars, @project)
else
User.current.allowed_in_any_project?(:manage_calendars)
end
end

def dynamic_path
if @project
new_project_calendars_path(@project)
else
new_calendar_path
end
end
end
end
Loading