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

Bump to primer_view_components 0.28.1 and update PageHeaders in Core #15129

Merged
merged 43 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
12c3fd3
update core with new primer view components and update page header co…
bsatarnejad Mar 27, 2024
24d9a42
update page header in project attributes page
bsatarnejad Mar 27, 2024
8f2b9f2
update page header in projects index page
bsatarnejad Mar 27, 2024
2b21ffe
update page header in virus scanning page
bsatarnejad Mar 27, 2024
9ad93c7
update page header in Quarantined attachments page
bsatarnejad Mar 27, 2024
108490d
use one breadcrumb in virus scanning page
bsatarnejad Mar 28, 2024
6a91890
use one breadcrumb in quarantined attachments page
bsatarnejad Mar 28, 2024
555b141
show breadcrumb in project attributes page
bsatarnejad Mar 28, 2024
cf7bf7c
show breadcrumb in project attributes edit page
bsatarnejad Mar 28, 2024
e152956
show breadcrumb in header component of project attributes page
bsatarnejad Mar 28, 2024
0c6ae6f
show correct breadcrumb in members and projects pages
bsatarnejad Mar 28, 2024
82364e1
show correct breadcrumb in form header component of projects custom f…
bsatarnejad Mar 28, 2024
c662b50
show correct breadcrumb in create a new storage page
bsatarnejad Mar 28, 2024
fb3c6a7
(not complete we should discuss) there is no action type for renderin…
bsatarnejad Mar 28, 2024
051a53f
project attribute edit header update with new breadcrumb
bsatarnejad Mar 28, 2024
eecae54
change order of buttons in members page header
bsatarnejad Mar 28, 2024
522ab3f
commit gemfile.lock and package-lock.json
bsatarnejad Apr 3, 2024
d622636
use double quotation marks for string
bsatarnejad Apr 3, 2024
0ca05da
remove unnecessary system arguments
bsatarnejad Apr 3, 2024
1f6185f
Wrap form around the PageHeader in order for the submit button to wor…
HDinger Apr 3, 2024
978006b
Replace invisble button with a link as it matches the requirements be…
HDinger Apr 3, 2024
991be14
fix string definition in projects list
bsatarnejad Apr 3, 2024
aab2443
update primer view component version to 0.26.0
bsatarnejad Apr 3, 2024
49a06fa
Extract menu logic of projects page into a helper to be able to acces…
HDinger Apr 3, 2024
b70ddc5
update breadcrumb in edit form of project attribute
bsatarnejad Apr 3, 2024
17996f1
Merge branch 'implementation-update-page-header-in-core' of https://g…
bsatarnejad Apr 3, 2024
338000b
update breadcrumb in edit form of project attribute
bsatarnejad Apr 3, 2024
a7ebc43
remove show default breadcrumb method in some components
bsatarnejad Apr 3, 2024
ba91ed8
Add breadcrumb to edit state of the project list page header
HDinger Apr 4, 2024
bbf0a01
Add required breadcrumb elements to Storages and Project attribute page
HDinger Apr 4, 2024
735e5ef
Update primer to 0.27.0 so that we can use the Dialog slot on the pro…
HDinger Apr 4, 2024
b1c3932
Reflect the sidebar hierarchy in the breadcrumbs of the Members page
HDinger Apr 4, 2024
7bdcfdd
Merge remote-tracking branch 'origin/dev' into implementation-update-…
HDinger Apr 4, 2024
15d619b
Fix breadcrumb and page title for the members page
HDinger Apr 5, 2024
4ffa2ff
Add label for zen mode (used by Primer::OpenProject::ZenModeButton)
HDinger Apr 5, 2024
eea6bf8
Remove NewStorageButtonComponent as it does not work outside a header…
HDinger Apr 5, 2024
b110240
Add old breadcrumb methods again for super class compliance && fix tests
HDinger Apr 5, 2024
ac68ad8
Add correct breadcrumb element for the project settings page of proje…
HDinger Apr 5, 2024
1a5581b
Merge branch 'dev' into implementation-update-page-header-in-core
HDinger Apr 8, 2024
c60c150
Change order of buttons back until we have decided on how we want to …
HDinger Apr 10, 2024
90f0721
Merge remote-tracking branch 'origin/dev' into implementation-update-…
HDinger Apr 10, 2024
2ece709
Extract header into separate components for separation of concerns
HDinger Apr 10, 2024
1a1a3f6
Bump to primer version 0.28.1
HDinger Apr 10, 2024
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
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,6 @@ gemfiles.each do |file|
send(:eval_gemfile, file) if File.readable?(file)
end

