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 ShareDialog preview
Klaus Zandersc8fa05b13a3b
diff --git a/app/components/shares/share_dialog_component.html.erb b/app/components/shares/share_dialog_component.html.erbnew file mode 100644index 00000000000..e9e061841c7--- /dev/null+++ b/app/components/shares/share_dialog_component.html.erb@@ -0,0 +1,8 @@+<%=+ render(Primer::Alpha::Dialog.new(title: t(:label_share_project_list), id: 'sharing-modal', data: { 'keep-open-on-submit': true }, size: :xlarge)) do |d|+ d.with_header(variant: :large)+ d.with_body do+ render(Shares::ModalBodyComponent.new(strategy:, shares:, errors:))+ end+ end+%>diff --git a/app/components/shares/share_dialog_component.rb b/app/components/shares/share_dialog_component.rbnew file mode 100644index 00000000000..e9e56d6cc76--- /dev/null+++ b/app/components/shares/share_dialog_component.rb@@ -0,0 +1,49 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Shares+ class ShareDialogComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(shares:, strategy:, errors:)+ super++ @strategy = strategy+ @shares = shares+ @errors = errors+ end++ private++ attr_reader :shares, :strategy, :errors+ end+enddiff --git a/app/views/shares/dialog.turbo_stream.erb b/app/views/shares/dialog.turbo_stream.erbindex 7c16bd93ef1..9e5a07ab197 100644--- a/app/views/shares/dialog.turbo_stream.erb+++ b/app/views/shares/dialog.turbo_stream.erb@@ -1,12 +1,4 @@<%= turbo_stream.dialog do- render(Primer::Alpha::Dialog.new(title: t(:label_share_project_list),- id: 'sharing-modal',- data: { 'keep-open-on-submit': true },- size: :xlarge)) do |d|- d.with_header(variant: :large)- d.with_body do- render(Shares::ModalBodyComponent.new(strategy: @sharing_strategy, shares: @shares, errors: @errors))- end- end+ render(Shares::ShareDialogComponent.new(strategy: @sharing_strategy, shares: @shares, errors: @errors))end%>diff --git a/lookbook/previews/shares/share_dialog_component_preview.rb b/lookbook/previews/shares/share_dialog_component_preview.rbnew file mode 100644index 00000000000..8818bcb4e50--- /dev/null+++ b/lookbook/previews/shares/share_dialog_component_preview.rb@@ -0,0 +1,23 @@+module 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:)+ errors = []+ shares = []++ render(Shares::ShareDialogComponent.new(strategy:, shares:, errors:))+ end++ def work_package+ user = FactoryBot.build_stubbed(:admin)+ work_package = FactoryBot.build_stubbed(:work_package)+ strategy = SharingStrategies::WorkPackageStrategy.new(work_package, user:)+ errors = []+ shares = []++ render(Shares::ShareDialogComponent.new(strategy:, shares:, errors:))+ end+ end+end