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
replace beta news widget with news widget component (#20392)
Behrokh Satarnejad6144a00c553c
diff --git a/frontend/src/app/shared/components/grids/openproject-grids.module.ts b/frontend/src/app/shared/components/grids/openproject-grids.module.tsindex 2a17ff92cd0..170920750df 100644--- a/frontend/src/app/shared/components/grids/openproject-grids.module.ts+++ b/frontend/src/app/shared/components/grids/openproject-grids.module.ts@@ -43,7 +43,6 @@ import { GridComponent } from 'core-app/shared/components/grids/grid/grid.componimport { AddGridWidgetModalComponent } from 'core-app/shared/components/grids/widgets/add/add.modal';import { WidgetDocumentsComponent } from 'core-app/shared/components/grids/widgets/documents/documents.component';import { WidgetNewsComponent } from 'core-app/shared/components/grids/widgets/news/news.component';-import { WidgetNewsBetaComponent } from 'core-app/shared/components/grids/widgets/news-beta/news-beta.component';import { WidgetWpTableComponent } from 'core-app/shared/components/grids/widgets/wp-table/wp-table.component';import { WidgetMenuComponent } from 'core-app/shared/components/grids/widgets/menu/widget-menu.component';import { WidgetWpTableMenuComponent } from 'core-app/shared/components/grids/widgets/wp-table/wp-table-menu.component';@@ -121,7 +120,6 @@ import { OpenprojectEnterpriseModule } from 'core-app/features/enterprise/openprWidgetDocumentsComponent,WidgetMembersComponent,WidgetNewsComponent,- WidgetNewsBetaComponent,WidgetWpCalendarComponent,WidgetWpOverviewComponent,WidgetWpTableComponent,diff --git a/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.html b/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.htmldeleted file mode 100644index 6f3f1a56c93..00000000000--- a/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.html+++ /dev/null@@ -1,11 +0,0 @@-<widget-header- [name]="widgetName"- [editable]="isEditable">-- <widget-menu slot="menu"- [resource]="resource" />-</widget-header>--<div class="op-widget-box--body -allow-inner-overflow">- <turbo-frame [id]="frameId" [src]="src" />-</div>diff --git a/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.ts b/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.tsdeleted file mode 100644index 294ba9d5218..00000000000--- a/frontend/src/app/shared/components/grids/widgets/news-beta/news-beta.component.ts+++ /dev/null@@ -1,40 +0,0 @@-//-- 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.-//++--import { ChangeDetectionStrategy, Component } from '@angular/core';-import { AbstractTurboWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-turbo-widget.component';--@Component({- templateUrl: './news-beta.component.html',- changeDetection: ChangeDetectionStrategy.OnPush,- standalone: false,-})-export class WidgetNewsBetaComponent extends AbstractTurboWidgetComponent {- override frameId = 'overviews-widgets-news-component';- override name = 'news';-}diff --git a/frontend/src/app/shared/components/grids/widgets/news/news.component.html b/frontend/src/app/shared/components/grids/widgets/news/news.component.htmlindex 9537572b296..d82ef9f8717 100644--- a/frontend/src/app/shared/components/grids/widgets/news/news.component.html+++ b/frontend/src/app/shared/components/grids/widgets/news/news.component.html@@ -1,51 +1,11 @@<widget-header[name]="widgetName"- [editable]="isEditable"- >+ [editable]="isEditable"><widget-menu slot="menu"[resource]="resource" />-</widget-header>-<div class="op-widget-box--body">- @if (noEntries) {- <op-no-results [title]="text.noResults"- />- }- <ul class="widget-box--arrow-links">- @for (news of entries; track news) {- <li- class="widget-box--arrow-multiline"- >- @if (news.author) {- <op-principal [principal]="news.author"- [hideName]="true"- class="widget-box--avatar news-author-avatar hidden-for-mobile"- />- }- <div class="widget-box--project">- <a- [href]="newsProjectPath(news)"- [textContent]="newsProjectName(news)"- ></a>:- <a- [href]="newsPath(news)"- [textContent]="news.title"- ></a>- </div>- @if (news.author) {- <div- class="widget-box--author news-author"- [innerHTML]="text.addedBy(news)"- ></div>- }- @if (news.summary) {- <p- [textContent]="news.summary"- class="widget-box--additional-info"- ></p>- }- </li>- }- </ul>++<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/news/news.component.spec.ts b/frontend/src/app/shared/components/grids/widgets/news/news.component.spec.tsdeleted file mode 100644index ba6fd2161cd..00000000000--- a/frontend/src/app/shared/components/grids/widgets/news/news.component.spec.ts+++ /dev/null@@ -1,115 +0,0 @@-import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';-import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';-import { ConfigurationService } from 'core-app/core/config/configuration.service';-import { States } from 'core-app/core/states/states.service';-import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';-import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';-import { By } from '@angular/platform-browser';-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import { of } from 'rxjs';-import { TimezoneService } from 'core-app/core/datetime/timezone.service';-import { WidgetNewsComponent } from './news.component';--describe('shows news', () => {- let app:WidgetNewsComponent;- let fixture:ComponentFixture<WidgetNewsComponent>;- let element:DebugElement;-- const newsStub = {- id: 1,- title: 'Welcome to your demo project',- author: {- href: '/api/v3/users/1',- name: 'Foo Bar',- },- summary: 'We are glad you joined. In this module you can communicate project news to your team members.\n',- description: {- format: 'markdown',- raw: 'The actual news',- html: '<p>The actual news</p>',- },- createdAt: '2020-03-26T10:42:14Z',- updatedAt: '2020-03-26T10:42:14Z',- };-- const apiv3ServiceStub = {- news: {- list: (_params:any) => of({ elements: [newsStub] }),- },- };-- const configurationServiceStub = {- isTimezoneSet: () => false,- dateFormatPresent: () => false,- timeFormatPresent: () => false,- };- beforeEach(() => {- TestBed.configureTestingModule({- declarations: [- WidgetNewsComponent- ],- schemas: [NO_ERRORS_SCHEMA],- imports: [],- providers: [- TimezoneService,- { provide: ConfigurationService, useValue: configurationServiceStub },- States,- { provide: ApiV3Service, useValue: apiv3ServiceStub },- HalResourceService,- provideHttpClient(withInterceptorsFromDi()),- ]-}).compileComponents();-- fixture = TestBed.createComponent(WidgetNewsComponent);- app = fixture.debugElement.componentInstance;- element = fixture.debugElement;- });-- it('should load news from the server', fakeAsync(() => {- fixture.detectChanges();- tick();- expect(app.entries.length).toBe(1);- }));-- it('should render the component successfully to show the news', waitForAsync(() => {- fixture.detectChanges();- fixture.whenStable().then(() => {- const newsItem = document.querySelector('li');- expect(document.contains(newsItem)).toBeTruthy();- });- }));-- it('should Not add the no-results component into DOM', waitForAsync(() => {- fixture.detectChanges();- fixture.whenStable().then(() => {- const newsItem = document.querySelector('no-results');- expect(document.contains(newsItem)).not.toBeTruthy();- });- }));-- it('should add the widget-header component into DOM', waitForAsync(() => {- fixture.detectChanges();- fixture.whenStable().then(() => {- const newsItem = document.querySelector('widget-header');- expect(document.contains(newsItem)).toBeTruthy();- });- }));-- it('should show summary of news', waitForAsync(() => {- fixture.detectChanges();-- fixture.whenStable().then(() => {- const newsItem:HTMLElement = element.query(By.css('.widget-box--additional-info')).nativeElement;- expect(newsItem.innerText).toContain('We are glad you joined.');- });- }));-- it('should Not add the op-principal component into DOM', waitForAsync(() => {- fixture.detectChanges();-- fixture.whenStable().then(() => {- const newsItem = document.querySelector('op-principal');- expect(document.contains(newsItem)).toBeTruthy();- });- }));-});diff --git a/frontend/src/app/shared/components/grids/widgets/news/news.component.ts b/frontend/src/app/shared/components/grids/widgets/news/news.component.tsindex e9168b61493..d7935c2d8e8 100644--- a/frontend/src/app/shared/components/grids/widgets/news/news.component.ts+++ b/frontend/src/app/shared/components/grids/widgets/news/news.component.ts@@ -1,102 +1,40 @@-import { AbstractWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-widget.component';-import {- ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector, OnInit,-} from '@angular/core';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';-import { NewsResource } from 'core-app/features/hal/resources/news-resource';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-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 idFromLink from 'core-app/features/hal/helpers/id-from-link';+//-- 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.+//++++import { ChangeDetectionStrategy, Component } from '@angular/core';+import { AbstractTurboWidgetComponent } from 'core-app/shared/components/grids/widgets/abstract-turbo-widget.component';@Component({templateUrl: './news.component.html',changeDetection: ChangeDetectionStrategy.OnPush,standalone: false,})-export class WidgetNewsComponent extends AbstractWidgetComponent implements OnInit {- public text = {- at: this.i18n.t('js.grid.widgets.news.at'),- noResults: this.i18n.t('js.grid.widgets.news.no_results'),- addedBy: (news:NewsResource) => this.i18n.t('js.label_added_time_by',- { author: this.newsAuthorName(news), age: this.newsCreated(news), authorLink: this.newsAuthorPath(news) }),- };-- public entries:NewsResource[] = [];-- private entriesLoaded = false;-- constructor(-- readonly pathHelper:PathHelperService,- readonly i18n:I18nService,- protected readonly injector:Injector,- readonly timezone:TimezoneService,- readonly currentProject:CurrentProjectService,- readonly apiV3Service:ApiV3Service,- readonly cdr:ChangeDetectorRef,- ) {- super(i18n, injector);- }-- ngOnInit() {- this- .apiV3Service- .news- .list(this.newsDmParams)- .subscribe((collection) => this.setupNews(collection.elements));- }-- public setupNews(news:any[]) {- this.entries = news;- this.entriesLoaded = true;- this.cdr.detectChanges();- }-- public get isEditable() {- return false;- }-- public newsPath(news:NewsResource) {- return this.pathHelper.newsPath(news.id!);- }-- public newsProjectPath(news:NewsResource) {- return this.pathHelper.projectPath(idFromLink(news.project?.href));- }-- public newsProjectName(news:NewsResource) {- return news.project?.name;- }-- public newsAuthorName(news:NewsResource) {- return news.author?.name;- }-- public newsAuthorPath(news:NewsResource) {- return this.pathHelper.userPath(news.author?.id);- }-- public newsCreated(news:NewsResource) {- return this.timezone.formattedDatetime(news.createdAt);- }-- public get noEntries() {- return !this.entries.length && this.entriesLoaded;- }-- private get newsDmParams() {- const params:ApiV3ListParameters = {- sortBy: [['created_at', 'desc']],- pageSize: 3,- };-- if (this.currentProject.id) {- params.filters = [['project_id', '=', [this.currentProject.id]]];- }-- return params;- }+export class WidgetNewsComponent extends AbstractTurboWidgetComponent {+ override frameId = 'overviews-widgets-news-component';+ override name = 'news';}diff --git a/frontend/src/app/shared/components/grids/widgets/widgets.service.ts b/frontend/src/app/shared/components/grids/widgets/widgets.service.tsindex faa5272916f..ab2b465f402 100644--- a/frontend/src/app/shared/components/grids/widgets/widgets.service.ts+++ b/frontend/src/app/shared/components/grids/widgets/widgets.service.ts@@ -17,7 +17,6 @@ import {import { WidgetDocumentsComponent } from 'core-app/shared/components/grids/widgets/documents/documents.component';import { WidgetMembersComponent } from 'core-app/shared/components/grids/widgets/members/members.component';import { WidgetNewsComponent } from 'core-app/shared/components/grids/widgets/news/news.component';-import { WidgetNewsBetaComponent } from 'core-app/shared/components/grids/widgets/news-beta/news-beta.component';import {WidgetProjectDescriptionComponent,} from 'core-app/shared/components/grids/widgets/project-description/project-description.component';@@ -204,14 +203,6 @@ export class GridWidgetsService {name: this.I18n.t('js.grid.widgets.news.title'),},},- {- identifier: 'news_beta',- component: WidgetNewsBetaComponent,- title: this.I18n.t('js.grid.widgets.news_beta.title'),- properties: {- name: this.I18n.t('js.grid.widgets.news_beta.title'),- },- },{identifier: 'project_description',component: WidgetProjectDescriptionComponent,diff --git a/modules/grids/config/locales/js-en.yml b/modules/grids/config/locales/js-en.ymlindex 779caaaabc1..94699e78c1e 100644--- a/modules/grids/config/locales/js-en.yml+++ b/modules/grids/config/locales/js-en.yml@@ -21,8 +21,6 @@ en:title: 'News'at: 'at'no_results: 'Nothing new to report.'- news_beta:- title: 'News (BETA)'project_description:title: 'Project description'no_results: "No description has been written yet. One can be provided in the 'Project settings'."diff --git a/modules/grids/lib/grids/configuration/in_project_base_registration.rb b/modules/grids/lib/grids/configuration/in_project_base_registration.rbindex b4a1a631775..675d3abdcdb 100644--- a/modules/grids/lib/grids/configuration/in_project_base_registration.rb+++ b/modules/grids/lib/grids/configuration/in_project_base_registration.rb@@ -11,7 +11,6 @@ module Grids::Configuration"time_entries_list","members","news",- "news_beta","documents","custom_text"@@ -72,10 +71,6 @@ module Grids::Configurationallowed ->(user, project) { user.allowed_in_project?(:view_news, project) }end- widget_strategy "news_beta" do- allowed ->(user, project) { view_beta_widgets.(user, project) && user.allowed_in_project?(:view_news, project) }- end-widget_strategy "documents" doallowed ->(user, project) { user.allowed_in_project?(:view_documents, project) }enddiff --git a/modules/my_page/lib/my_page/grid_registration.rb b/modules/my_page/lib/my_page/grid_registration.rbindex dac5b0f735e..783fa6d6012 100644--- a/modules/my_page/lib/my_page/grid_registration.rb+++ b/modules/my_page/lib/my_page/grid_registration.rb@@ -13,8 +13,7 @@ module MyPage"work_packages_table","time_entries_current_user","project_favorites",- "news",- "news_beta"+ "news"wp_table_strategy_proc = Proc.new doafter_destroy -> { ::Query.find_by(id: options[:queryId])&.destroy }diff --git a/modules/overviews/app/components/overviews/overview_grid_component.html.erb b/modules/overviews/app/components/overviews/overview_grid_component.html.erbindex 9afccac1ecc..ec33d11af0a 100644--- a/modules/overviews/app/components/overviews/overview_grid_component.html.erb+++ b/modules/overviews/app/components/overviews/overview_grid_component.html.erb@@ -32,8 +32,6 @@ See COPYRIGHT and LICENSE files for more details.grid.with_widget(Overviews::Widgets::DescriptionComponent, @project)grid.with_widget(Overviews::Widgets::ProjectStatusComponent, @project)grid.with_widget(Overviews::Widgets::SubitemsComponent, @project)- if OpenProject::FeatureDecisions.beta_widgets_active?- grid.with_widget(Overviews::Widgets::NewsComponent, @project)- end+ grid.with_widget(Overviews::Widgets::NewsComponent, @project)end%>diff --git a/modules/overviews/db/migrate/20250923120330_remove_news_beta_widgets.rb b/modules/overviews/db/migrate/20250923120330_remove_news_beta_widgets.rbnew file mode 100644index 00000000000..6273bb38e02--- /dev/null+++ b/modules/overviews/db/migrate/20250923120330_remove_news_beta_widgets.rb@@ -0,0 +1,48 @@+# 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 RemoveNewsBetaWidgets < ActiveRecord::Migration[8.0]+ def up+ remove_news_beta_widgets+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end++ private++ def remove_news_beta_widgets+ execute <<-SQL.squish+ DELETE FROM grid_widgets+ WHERE identifier = 'news_beta'+ SQL+ end+end