gem "openproject-octicons", "~>19.8.0"
gem "openproject-octicons_helper", "~>19.8.0"
gem "openproject-primer_view_components", "~>0.23.0"
HDinger marked this conversation as resolved.
Show resolved Hide resolved
gem "openproject-octicons", "~>19.9.0"
gem "openproject-octicons_helper", "~>19.9.0"
gem "openproject-primer_view_components", "~>0.27.0"
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -773,15 +773,15 @@ GEM
validate_email
validate_url
webfinger (~> 2.0)
openproject-octicons (19.8.0)
openproject-octicons_helper (19.8.0)
openproject-octicons (19.9.0)
openproject-octicons_helper (19.9.0)
actionview
openproject-octicons (= 19.8.0)
openproject-octicons (= 19.9.0)
railties
openproject-primer_view_components (0.23.0)
openproject-primer_view_components (0.27.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
openproject-octicons (>= 19.8.0)
openproject-octicons (>= 19.9.0)
view_component (>= 3.1, < 4.0)
openproject-token (4.0.0)
activemodel
Expand Down Expand Up @@ -1270,10 +1270,10 @@ DEPENDENCIES
openproject-job_status!
openproject-ldap_groups!
openproject-meeting!
openproject-octicons (~> 19.8.0)
openproject-octicons_helper (~> 19.8.0)
openproject-octicons (~> 19.9.0)
openproject-octicons_helper (~> 19.9.0)
openproject-openid_connect!
openproject-primer_view_components (~> 0.23.0)
openproject-primer_view_components (~> 0.27.0)
openproject-recaptcha!
openproject-reporting!
openproject-storages!
Expand Down
52 changes: 20 additions & 32 deletions app/components/members/index_page_header_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { t(:label_member_plural) }
header.with_title { page_title }
header.with_breadcrumbs(breadcrumb_items)

header.with_actions do
flex_layout do |actions|
if User.current.allowed_in_project?(:manage_members, @project)
actions.with_column(mr: BUTTON_MARGIN_RIGHT) do
render(
Primer::Beta::Button.new(
scheme: :primary,
size: :medium,
aria: { label: I18n.t(:button_add_member) },
title: I18n.t(:button_add_member),
id: 'add-member-button',
data: add_button_data_attributes
)
) do |button|
button.with_leading_visual_icon(icon: :plus)
t('activerecord.models.member')
end
end
end
header.with_action_icon_button(mobile_icon: "filter",
scheme: :default,
icon: "filter",
label: I18n.t(:description_filter),
id: "filter-member-button",
aria: { label: I18n.t(:description_filter) },
class: "toggle-member-filter-link",
data: filter_button_data_attributes)

actions.with_column do
render(
Primer::Beta::IconButton.new(
icon: 'filter',
id: 'filter-member-button',
aria: { label: I18n.t(:description_filter) },
class: 'toggle-member-filter-link',
data: filter_button_data_attributes
)
)
end
end
header.with_action_button(scheme: :primary,
mobile_icon: :plus,
mobile_label: t('activerecord.models.member'),
size: :medium,
aria: { label: I18n.t(:button_add_member) },
title: I18n.t(:button_add_member),
id: "add-member-button",
data: add_button_data_attributes) do |button|
button.with_leading_visual_icon(icon: :plus)
t('activerecord.models.member')
HDinger marked this conversation as resolved.
Show resolved Hide resolved
end
end
%>
54 changes: 52 additions & 2 deletions app/components/members/index_page_header_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
class Members::IndexPageHeaderComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include ApplicationHelper

BUTTON_MARGIN_RIGHT = 2
include Menus::MembersHelper

def initialize(project: nil)
super
Expand All @@ -57,4 +56,55 @@ def filter_button_data_attributes
action: "members-form#toggleMemberFilter"
}
end

