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

Bug/37571 not possible to create or edit projects if relative url root configured (#9384)

ulfertsd38570a41df7
diff --git a/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-form.ts b/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-form.ts
new file mode 100644
index 00000000000..84df3a1a9eb
--- /dev/null
+++ b/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-form.ts
@@ -0,0 +1,5 @@
+import { APIv3FormResource } from "core-app/modules/apiv3/forms/apiv3-form-resource";
+
+export class APIv3UsersForm extends APIv3FormResource {
+}
+
diff --git a/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-paths.ts b/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-paths.ts
index 199ce430fe4..cc8e02cb0f7 100644
--- a/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-paths.ts
+++ b/frontend/src/app/modules/apiv3/endpoints/users/apiv3-users-paths.ts
@@ -31,6 +31,7 @@ import { APIv3UserPaths } from "core-app/modules/apiv3/endpoints/users/apiv3-use
import { Observable } from "rxjs";
import { UserResource } from "core-app/modules/hal/resources/user-resource";
import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
+import { APIv3UsersForm } from "core-app/modules/apiv3/endpoints/users/apiv3-users-form";
export class Apiv3UsersPaths extends APIv3ResourceCollection<UserResource, APIv3UserPaths> {
constructor(protected apiRoot:APIV3Service,
@@ -43,6 +44,9 @@ export class Apiv3UsersPaths extends APIv3ResourceCollection<UserResource, APIv3
// /api/v3/users/me
public readonly me = this.path + '/me';
+ // /api/v3/users/form
+ public readonly form:APIv3UsersForm = this.subResource('form', APIv3UsersForm);
+
/**
* Create a new UserResource
*
diff --git a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
index cad72d64470..95155ebb2e5 100644
--- a/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
+++ b/frontend/src/app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
@@ -295,7 +295,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
}
if (resourcePath) {
- return `${this._pathHelperService.api.v3.apiV3Base}${resourcePath}`;
+ return resourcePath;
}
return;
@@ -349,7 +349,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
submit_message = `${title || ''} ${this.text.job_started}`;
} else {
- submit_message = this.resourceId ? this.text.successful_update : this.text.successful_create;
+ submit_message = this.formHttpMethod === 'patch' ? this.text.successful_update : this.text.successful_create;
}
this._notificationsService.addSuccess(submit_message);
diff --git a/frontend/src/app/modules/current-user/current-user.service.ts b/frontend/src/app/modules/current-user/current-user.service.ts
index d38189ab1e1..12f89fe9c14 100644
--- a/frontend/src/app/modules/current-user/current-user.service.ts
+++ b/frontend/src/app/modules/current-user/current-user.service.ts
@@ -153,7 +153,7 @@ export class CurrentUserService {
return this.capabilitiesForContext$(contextId).pipe(
map((capabilities) => actions.reduce(
(acc, action) => {
- return acc && !!capabilities.find(cap => cap.action.href === `/api/v3/actions/${action}`);
+ return acc && !!capabilities.find(cap => cap.action.href.endsWith(`/api/v3/actions/${action}`));
},
capabilities.length > 0,
)),
@@ -168,7 +168,7 @@ export class CurrentUserService {
const actionsToFilter = _.castArray(actions);
return this.capabilitiesForContext$(contextId).pipe(
map((capabilities) => capabilities.reduce(
- (acc, cap) => acc || !!actionsToFilter.find(action => cap.action.href === `/api/v3/actions/${action}`),
+ (acc, cap) => acc || !!actionsToFilter.find(action => cap.action.href.endsWith(`/api/v3/actions/${action}`)),
false,
)),
distinctUntilChanged(),
diff --git a/frontend/src/app/modules/invite-user-modal/principal/principal.component.html b/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
index 2bdc697dec8..7696aa4aade 100644
--- a/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
+++ b/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
@@ -53,7 +53,7 @@
*ngIf="isNewPrincipal && type === PrincipalType.User && userDynamicFieldConfig.schema"
[dynamicFormGroup]="dynamicFieldsControl"
[settings]="userDynamicFieldConfig"
- [resourcePath]="pathHelper.usersPath()"
+ [formUrl]="apiV3Service.users.form.path"
[handleSubmit]="false"
></op-dynamic-form>
</div>
diff --git a/frontend/src/app/modules/invite-user-modal/principal/principal.component.ts b/frontend/src/app/modules/invite-user-modal/principal/principal.component.ts
index 15dadd68ff0..e3eb4f9164f 100644
--- a/frontend/src/app/modules/invite-user-modal/principal/principal.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/principal/principal.component.ts
@@ -13,13 +13,15 @@ import {
FormControl,
Validators,
} from '@angular/forms';
-import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
import { HalResource } from "core-app/modules/hal/resources/hal-resource";
import { PrincipalData, PrincipalLike } from "core-app/modules/principal/principal-types";
import { ProjectResource } from "core-app/modules/hal/resources/project-resource";
import { DynamicFormComponent } from "core-app/modules/common/dynamic-forms/components/dynamic-form/dynamic-form.component"
import { PrincipalType } from '../invite-user.component';
+import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
+import { take } from 'rxjs/internal/operators/take';
+import { map } from 'rxjs/operators';
function extractCustomFieldsFromSchema(schema: IOPFormSettings['_embedded']['schema']) {
return Object.keys(schema)
@@ -128,7 +130,7 @@ export class PrincipalComponent implements OnInit {
constructor(
readonly I18n:I18nService,
readonly httpClient:HttpClient,
- readonly pathHelper:PathHelperService,
+ readonly apiV3Service:APIV3Service,
readonly cdRef: ChangeDetectorRef,
) {}
@@ -137,8 +139,17 @@ export class PrincipalComponent implements OnInit {
if (this.type === PrincipalType.User) {
const payload = this.isNewPrincipal ? this.principalData.customFields : {};
- this.httpClient
- .post<IOPFormSettings>('/api/v3/users/form', payload, { withCredentials: true, responseType: 'json' })
+ this
+ .apiV3Service
+ .users
+ .form
+ .post(payload)
+ .pipe(
+ take(1),
+ // The subsequent code expects to not work with a HalResource but rather with the raw
+ // api response.
+ map(formResource => formResource.$source)
+ )
.subscribe((formConfig) => {
this.userDynamicFieldConfig.schema = extractCustomFieldsFromSchema(formConfig._embedded?.schema);
this.userDynamicFieldConfig.payload = formConfig._embedded?.payload;
diff --git a/frontend/src/app/modules/projects/components/copy-project/copy-project.component.ts b/frontend/src/app/modules/projects/components/copy-project/copy-project.component.ts
index cd5e8e669b1..90195356aa3 100644
--- a/frontend/src/app/modules/projects/components/copy-project/copy-project.component.ts
+++ b/frontend/src/app/modules/projects/components/copy-project/copy-project.component.ts
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
-import {StateService, UIRouterGlobals} from "@uirouter/core";
+import {StateService} from "@uirouter/core";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {HalSource} from "core-app/modules/hal/resources/hal-resource";
@@ -12,6 +12,7 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {APIV3Service} from "core-app/modules/apiv3/api-v3.service";
import {JobStatusModal} from "core-app/modules/job-status/job-status-modal/job-status.modal";
import {OpModalService} from "core-app/modules/modal/modal.service";
+import { CurrentProjectService } from "core-components/projects/current-project.service";
@Component({
selector: 'op-copy-project',
@@ -35,7 +36,7 @@ export class CopyProjectComponent extends UntilDestroyedMixin implements OnInit
constructor(
private apiV3Service:APIV3Service,
- private uIRouterGlobals:UIRouterGlobals,
+ private currentProjectService:CurrentProjectService,
private pathHelperService:PathHelperService,
private modalService:OpModalService,
private $state:StateService,
@@ -45,7 +46,7 @@ export class CopyProjectComponent extends UntilDestroyedMixin implements OnInit
}
ngOnInit():void {
- this.formUrl = this.apiV3Service.projects.id(this.uIRouterGlobals.params.projectPath).copy.form.path;
+ this.formUrl = this.apiV3Service.projects.id(this.currentProjectService.id!).copy.form.path;
this.fieldGroups = [
{
name: this.text.advancedSettingsLabel,
diff --git a/frontend/src/app/modules/projects/components/new-project/new-project.component.ts b/frontend/src/app/modules/projects/components/new-project/new-project.component.ts
index 84d3238485d..6ba7f57c660 100644
--- a/frontend/src/app/modules/projects/components/new-project/new-project.component.ts
+++ b/frontend/src/app/modules/projects/components/new-project/new-project.component.ts
@@ -80,7 +80,7 @@ export class NewProjectComponent extends UntilDestroyedMixin implements OnInit {
}
ngOnInit():void {
- this.resourcePath = this.pathHelperService.projectsPath();
+ this.resourcePath = this.apiV3Service.projects.path;
this.fieldGroups = [{
name: this.text.advancedSettingsLabel,
fieldsFilter: (field) => !['name', 'parent'].includes(field.templateOptions?.property!) &&
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.html b/frontend/src/app/modules/projects/components/projects/projects.component.html
index 298deb5b645..6943dfd1dff 100644
--- a/frontend/src/app/modules/projects/components/projects/projects.component.html
+++ b/frontend/src/app/modules/projects/components/projects/projects.component.html
@@ -1,6 +1,6 @@
<op-dynamic-form
- [resourceId]="resourceId"
[resourcePath]="projectsPath"
+ [formHttpMethod]="formMethod"
[fieldsSettingsPipe]="dynamicFieldsSettingsPipe"
helpTextAttributeScope="Project"
></op-dynamic-form>
\ No newline at end of file
diff --git a/frontend/src/app/modules/projects/components/projects/projects.component.ts b/frontend/src/app/modules/projects/components/projects/projects.component.ts
index 7b96e1bd9de..392a7c4a294 100644
--- a/frontend/src/app/modules/projects/components/projects/projects.component.ts
+++ b/frontend/src/app/modules/projects/components/projects/projects.component.ts
@@ -1,9 +1,9 @@
import { Component, OnInit } from '@angular/core';
-import { StateService, UIRouterGlobals } from "@uirouter/core";
+import { StateService } from "@uirouter/core";
import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
-import { HalSource } from "core-app/modules/hal/resources/hal-resource";
import { IOPFormlyFieldSettings } from "core-app/modules/common/dynamic-forms/typings";
+import { CurrentProjectService } from "core-components/projects/current-project.service";
@Component({
selector: 'app-projects',
@@ -11,23 +11,22 @@ import { IOPFormlyFieldSettings } from "core-app/modules/common/dynamic-forms/ty
styleUrls: ['./projects.component.scss']
})
export class ProjectsComponent extends UntilDestroyedMixin implements OnInit {
- resourceId:string;
projectsPath:string;
+ formMethod = 'patch';
text:{ [key:string]:string };
dynamicFieldsSettingsPipe:(dynamicFieldsSettings:IOPFormlyFieldSettings[]) => IOPFormlyFieldSettings[];
hiddenFields = ['identifier', 'active'];
constructor(
- private _uIRouterGlobals:UIRouterGlobals,
private _pathHelperService:PathHelperService,
private _$state:StateService,
+ private _currentProjectService:CurrentProjectService,
) {
super();
}
ngOnInit():void {
- this.projectsPath = this._pathHelperService.projectsPath();
- this.resourceId = this._uIRouterGlobals.params.projectPath;
+ this.projectsPath = this._currentProjectService.apiv3Path!;
this.dynamicFieldsSettingsPipe = (dynamicFieldsSettings) => {
return dynamicFieldsSettings
.reduce((formattedDynamicFieldsSettings:IOPFormlyFieldSettings[], dynamicFormField) => {
@@ -43,13 +42,6 @@ export class ProjectsComponent extends UntilDestroyedMixin implements OnInit {
}
}
- onSubmitted(formResource:HalSource) {
- // TODO: Filter out if this.resourceId === 'new'?
- if (!this.resourceId) {
- this._$state.go('.', { ...this._$state.params, projectPath: formResource.identifier });
- }
- }
-
private isFieldHidden(name:string|undefined) {
return this.hiddenFields.includes(name || '');
}