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

Add an open paramter to the ShareDialog so we can open it in Lookbook

Klaus Zanders8f9e0afa2d74
diff --git a/app/components/shares/share_dialog_component.html.erb b/app/components/shares/share_dialog_component.html.erb
index 885fae1ddcf..d3c7f273265 100644
--- a/app/components/shares/share_dialog_component.html.erb
+++ b/app/components/shares/share_dialog_component.html.erb
@@ -1,5 +1,5 @@
<%=
- render(Primer::Alpha::Dialog.new(title: t(:label_share_project_list), id: 'sharing-modal', data: { 'keep-open-on-submit': true }, size: :xlarge)) do |d|
+ render(Primer::Alpha::Dialog.new(title: strategy.title, id: 'sharing-modal', data: { 'keep-open-on-submit': true }, size: :xlarge, open: open)) do |d|
d.with_header(variant: :large, mb: 3)
d.with_body do
render(strategy.modal_body_component(errors))
diff --git a/app/components/shares/share_dialog_component.rb b/app/components/shares/share_dialog_component.rb
index 63ad3ba6f08..ea7a0444a20 100644
--- a/app/components/shares/share_dialog_component.rb
+++ b/app/components/shares/share_dialog_component.rb
@@ -34,15 +34,16 @@ module Shares
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(strategy:, errors:)
+ def initialize(strategy:, errors:, open: false)
super
@strategy = strategy
@errors = errors
+ @open = open
end
private
- attr_reader :strategy, :errors
+ attr_reader :strategy, :errors, :open
end
end
diff --git a/lookbook/previews/shares/share_dialog_component_preview.rb b/lookbook/previews/shares/share_dialog_component_preview.rb
index 8818bcb4e50..75d131c0ce5 100644
--- a/lookbook/previews/shares/share_dialog_component_preview.rb
+++ b/lookbook/previews/shares/share_dialog_component_preview.rb
@@ -1,23 +1,22 @@
module Shares
+ # @logical_path OpenProject/Shares
class ShareDialogComponentPreview < Lookbook::Preview
def project_query
user = FactoryBot.build_stubbed(:admin)
query = FactoryBot.build_stubbed(:project_query, user:)
- strategy = SharingStrategies::ProjectQueryStrategy.new(query, user:)
+ strategy = SharingStrategies::ProjectQueryStrategy.new(query, user:, query_params: {})
errors = []
- shares = []
- render(Shares::ShareDialogComponent.new(strategy:, shares:, errors:))
+ render(Shares::ShareDialogComponent.new(strategy:, errors:, open: true))
end
def work_package
user = FactoryBot.build_stubbed(:admin)
work_package = FactoryBot.build_stubbed(:work_package)
- strategy = SharingStrategies::WorkPackageStrategy.new(work_package, user:)
+ strategy = SharingStrategies::WorkPackageStrategy.new(work_package, user:, query_params: {})
errors = []
- shares = []
- render(Shares::ShareDialogComponent.new(strategy:, shares:, errors:))
+ render(Shares::ShareDialogComponent.new(strategy:, errors:, open: true))
end
end
end