def breadcrumb_items
[{ href: project_overview_path(@project.id), text: @project.name },
{ href: project_members_path(@project), text: t(:label_member_plural) },
current_breadcrumb_element]
end

def page_title
# Rework this, when the Members page actually works with queries
@query ||= current_query
query_name = @query[:query_name]

if @query && query_name
query_name
else
t(:label_member_plural)
end
end

def current_breadcrumb_element
# Rework this, when the Members page actually works with queries
@query ||= current_query
query_name = @query[:query_name]
menu_header = @query[:menu_header]

if @query && query_name
if menu_header.present?
I18n.t("menus.breadcrumb.nested_element", section_header: menu_header, title: query_name).html_safe
else
query_name
end
else
t(:label_member_plural)
end
end

def current_query
query_name = nil
menu_header = nil

first_level_menu_items.find do |section|
section.children.find do |menu_query|
if !!menu_query.selected
query_name = menu_query.title
menu_header = section.header
end
end
end

{ query_name:, menu_header: }
end
end
175 changes: 86 additions & 89 deletions app/components/projects/index_page_header_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,115 +1,112 @@
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% if show_state? %>
<% header.with_title(data: { 'test-selector': 'project-query-name'}) { page_title } %>
<% header.with_breadcrumbs(breadcrumb_items)%>

<% header.with_actions do %>
<% if query_saveable? %>
<%= render(
Primer::Beta::Text.new(tag: :span,
mr: BUTTON_MARGIN_RIGHT,
color: :muted)) do
t('lists.can_be_saved_as')
end
%>
<% if query_saveable? %>
<% header.with_action_text { t('lists.can_be_saved_as') } %>

<%= render(
Primer::Beta::Button.new(scheme: :invisible,
size: :medium,
mr: BUTTON_MARGIN_RIGHT,
tag: :a,
href: new_projects_query_path,
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
},
classes: 'Button--invisibleOP')) do |button|
button.with_leading_visual_icon(icon: :'op-save')

t('button_save_as')
end %>
<% header.with_action_link(mobile_icon: nil, # Do not show on mobile as it is already part of the menu
mobile_label: nil,
href: new_projects_query_path,
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
}) do %>
<% render(Primer::Beta::Octicon.new(icon: "op-save",
align_self: :center,
"aria-label": I18n.t("button_save_as"),
mr: 1)
) + content_tag(:span, t("button_save_as")) %>
Copy link
Contributor

Choose a reason for hiding this comment

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

It would read easier if one could say something like:


header.with_action_link(**options) do |link|
  link.with_leading_visual_icon('op-save')
  t('button_save_as')
end  

or have the text and the icon be part of the with_action_link method. But that does not seem to be along the line of thinking of how Primer components are build.

What also strikes me as weird is that a link is used and not a button. This seems to violate the statement of primer: "Links navigate you to a new place or new content. Do not use links for triggering an action. Instead, use buttons, which are designed to activate a feature." (source)

Copy link
Contributor

Choose a reason for hiding this comment

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

header.with_action_link(**options) do |link|
link.with_leading_visual_icon('op-save')
t('button_save_as')
end

The link component unfortunately does not support leading visual (although they mention it in the docs, it is not implemented).

The product team and I discussed the decision for the link for quite some time. Of course, the invisible button would be the best solution. However, Primer has this weird behavior of changing the font color of that buttons depending on the existance of an icon. The issue I raised for that in Primer was closed witht the comment that it "is working as expected" 🤷 Since GitHub and even Primer itself is very fuzzy when it comes to their usage of Buttons vs Links, we decided to go with the Link at this place.

<% end %>
<% end %>

<%= render(Primer::Alpha::ActionMenu.new) do |menu|
menu.with_show_button(icon: 'op-kebab-vertical', 'aria-label': t(:label_more), data: { 'test-selector': 'project-more-dropdown-menu' })

