Skip to content

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

Pass a closing url to the split screen so that we know where to go to

Henriette Dargec47ebeddf14d
diff --git a/app/components/work_packages/details/tab_component.html.erb b/app/components/work_packages/details/tab_component.html.erb
index 2ee6faecbc0..b1ed9590c52 100644
--- a/app/components/work_packages/details/tab_component.html.erb
+++ b/app/components/work_packages/details/tab_component.html.erb
@@ -15,6 +15,7 @@
end
end
end
+
flex.with_column(classes: "op-work-package-details-tab-component--action") do
render(Primer::Beta::IconButton.new(icon: :"screen-full",
tag: :a,
@@ -23,8 +24,13 @@
scheme: :invisible,
aria: { label: I18n.t("js.button_show_fullscreen") }))
end
- flex.with_column(pt: 2, border: :bottom, border_color: :muted, classes: "op-work-package-details-tab-component--action") do
- render(Primer::Beta::IconButton.new(icon: :x, scheme: :invisible, aria: { label: I18n.t(:button_close) }))
+
+ flex.with_column(classes: "op-work-package-details-tab-component--action") do
+ render(Primer::Beta::IconButton.new(icon: :x,
+ tag: :a,
+ href: url_helpers.send(base_route),
+ scheme: :invisible,
+ aria: { label: I18n.t(:button_close) }))
end
end
%>
diff --git a/app/components/work_packages/details/tab_component.rb b/app/components/work_packages/details/tab_component.rb
index fe6fbdee583..741792ef396 100644
--- a/app/components/work_packages/details/tab_component.rb
+++ b/app/components/work_packages/details/tab_component.rb
@@ -5,13 +5,14 @@ class WorkPackages::Details::TabComponent < ApplicationComponent
include OpTurbo::Streamable
include Redmine::MenuManager::MenuHelper
- attr_reader :tab, :work_package
+ attr_reader :tab, :work_package, :base_route
- def initialize(work_package:, tab: :overview)
+ def initialize(work_package:, base_route:, tab: :overview)
super
@work_package = work_package
@tab = tab.to_sym
+ @base_route = base_route
end
delegate :project, to: :work_package
diff --git a/app/components/work_packages/split_view_component.html.erb b/app/components/work_packages/split_view_component.html.erb
index acc9a32cede..2d11e4c2816 100644
--- a/app/components/work_packages/split_view_component.html.erb
+++ b/app/components/work_packages/split_view_component.html.erb
@@ -12,7 +12,7 @@
end
else
flex.with_row do
- render(WorkPackages::Details::TabComponent.new(work_package: @work_package, tab: @tab))
+ render(WorkPackages::Details::TabComponent.new(work_package: @work_package, tab: @tab, base_route: @base_route))
end
flex.with_row(flex: 1) do
helpers.angular_component_tag "opce-wp-split-view",
diff --git a/app/components/work_packages/split_view_component.rb b/app/components/work_packages/split_view_component.rb
index 7db9672ac25..5946b80cd7b 100644
--- a/app/components/work_packages/split_view_component.rb
+++ b/app/components/work_packages/split_view_component.rb
@@ -4,11 +4,12 @@ class WorkPackages::SplitViewComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
- def initialize(id:, tab: "overview")
+ def initialize(id:, base_route:, tab: "overview")
super
@id = id
@tab = tab
@work_package = WorkPackage.visible.find_by(id:)
+ @base_route = base_route
end
end
diff --git a/app/helpers/work_packages/split_view_helper.rb b/app/helpers/work_packages/split_view_helper.rb
index edeb97b2527..c41f29ad96b 100644
--- a/app/helpers/work_packages/split_view_helper.rb
+++ b/app/helpers/work_packages/split_view_helper.rb
@@ -3,7 +3,9 @@ module WorkPackages::SplitViewHelper
return unless params[:work_package_split_view]
content_for :content_body_right do
- render WorkPackages::SplitViewComponent.new(id: params[:work_package_id], tab: params[:tab])
+ render WorkPackages::SplitViewComponent.new(id: params[:work_package_id],
+ tab: params[:tab],
+ base_route: params[:base_route] || work_packages_path)
end
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 223f608f278..0d82903b420 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -705,11 +705,12 @@ Rails.application.routes.draw do
action: options.fetch(:action, :split_view),
defaults: { tab: :overview },
as: :details,
- work_package_split_view: true
+ work_package_split_view: true,
+ base_route: options.fetch(:base_route)
end
resources :notifications, only: :index do
- concerns :with_split_view
+ concerns :with_split_view, base_route: :notifications_path
collection do
post :mark_all_read
diff --git a/spec/components/previews/work_packages/split_view_component_preview.rb b/spec/components/previews/work_packages/split_view_component_preview.rb
index 5d951149e24..775f6279f59 100644
--- a/spec/components/previews/work_packages/split_view_component_preview.rb
+++ b/spec/components/previews/work_packages/split_view_component_preview.rb
@@ -2,6 +2,6 @@
class WorkPackages::SplitViewComponentPreview < ViewComponent::Preview
def default
- render(WorkPackages::SplitViewComponent.new(work_package: "work_package", tab: "tab"))
+ render(WorkPackages::SplitViewComponent.new(id: "1", tab: "tab", base_url: work_packages_path))
end
end