OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add options for a create button in the submenu component
Henriette Dargeac168fef2e0c
diff --git a/app/components/open_project/common/submenu_component.html.erb b/app/components/open_project/common/submenu_component.html.erbindex 659a2f60a49..35e4f8e2a95 100644--- a/app/components/open_project/common/submenu_component.html.erb+++ b/app/components/open_project/common/submenu_component.html.erb@@ -3,6 +3,7 @@<div class="op-sidebar--search"><%= render Primer::Alpha::TextField.new(name: "search",label: I18n.t("label_search"),+ placeholder: I18n.t("label_search"),leading_visual: { icon: :search },visually_hide_label: true,classes: "op-sidebar--search-input",@@ -68,4 +69,16 @@</div><% end %></div>++ <% if @create_btn_options.present? %>+ <div class="op-sidebar--footer">+ <%= render Primer::Beta::Button.new(scheme: :primary,+ tag: :a,+ href: @create_btn_options[:href],+ classes: "op-sidebar--footer-action") do |button|+ button.with_leading_visual_icon(icon: "plus")+ @create_btn_options[:text]+ end %>+ </div>+ <% end %></div>diff --git a/app/components/open_project/common/submenu_component.rb b/app/components/open_project/common/submenu_component.rbindex d786f62c1ad..e0cdcf88ea1 100644--- a/app/components/open_project/common/submenu_component.rb+++ b/app/components/open_project/common/submenu_component.rb@@ -31,10 +31,11 @@module OpenProjectmodule Commonclass SubmenuComponent < ApplicationComponent- def initialize(sidebar_menu_items: nil, searchable: false)+ def initialize(sidebar_menu_items: nil, searchable: false, create_btn_options: nil)super()@sidebar_menu_items = sidebar_menu_items@searchable = searchable+ @create_btn_options = create_btn_optionsenddef render?diff --git a/frontend/src/global_styles/layout/_main_menu.sass b/frontend/src/global_styles/layout/_main_menu.sassindex ccd16383f44..6bb12990f9e 100644--- a/frontend/src/global_styles/layout/_main_menu.sass+++ b/frontend/src/global_styles/layout/_main_menu.sass@@ -71,7 +71,7 @@ $arrow-left-width: 40pxoverflow: auto@include styled-scroll-bar- a:focus+ a:not(.Button):focuscolor: var(--main-menu-font-color)ul@@ -105,11 +105,11 @@ $arrow-left-width: 40px// explicitly reset to zero to avoid selector precedence problemspadding-left: 0- .main-menu--children li a+ .main-menu--children li a:not(.Button)// children have no icon so we need to push them right.padding-left: 24px- a+ a:not(.Button)text-decoration: noneline-height: var(--main-menu-item-height)position: relative@@ -143,7 +143,7 @@ $arrow-left-width: 40px.toggler:hover@include main-menu-hover- a+ a:not(.Button)border: 1px solid transparent&.selected, &.selected + a@@ -158,10 +158,10 @@ $arrow-left-width: 40px& ~ .toggler@include main-menu-hover- a:not(.toggler)+ a:not(.Button):not(.toggler)@extend .small-12- a:not(:only-child):first-of-type+ a:not(.Button):not(:only-child):first-of-typeflex: 0 0 calc(100% - 40px)max-width: calc(100% - 40px)@@ -259,7 +259,7 @@ a.main-menu--parent-node&.menu_root> li.main-item-wrapper- a:not(:only-child)+ a:not(.Button):not(:only-child)@extend .small-12.ellipsis@@ -284,7 +284,7 @@ a.main-menu--parent-nodefont-family: var(--body-font-family)font-style: normal- a, a:link+ a:not(.Button), a:not(.Button):link&:not(.searchable-menu--item-link):not(.searchable-menu--category-icon)color: var(--main-menu-font-color)display: inlinediff --git a/lookbook/previews/open_project/common/submenu_component_preview.rb b/lookbook/previews/open_project/common/submenu_component_preview.rbindex bda7c923905..b8d4bce36f2 100644--- a/lookbook/previews/open_project/common/submenu_component_preview.rb+++ b/lookbook/previews/open_project/common/submenu_component_preview.rb@@ -5,7 +5,7 @@ module OpenProject# @label Defaultdef defaultrender_with_template(template: "open_project/common/submenu_preview/playground",- locals: { sidebar_menu_items: menu_items, searchable: false })+ locals: { sidebar_menu_items: menu_items, searchable: false, create_btn_options: nil })end# @label Searchable@@ -13,7 +13,15 @@ module OpenProject# It will be fine in production.def searchablerender_with_template(template: "open_project/common/submenu_preview/playground",- locals: { sidebar_menu_items: menu_items, searchable: true })+ locals: { sidebar_menu_items: menu_items, searchable: true, create_btn_options: nil })+ end++ # @label With create Button+ # `create_btn_options: { href: "/#", text: "User"}`+ def with_create_button+ render_with_template(template: "open_project/common/submenu_preview/playground",+ locals: { sidebar_menu_items: menu_items, searchable: true,+ create_btn_options: { href: "/#", text: "User" } })endprivatediff --git a/lookbook/previews/open_project/common/submenu_preview/playground.html.erb b/lookbook/previews/open_project/common/submenu_preview/playground.html.erbindex ccdbaaa2788..2aead4a5728 100644--- a/lookbook/previews/open_project/common/submenu_preview/playground.html.erb+++ b/lookbook/previews/open_project/common/submenu_preview/playground.html.erb@@ -1,6 +1,8 @@<div class="main-menu"> <!-- Meant to be rendered inside the left-handed sidebar and is currently depending on that --><%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: sidebar_menu_items,- searchable: searchable)+ searchable: searchable,+ create_btn_options: create_btn_options+ )%></div>diff --git a/modules/calendar/app/controllers/calendar/menus_controller.rb b/modules/calendar/app/controllers/calendar/menus_controller.rbindex d500883d311..a0219a1db6d 100644--- a/modules/calendar/app/controllers/calendar/menus_controller.rb+++ b/modules/calendar/app/controllers/calendar/menus_controller.rb@@ -32,6 +32,9 @@ module ::Calendardef show@submenu_menu_items = ::Calendar::Menu.new(project: @project, params:).menu_items+ @create_btn_options = if User.current.allowed_in_any_project?(:manage_calendars)+ { href: new_project_calendars_path(@project), text: I18n.t("label_calendar") }+ endrender layout: nilenddiff --git a/modules/calendar/app/views/calendar/menus/show.html.erb b/modules/calendar/app/views/calendar/menus/show.html.erbindex a65dd2af4a4..a7e71e26a21 100644--- a/modules/calendar/app/views/calendar/menus/show.html.erb+++ b/modules/calendar/app/views/calendar/menus/show.html.erb@@ -1,3 +1,5 @@<%= turbo_frame_tag "calendar_sidemenu" do %>- <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items, searchable: true) %>+ <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items,+ searchable: true,+ create_btn_options: @create_btn_options) %><% end %>