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
Remove requiring changes to the OpenProject core
Oliver Güntherc6b753af7443
diff --git a/README.md b/README.mdindex 070607b843f..8e57baa813a 100644--- a/README.md+++ b/README.md@@ -175,49 +175,6 @@ group :opf_plugins doend```-## Changes required in the OpenProject code--Right now, as the plugin for Github works, it is required to add some lines of code in the core of the OpenProject code before the precompilation of the assets.--Please modify the following files:--#### 1) api-v3-work-package-paths.ts--Path of the file that needs to be modified:--```-frontend/src/app/core/apiv3/endpoints/work_packages/api-v3-work-package-paths.ts-```--Add the following just after the line defining the Github resource (after line 52):--```- // /api/v3/(?:projectPath)/work_packages/(:workPackageId)/gitlab_merge_requests- public readonly gitlab_merge_requests = this.subResource('gitlab_merge_requests');-```--This line of code is necessary so that when precompiling the plugin assets they do not generate an error.--#### 2) work-package.rd--Path of the file that needs to be modified:--```-app/models/work_package.rb-```--Add the following just after the line defining the Github table relation (after line 67):--```-has_and_belongs_to_many :gitlab_merge_requests-```--This line of code is necessary to display the content of the new Gitlab tab and not generate the error:--```-undefined method `gitlab_merge_requests' for #<WorkPackage:0x000056127ee75b30>-```-### The Gitlab Bot user in OpenProjectFirst you will need to create a user in OpenProject that will make the comments. The user will have to be added to each project with a role that allows them to comment on work packages and change status.diff --git a/frontend/module/merge-request/merge-request.component.ts b/frontend/module/merge-request/merge-request.component.tsindex a787b9244e6..5a341ac9908 100644--- a/frontend/module/merge-request/merge-request.component.ts+++ b/frontend/module/merge-request/merge-request.component.ts@@ -29,9 +29,9 @@import { Component, Input } from '@angular/core';import { GitlabPipelineResource } from '../hal/resources/gitlab-pipelines-resource';-import { IGitlabMergeRequestResource } from "../../../../../../../../modules/gitlab_integration/frontend/module/typings";-import { PathHelperService } from "core-app/core/path-helper/path-helper.service";-import { I18nService } from "core-app/core/i18n/i18n.service";+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import {IGitlabMergeRequestResource} from 'core-app/features/plugins/linked/openproject-gitlab_integration/typings';@Component({selector: 'gitlab-merge-request',diff --git a/frontend/module/tab-mrs/tab-mrs.component.ts b/frontend/module/tab-mrs/tab-mrs.component.tsindex 85b6cb8b844..4700980decc 100644--- a/frontend/module/tab-mrs/tab-mrs.component.ts+++ b/frontend/module/tab-mrs/tab-mrs.component.ts@@ -29,11 +29,11 @@import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';import { WorkPackageResource } from "core-app/features/hal/resources/work-package-resource";-import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';import { HalResourceService } from "core-app/features/hal/services/hal-resource.service";import { CollectionResource } from "core-app/features/hal/resources/collection-resource";-import { IGitlabMergeRequestResource } from "../../../../../../../../modules/gitlab_integration/frontend/module/typings";import { I18nService } from "core-app/core/i18n/i18n.service";+import {IGitlabMergeRequestResource} from "core-app/features/plugins/linked/openproject-gitlab_integration/typings";+import {ApiV3Service} from "core-app/core/apiv3/api-v3.service";@Component({selector: 'tab-mrs',@@ -47,13 +47,14 @@ export class TabMrsComponent implements OnInit {constructor(readonly I18n:I18nService,- readonly apiV3Service:APIV3Service,+ readonly apiV3Service:ApiV3Service,readonly halResourceService:HalResourceService,readonly changeDetector:ChangeDetectorRef,) {}ngOnInit(): void {- const mergeRequestsPath = this.apiV3Service.work_packages.id({id: this.workPackage.id })?.gitlab_merge_requests.path;+ const basePath = this.apiV3Service.work_packages.id(this.workPackage.id as string).path;+ const mergeRequestsPath = `${basePath}/gitlab_merge_requests`;this.halResourceService.get<CollectionResource<IGitlabMergeRequestResource>>(mergeRequestsPath)diff --git a/lib/open_project/gitlab_integration/engine.rb b/lib/open_project/gitlab_integration/engine.rbindex a3c16c6f699..23010a02d1f 100644--- a/lib/open_project/gitlab_integration/engine.rb+++ b/lib/open_project/gitlab_integration/engine.rb@@ -44,6 +44,7 @@ module OpenProject::GitlabIntegration:author_url => 'https://github.com/btey/openproject',bundled: true+ patches %w[WorkPackage]initializer 'gitlab.register_hook' do::OpenProject::Webhooks.register_hook 'gitlab' do |hook, environment, params, user|diff --git a/lib/open_project/gitlab_integration/patches/work_package_patch.rb b/lib/open_project/gitlab_integration/patches/work_package_patch.rbnew file mode 100644index 00000000000..eabf7ea5d07--- /dev/null+++ b/lib/open_project/gitlab_integration/patches/work_package_patch.rb@@ -0,0 +1,13 @@+module OpenProject::GitlabIntegration+ module Patches+ module WorkPackagePatch+ extend ActiveSupport::Concern++ included do+ has_and_belongs_to_many :gitlab_merge_requests+ end+ end+ end+end++::WorkPackage.include OpenProject::GitlabIntegration::Patches::WorkPackagePatch