if gantt_portfolio_project_ids.any?
menu.with_item(
tag: :a,
label: t('projects.index.open_as_gantt'),
href: gantt_portfolio_query_link,
id: 'projects-index-open-as-gantt',
content_arguments: { target: '_blank' }
) do |item|
item.with_leading_visual_icon(icon: 'op-view-timeline')
end
end

<%= header.with_action_menu(menu_arguments: {
HDinger marked this conversation as resolved.
Show resolved Hide resolved
anchor_align: :end
},
button_arguments: {
icon: "op-kebab-vertical",
"aria-label": t(:label_more),
data: { "test-selector": "project-more-dropdown-menu" }
}) do |menu, button|
HDinger marked this conversation as resolved.
Show resolved Hide resolved
if gantt_portfolio_project_ids.any?
menu.with_item(
tag: :a,
label: t(:label_overall_activity),
href: activities_path
label: t('projects.index.open_as_gantt'),
href: gantt_portfolio_query_link,
id: 'projects-index-open-as-gantt',
content_arguments: { target: '_blank' }
) do |item|
item.with_leading_visual_icon(icon: 'tasklist')
item.with_leading_visual_icon(icon: 'op-view-timeline')
end
end

if query_saveable?
menu.with_item(
label: t('button_save_as'),
href: new_projects_query_path,
content_arguments: {
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
}
}
) do |item|
item.with_leading_visual_icon(icon: :'op-save')
end
end
menu.with_item(
tag: :a,
label: t(:label_overall_activity),
href: activities_path
) do |item|
item.with_leading_visual_icon(icon: 'tasklist')
end

if query_saveable?
menu.with_item(
label: t('js.label_export'),
content_arguments: { 'data-show-dialog-id': Projects::ExportListModalComponent::MODAL_ID }
label: t('button_save_as'),
href: new_projects_query_path,
content_arguments: {
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
}
}
) do |item|
item.with_leading_visual_icon(icon: 'sign-out')
item.with_leading_visual_icon(icon: :'op-save')
end
end

menu.with_item(
label: t('js.label_export'),
content_arguments: { 'data-show-dialog-id': Projects::ExportListModalComponent::MODAL_ID }
) do |item|
item.with_leading_visual_icon(icon: 'sign-out')
end

menu.with_item(
label: t(:'queries.configure_view.heading'),
content_arguments: { 'data-show-dialog-id': Projects::ConfigureViewModalComponent::MODAL_ID }
) do |item|
item.with_leading_visual_icon(icon: :gear)
end

if query.persisted?
menu.with_item(
label: t(:'queries.configure_view.heading'),
content_arguments: { 'data-show-dialog-id': Projects::ConfigureViewModalComponent::MODAL_ID }
label: t(:button_delete),
scheme: :danger,
content_arguments: { 'data-show-dialog-id': Projects::DeleteListModalComponent::MODAL_ID }
) do |item|
item.with_leading_visual_icon(icon: :gear)
end

if query.persisted?
menu.with_item(
label: t(:button_delete),
scheme: :danger,
content_arguments: { 'data-show-dialog-id': Projects::DeleteListModalComponent::MODAL_ID }
) do |item|
item.with_leading_visual_icon(icon: 'trash')
end
item.with_leading_visual_icon(icon: 'trash')
end
end
%>
<% end %>
end
%>

<% else %>
<% header.with_title(mt: 2, mb: 2, data: { 'test-selector': 'project-query-name'}) do
primer_form_with(model: query,
url: projects_queries_path,
scope: 'query',
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
},
id: 'project-save-form') do |f|
render(Queries::Projects::Create.new(f))
end
end %>
<% header.with_title(data: { 'test-selector': 'project-query-name'}) do
primer_form_with(model: query,
url: projects_queries_path,
scope: 'query',
data: {
controller: "params-from-query",
'application-target': "dynamic",
'params-from-query-allowed-value': '["filters", "columns"]'
},
id: 'project-save-form') do |f|
render(Queries::Projects::Create.new(f))
end
end %>
<% header.with_breadcrumbs(breadcrumb_items)%>
<% end %>
<% end %>

Expand Down
Loading
Loading