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 subitems widget and status label

Oliver Günther3c7e0383d6b5
diff --git a/app/components/projects/index_sub_header_component.html.erb b/app/components/projects/index_sub_header_component.html.erb
index f44b08fa48c..0999c5b92fe 100644
--- a/app/components/projects/index_sub_header_component.html.erb
+++ b/app/components/projects/index_sub_header_component.html.erb
@@ -49,7 +49,7 @@
disabled: @disable_buttons,
size: :medium
) do |item|
- item.with_leading_visual_icon(icon: new_workspace_icon(new_type))
+ item.with_leading_visual_icon(icon: helpers.workspace_icon(new_type))
end
end
end
diff --git a/app/components/projects/index_sub_header_component.rb b/app/components/projects/index_sub_header_component.rb
index 33ff18d3189..992efa4bbcd 100644
--- a/app/components/projects/index_sub_header_component.rb
+++ b/app/components/projects/index_sub_header_component.rb
@@ -86,17 +86,6 @@ module Projects
I18n.t(:"label_#{type}")
end
- def new_workspace_icon(type)
- case type
- when Project.workspace_types[:project]
- :project
- when Project.workspace_types[:portfolio]
- :briefcase
- when Project.workspace_types[:program]
- :"project-roadmap"
- end
- end
-
def allowed_new_workspace_types
allowed_types = []
allowed_types << Project.workspace_types[:project] if @current_user.allowed_globally?(:add_project)
diff --git a/app/components/projects/status_badge_component.html.erb b/app/components/projects/status_badge_component.html.erb
new file mode 100644
index 00000000000..ff6ee7c2f31
--- /dev/null
+++ b/app/components/projects/status_badge_component.html.erb
@@ -0,0 +1,3 @@
+<%=
+ render(Primer::Beta::Label.new(size: :medium, inline: true, **@system_arguments)) { name }
+%>
diff --git a/app/components/projects/status_badge_component.rb b/app/components/projects/status_badge_component.rb
new file mode 100644
index 00000000000..3229b623f21
--- /dev/null
+++ b/app/components/projects/status_badge_component.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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.
+#++
+
+class Projects::StatusBadgeComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+ include Primer::ClassNameHelper
+
+ def initialize(project:, **system_arguments)
+ super
+
+ @project = project
+ @status = find_status(project.status_code)
+ @system_arguments = system_arguments
+ end
+
+ def before_render
+ @system_arguments[:classes] = class_names(
+ @system_arguments[:classes],
+ helpers.hl_background_class(:project_status, @status.id)
+ )
+ end
+
+ def render?
+ @status.present?
+ end
+
+ def name
+ helpers.project_status_name(@project.status_code)
+ end
+
+ def find_status(code)
+ Projects::Statuses::AVAILABLE.find(-> { Projects::Statuses::NOT_SET }) { it.code&.to_s == code }
+ end
+end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 601bdfeaf50..99469be7f72 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -88,14 +88,4 @@ module ProjectsHelper
def projects_query_params
safe_query_params(PROJECTS_QUERY_PARAM_NAMES)
end
-
- def new_workspace_title(workspace)
- if workspace.project?
- I18n.t(:label_project_new)
- elsif workspace.portfolio?
- I18n.t(:label_portfolio_new)
- elsif workspace.program?
- I18n.t(:label_program_new)
- end
- end
end
diff --git a/app/helpers/workspace_helper.rb b/app/helpers/workspace_helper.rb
new file mode 100644
index 00000000000..86687dd880a
--- /dev/null
+++ b/app/helpers/workspace_helper.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 WorkspaceHelper
+ def new_workspace_title(workspace)
+ if workspace.project?
+ I18n.t(:label_project_new)
+ elsif workspace.portfolio?
+ I18n.t(:label_portfolio_new)
+ elsif workspace.program?
+ I18n.t(:label_program_new)
+ end
+ end
+
+ def workspace_icon(type)
+ case type
+ when Project.workspace_types[:portfolio]
+ :briefcase
+ when Project.workspace_types[:program]
+ :"project-roadmap"
+ else
+ :project
+ end
+ end
+end
diff --git a/modules/overviews/app/components/_index.sass b/modules/overviews/app/components/_index.sass
index 8b28685c0b2..747c81a350a 100644
--- a/modules/overviews/app/components/_index.sass
+++ b/modules/overviews/app/components/_index.sass
@@ -1,2 +1,3 @@
@import "./overviews/project_custom_fields/item_component.sass"
@import "./overviews/project_phases/item_component.sass"
+@import "./overviews/show_component.sass"
diff --git a/modules/overviews/app/components/overviews/widgets/subitems_component.html.erb b/modules/overviews/app/components/overviews/widgets/subitems_component.html.erb
new file mode 100644
index 00000000000..8199e30654b
--- /dev/null
+++ b/modules/overviews/app/components/overviews/widgets/subitems_component.html.erb
@@ -0,0 +1,69 @@
+<%#-- copyright
+
+OpenProject is an open source project management software.
+Copyright (C) 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.
+
+++#%>
+
+<%=
+ component_wrapper do
+ render(Primer::Beta::BorderBox.new) do |component|
+ component.with_header do
+ render(Primer::Beta::Text.new) { title }
+ end
+
+ if children.empty?
+ component.with_row do
+ render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("overviews.widgets.subitems.no_visible_children") }
+ end
+ else
+ children.find_each do |child|
+ component.with_row do
+ flex_layout do |row|
+ row.with_column do
+ render(Primer::Beta::Text.new(color: :subtle)) do
+ concat render Primer::Beta::Octicon.new(icon: helpers.workspace_icon(child),
+ mr: 1,
+ color: :subtle,
+ "aria-label": child.workspace_label)
+ concat child.workspace_label
+ end
+ end
+
+ row.with_column(ml: 2) do
+ render(Primer::Beta::Link.new(href: project_path(child))) { child.name }
+ end
+
+ row.with_column(ml: 2) do
+ render(Projects::StatusBadgeComponent.new(project: child))
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/overviews/app/components/overviews/widgets/subitems_component.rb b/modules/overviews/app/components/overviews/widgets/subitems_component.rb
new file mode 100644
index 00000000000..c2c6fd2622c
--- /dev/null
+++ b/modules/overviews/app/components/overviews/widgets/subitems_component.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 Overviews
+ module Widgets
+ class SubitemsComponent < ApplicationComponent
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+ include ApplicationHelper
+
+ def project = model
+
+ delegate :description, to: :project
+
+ def title
+ I18n.t("overviews.widgets.subitems.in_this_#{project.workspace_type}")
+ end
+
+ def children
+ @children ||= project.children.visible
+ end
+ end
+ end
+end
diff --git a/modules/overviews/app/views/overviews/overviews/_page_header.html.erb b/modules/overviews/app/views/overviews/overviews/_page_header.html.erb
index 30cda74a2d5..0f54ade9810 100644
--- a/modules/overviews/app/views/overviews/overviews/_page_header.html.erb
+++ b/modules/overviews/app/views/overviews/overviews/_page_header.html.erb
@@ -4,7 +4,7 @@
header.with_breadcrumbs(
[
{ href: project_path(@project), text: @project.name, skip_for_mobile: true },
- t("overviews.label")
+ I18n.t("overviews.label_home", workspace_type: @project.workspace_label)
]
)
favored = @project.favored_by?(User.current)
diff --git a/modules/overviews/config/locales/en.yml b/modules/overviews/config/locales/en.yml
index 91e68918729..158daf33827 100644
--- a/modules/overviews/config/locales/en.yml
+++ b/modules/overviews/config/locales/en.yml
@@ -3,4 +3,11 @@ en:
label_home: "%{workspace_type} home"
label_dashboard: "Dashboard"
label_overview: 'Overview'
+
+ widgets:
+ subitems:
+ in_this_portfolio: "In this portfolio"
+ in_this_program: "In this program"
+ in_this_project: "In this project"
+ no_visible_children: "There are no visible children."
permission_manage_overview: 'Manage overview page'