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
Render a custom empty state component when the project query is public
Aaron Contreras2b24c4dfec3b
diff --git a/app/components/shares/modal_body_component.html.erb b/app/components/shares/modal_body_component.html.erbindex 2ee90bfccba..2995901dc0d 100644--- a/app/components/shares/modal_body_component.html.erb+++ b/app/components/shares/modal_body_component.html.erb@@ -101,7 +101,7 @@render(strategy.empty_state_component.new(strategy: strategy))elserender(Shares::EmptyStateComponent.new(strategy: strategy))- end+ endendelse@shares.each do |share|diff --git a/app/components/shares/project_queries/empty_state_component.html.erb b/app/components/shares/project_queries/empty_state_component.html.erbnew file mode 100644index 00000000000..64e117e461b--- /dev/null+++ b/app/components/shares/project_queries/empty_state_component.html.erb@@ -0,0 +1,15 @@+<%= render(Primer::Beta::Blankslate.new) do |component|+ component.with_visual_icon(icon: blankslate_config[:icon], size: :medium)+ component.with_heading(tag: :h2).with_content(+ blankslate_config[:heading_text],+ )+ component.with_description do+ flex_layout do |flex|+ flex.with_row(mb: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) do+ blankslate_config[:description_text]+ end+ end+ end+ end+end %>diff --git a/app/components/shares/project_queries/empty_state_component.rb b/app/components/shares/project_queries/empty_state_component.rbnew file mode 100644index 00000000000..228cd84d742--- /dev/null+++ b/app/components/shares/project_queries/empty_state_component.rb@@ -0,0 +1,60 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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+ module ProjectQueries+ class EmptyStateComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+ include OpPrimer::ComponentHelpers++ def initialize(strategy:)+ super++ @strategy = strategy+ @entity = strategy.entity+ end++ private++ attr_reader :strategy, :entity++ def blankslate_config # rubocop:disable Metrics/AbcSize+ @blankslate_config ||= {}.tap do |config|+ if params[:filters].blank?+ config[:icon] = :people+ config[:heading_text] = "ABC"+ config[:description_text] = I18n.t("sharing.text_empty_state_description", entity: @entity.class.model_name.human)+ else+ config[:icon] = :search+ config[:heading_text] = I18n.t("sharing.text_empty_search_header")+ config[:description_text] = I18n.t("sharing.text_empty_search_description")+ end+ end+ end+ end+ end+enddiff --git a/app/models/sharing_strategies/project_query_strategy.rb b/app/models/sharing_strategies/project_query_strategy.rbindex 279bd32a0a8..163397655b0 100644--- a/app/models/sharing_strategies/project_query_strategy.rb+++ b/app/models/sharing_strategies/project_query_strategy.rb@@ -62,5 +62,9 @@ module SharingStrategiesdef additional_body_componentShares::ProjectQueries::PublicFlagComponentend++ def empty_state_component+ Shares::ProjectQueries::EmptyStateComponent if @entity.public?+ endendend