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
Migrate angular subitems widget to rails based implementation
Henriette Darge65843f218ede
diff --git a/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.html b/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.htmlindex 739a65b5352..d82ef9f8717 100644--- a/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.html+++ b/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.html@@ -6,18 +6,6 @@[resource]="resource" /></widget-header>-<div class="op-widget-box--body">- @if (noEntries) {- <op-no-results [title]="text.noResults" />- }- @for (project of projects; track project; let last = $last) {- <span>- <a [href]="projectPath(project)"- [textContent]="projectName(project)">- </a>- @if (!last) {- <span>, </span>- }- </span>- }+<div class="op-widget-box--body -allow-inner-overflow">+ <turbo-frame [id]="frameId" [src]="src" loading="lazy" /></div>diff --git a/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.ts b/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.tsindex e6f3ad16db5..a7b043f224b 100644--- a/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.ts+++ b/frontend/src/app/shared/components/grids/widgets/subprojects/subprojects.component.ts@@ -1,75 +1,15 @@-import { AbstractWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-widget.component';import {- ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector, OnInit,+ ChangeDetectionStrategy,+ Component,} from '@angular/core';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { ProjectResource } from 'core-app/features/hal/resources/project-resource';-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import { ApiV3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';-import { TimezoneService } from 'core-app/core/datetime/timezone.service';-import { MAGIC_PAGE_NUMBER } from 'core-app/core/apiv3/helpers/get-paginated-results';+import { AbstractTurboWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-turbo-widget.component';@Component({templateUrl: './subprojects.component.html',changeDetection: ChangeDetectionStrategy.OnPush,standalone: false,})-export class WidgetSubprojectsComponent extends AbstractWidgetComponent implements OnInit {- public text = {- noResults: this.i18n.t('js.grid.widgets.subprojects.no_results'),- };-- public projects:ProjectResource[];-- constructor(- readonly halResource:HalResourceService,- readonly pathHelper:PathHelperService,- readonly i18n:I18nService,- protected readonly injector:Injector,- readonly timezone:TimezoneService,- readonly apiV3Service:ApiV3Service,- readonly currentProject:CurrentProjectService,- readonly cdr:ChangeDetectorRef,- ) {- super(i18n, injector);- }-- ngOnInit() {- this- .apiV3Service- .projects- .list(this.projectListParams)- .subscribe((collection) => {- this.projects = collection.elements;-- this.cdr.detectChanges();- });- }-- public get isEditable() {- return false;- }-- public projectPath(project:ProjectResource) {- return this.pathHelper.projectPath(project.identifier);- }-- public projectName(project:ProjectResource) {- return project.name;- }-- public get noEntries() {- return this.projects && !this.projects.length;- }-- private get projectListParams():ApiV3ListParameters {- return {- sortBy: [['name', 'asc']],- filters: [['parent_id', '=', [this.currentProject.id!]], ['active', '=', ['t']]],- pageSize: MAGIC_PAGE_NUMBER,- };- }+export class WidgetSubprojectsComponent extends AbstractTurboWidgetComponent {+ override frameId = 'overviews-widgets-subitems-component';+ override name = 'subitems';}diff --git a/modules/overviews/app/components/overviews/widgets/news_component.rb b/modules/overviews/app/components/overviews/widgets/news_component.rbindex 4765f842dbe..c434f564d9e 100644--- a/modules/overviews/app/components/overviews/widgets/news_component.rb+++ b/modules/overviews/app/components/overviews/widgets/news_component.rb@@ -60,7 +60,6 @@ module Overviewsdef titleProject.human_attribute_name(:news)end-endendenddiff --git a/modules/overviews/app/controllers/overviews/widgets/subitems_controller.rb b/modules/overviews/app/controllers/overviews/widgets/subitems_controller.rbnew file mode 100644index 00000000000..80a047c8600--- /dev/null+++ b/modules/overviews/app/controllers/overviews/widgets/subitems_controller.rb@@ -0,0 +1,32 @@+# 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 Overviews::Widgets::SubitemsController < Overviews::WidgetController+enddiff --git a/modules/overviews/app/views/overviews/widgets/subitems/show.html.erb b/modules/overviews/app/views/overviews/widgets/subitems/show.html.erbnew file mode 100644index 00000000000..2f70002bc3e--- /dev/null+++ b/modules/overviews/app/views/overviews/widgets/subitems/show.html.erb@@ -0,0 +1,30 @@+<%#-- 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.++++#%>++<%= render Overviews::Widgets::SubitemsComponent.new(@project) %>diff --git a/modules/overviews/config/routes.rb b/modules/overviews/config/routes.rbindex b3abccb5a94..f110b217a83 100644--- a/modules/overviews/config/routes.rb+++ b/modules/overviews/config/routes.rb@@ -20,6 +20,7 @@ Rails.application.routes.draw donamespace :widgets doresource :project_status, only: %i[show update]resource :news, only: %i[show]+ resource :subitems, only: %i[show]endendenddiff --git a/modules/overviews/lib/overviews/engine.rb b/modules/overviews/lib/overviews/engine.rbindex 121293ac501..c3562da3247 100644--- a/modules/overviews/lib/overviews/engine.rb+++ b/modules/overviews/lib/overviews/engine.rb@@ -49,7 +49,8 @@ module Overviews.push("overviews/overviews/show","overviews/overviews/dashboard",- "overviews/widgets/project_statuses/show"+ "overviews/widgets/project_statuses/show",+ "overviews/widgets/subitems/show")OpenProject::AccessControl.permission(:edit_project)diff --git a/modules/overviews/spec/controllers/overviews/widgets/subitems_controller_spec.rb b/modules/overviews/spec/controllers/overviews/widgets/subitems_controller_spec.rbnew file mode 100644index 00000000000..7297941a555--- /dev/null+++ b/modules/overviews/spec/controllers/overviews/widgets/subitems_controller_spec.rb@@ -0,0 +1,50 @@+# 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.+#++++require "rails_helper"++RSpec.describe Overviews::Widgets::SubitemsController do+ shared_let(:project) { create(:project) }+ shared_let(:user) { create(:user, member_with_permissions: { project => %i[view_project] }) }+ current_user { user }++ describe "GET #show" do+ context "with project" do+ before do+ get :show, params: { project_id: project }+ end++ it "renders show template", :aggregate_failures do+ expect(response).to be_successful+ expect(response).to render_template "show"+ end+ end+ end+enddiff --git a/modules/overviews/spec/permissions/widgets/subitems_spec.rb b/modules/overviews/spec/permissions/widgets/subitems_spec.rbnew file mode 100644index 00000000000..dd78deaa65a--- /dev/null+++ b/modules/overviews/spec/permissions/widgets/subitems_spec.rb@@ -0,0 +1,38 @@+# 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.+#++++require "spec_helper"+require "support/permission_specs"++RSpec.describe Overviews::Widgets::SubitemsController, "permissions", type: :controller do # rubocop:disable RSpec/EmptyExampleGroup,RSpec/SpecFilePathFormat+ include PermissionSpecs++ check_permission_required_for("overviews/widgets/subitems#show", :view_project)+enddiff --git a/modules/overviews/spec/routing/widget_routing_spec.rb b/modules/overviews/spec/routing/widget_routing_spec.rbindex 15e6903499b..a4d861920c9 100644--- a/modules/overviews/spec/routing/widget_routing_spec.rb+++ b/modules/overviews/spec/routing/widget_routing_spec.rb@@ -120,4 +120,22 @@ RSpec.describe Overviews::WidgetController doendendend++ describe "subitems routing" do+ describe "GET #show" do+ it do+ expect(get("/projects/my-project/widgets/subitems"))+ .to route_to(controller: "overviews/widgets/subitems", action: "show", project_id: "my-project")+ end+ end+ end++ describe "subitems named routing" do+ describe "GET #show" do+ it do+ expect(get(project_widgets_subitems_path("my-project")))+ .to route_to(controller: "overviews/widgets/subitems", action: "show", project_id: "my-project")+ end+ end+ endend