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

Merge/release 11.3 (#9427)

Benjamin Bädorf0981c65582d7
diff --git a/app/helpers/sentry_helper.rb b/app/helpers/sentry_helper.rb
index 139df36d03c..7770699988d 100644
--- a/app/helpers/sentry_helper.rb
+++ b/app/helpers/sentry_helper.rb
@@ -14,7 +14,7 @@ module SentryHelper
data: {
dsn: OpenProject::Configuration.sentry_frontend_dsn,
version: OpenProject::VERSION.to_s,
- tracing_rate: OpenProject::Configuration.sentry_traces_sample_rate
+ tracing_factor: OpenProject::Configuration.sentry_frontend_trace_factor
}
end
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb
index bb4a4b8a837..3ddb84cee4c 100644
--- a/config/initializers/sentry.rb
+++ b/config/initializers/sentry.rb
@@ -37,10 +37,51 @@ if OpenProject::Logging::SentryLogger.enabled?
# Sample rate for performance
# 0.0 = disabled
# 1.0 = all samples are traced
- config.traces_sample_rate = OpenProject::Configuration.sentry_traces_sample_rate
- config.traces_sampler = lambda do |sampling_context|
- # ignore health checks transactions
- !["/health_checks"].include?(sampling_context[:transaction_context][:name])
+ sample_factor = OpenProject::Configuration.sentry_trace_factor.to_f
+
+ # Define a tracing sample handler
+ trace_sampler = lambda do |sampling_context|
+ # if this is the continuation of a trace, just use that decision (rate controlled by the caller)
+ next sampling_context[:parent_sampled] unless sampling_context[:parent_sampled].nil?
+
+ # transaction_context is the transaction object in hash form
+ # keep in mind that sampling happens right after the transaction is initialized
+ # for example, at the beginning of the request
+ transaction_context = sampling_context[:transaction_context]
+
+ # transaction_context helps you sample transactions with more sophistication
+ # for example, you can provide different sample rates based on the operation or name
+ op = transaction_context[:op]
+ transaction_name = transaction_context[:name]
+
+ rate = case op
+ when /request/
+ case transaction_name
+ when /health_check/
+ 0.0
+ else
+ [0.1 * sample_factor, 1.0].min
+ end
+ when /delayed_job/
+ [0.01 * sample_factor, 1.0].min
+ else
+ 0.0 # ignore all other transactions
+ end
+
+ Rails.logger.debug { "[SENTRY TRACE SAMPLER] Decided on sampling rate #{rate} for #{op}: #{transaction_name} " }
+
+ rate
+ end
+
+ # Assign the sampler conditionally to avoid running the lambda
+ # when we don't trace anyway
+ if sample_factor.zero?
+ Rails.logger.debug { "[SENTRY TRACE SAMPLER] Requested factor is zero, skipping performance tracing" }
+ config.traces_sample_rate = 0
+ config.traces_sampler = nil
+ else
+ Rails.logger.debug { "[SENTRY TRACE SAMPLER] Requested factor is #{sample_factor}, setting up performance tracing" }
+ config.traces_sampler = trace_sampler
end
# Set release info
diff --git a/config/locales/crowdin/js-de.yml b/config/locales/crowdin/js-de.yml
index 05e2486c6c2..a3ca0076703 100644
--- a/config/locales/crowdin/js-de.yml
+++ b/config/locales/crowdin/js-de.yml
@@ -486,21 +486,21 @@ de:
welcome: 'Lernen Sie in drei Minuten die <b>wichtigen Funktionen</b> kennen. <br> Wir empfehlen Ihnen die Tour bis zum Ende zu machen. Sie können diese jeder Zeit wieder neu starten.'
wiki: 'Im <b>Wiki</b> können Sie gemeinsam mit dem Team Informationen dokumentieren und eine Wissensdatenbank aufbauen.'
backlogs:
- overview: "Sie können Anforderungen in der <b>Backlogs Ansicht</b> verwalten. <br> Rechts befindet sich das Product Backlog oder Bug Backlog, links die jeweiligen Sprints. Hier können Sie <b>Epics, User Stories und Fehler</b> anlegen und mit Drag & Drop priorisieren und einem Sprint zuweisen."
+ overview: "Sie können Anforderungen in der <b>Backlogs Ansicht</b> verwalten. <br> Rechts befindet sich das Product Backlog oder Bug Backlog, links die jeweiligen Sprints. Hier können Sie <b>Epics, User Stories und Bugs (Fehler)</b> anlegen und mit Drag and Drop priorisieren und einem Sprint zuweisen."
task_board_arrow: 'Um das <b>Taskboard</b> zu sehen, öffnen Sie das Sprint Drop-down Menü...'
task_board_select: '… und wählen Sie den Menüpunkt <b>Taskboard</b>.'
- task_board: "Im <b>Taskboard</b> sehen Sie die Aufgaben eines Sprints. Sie können neue Aufgaben oder Sprint-Hindernisse mit dem + Icon einer User Story hinzufügen, einer Person zuweisen und mit Drag & Drop aktualisieren."
+ task_board: "Im <b>Taskboard</b> sehen Sie die Aufgaben eines Sprints. Sie können neue Aufgaben oder Sprint-Hindernisse mit dem Plus (+) Knopf einer User Story hinzufügen, einer Person zuweisen und mit Drag and Drop aktualisieren."
boards:
- overview: 'Verwalten Sie Ihre Arbeit in einer intuitiven <b>Boards</b> -Ansicht.'
- lists: 'Sie können mehrere Listen (Spalten) innerhalb einer Board-Ansicht erstellen, z.B. um ein KANBAN-Board zu erstellen.'
- add: 'Klicken Sie + um <b>eine neue Karte</b> zur Liste eines Boards hinzuzufügen.'
+ overview: 'Wählen Sie links im Menü <b>Boards</b> aus, um Ihre Arbeit in einer agilen Board-Ansicht zu verwalten.'
+ lists: 'Sie können mehrere Listen (Spalten) innerhalb einer Board-Ansicht erstellen, z.B. um ein Kanban-Board zu erstellen.'
+ add: 'Mit dem Plus (+) Knopf, können sie entweder eine <b>neue Karte</b> oder eine schon <b>existierende Karte</b> zu Ihrem Board hinzuzufügen. '
drag: 'Ziehen Sie Ihre Karten in eine Liste, um diese zu sortieren oder weisen Sie diese einer anderen Liste zu. Ein Doppelklick auf eine Karte öffnet die Detailansicht.'
wp:
toggler: "Hier sind die <b>Arbeitspakete</b>, die Ihnen eine detailliertere Sicht auf die Arbeit in Ihrem Projekt geben."
list: 'Dies ist die Liste der wichtigen <b>Arbeitspakete</b> in Ihrem Projekt, z.B. Aufgaben, Funktionen, Meilensteine, Fehler, und Vieles mehr. <br> Sie können neue Arbeitspakete direkt in der Liste anlegen und bearbeiten. Ein Doppelklick auf eine Zeile öffnet die Detailansicht.'
full_view: 'In der <b>Arbeitspaket-Detailansicht</b> finden Sie alle wichtigen Informationen, wie Beschreibung, Status und Priorität, Aktivitäten, Abhängigkeiten oder Kommentare.'
back_button: 'Mit dem Pfeil kommen Sie zurück in die Listenansicht.'
- create_button: 'Mit <b>Anlegen</b> Können Sie neue Arbeitspakete Ihrem Projekt hinzufügen.'
+ create_button: 'Mit dem <b>+ Anlegen</b> Knopf erstellen Sie weitere Arbeitspakete für Ihr Projekt.'
timeline_button: 'Sie können ein <b>Gantt Diagramm</b> aktivieren um Projektpläne zu erstellen.'
timeline: 'Hier sehen Sie den Projektplan. Sie können neue Phasen oder Meilensteine sowie Abhängigkeiten hinzufügen und bearbeiten. Das Team sieht jeder Zeit die aktuelle Planung und kann diese bei Bedarf aktualisieren.'
notifications:
diff --git a/docs/user-guide/agile-boards/README.md b/docs/user-guide/agile-boards/README.md
index 6afe7f4db4e..23b9335ac69 100644
--- a/docs/user-guide/agile-boards/README.md
+++ b/docs/user-guide/agile-boards/README.md
@@ -51,10 +51,10 @@ Click on the green **+Board** button to create a new Board view.
Next, you need to choose which kind of Agile board you want to create.
-#### Basic board
+### Basic board
You can freely create lists, name them and order your work packages within. If you move work packages between the lists, there will be **NO changes** to the work package itself. This allows you to create flexible boards for any kind of activity you would like to track, e.g. Management of Ideas.
-#### Action boards
+### Action boards
In an Action board each lists represents a value of an attribute of the contained work packages (cards), e.g. there's a list for the status "New" and a list for the status "In Progress" in the Status board.
Moving work packages (cards) between two lists will update them automatically, based on the list to which they're moved.
@@ -62,17 +62,22 @@ After [adding lists to your board](#add-lists-to-your-board) they will automatic
There are several **types of Action boards** available:
-#### Status board: Each list represents a status. That means that e.g. all work packages with the status "New" will be automatically displayed in the column "New".
+### Status board:
+Each list represents a status. That means that e.g. all work packages with the status "New" will be automatically displayed in the column "New".
When creating a new Status board a list with all work packages in the default status (usually this is the status "New") will be added automatically, while additional lists need to be added manually.
Please note: You can't move work packages from or to every status. Please find out more about the work-flow logics restricting this here: [Allowed transitions between status](../../system-admin-guide/manage-work-packages/work-package-workflows/)
-#### Assignee board: Every list represents one assignee. You can choose regular users, [placeholder users](../../system-admin-guide/users-permissions/placeholder-users) and groups as assignees.
+### Assignee board:
+Every list represents one assignee. You can choose regular users, [placeholder users](../../system-admin-guide/users-permissions/placeholder-users) and groups as assignees.
-#### Version board: Every list represents a version. This board is ideal for product development or planning software releases. When creating a new Version board a list with all work packages in the version(s) belonging to the current project will be added automatically, while additional lists need to be added manually.
+### Version board:
+Every list represents a version. This board is ideal for product development or planning software releases. When creating a new Version board a list with all work packages in the version(s) belonging to the current project will be added automatically, while additional lists need to be added manually.
-#### Subproject board: Every list represents a subproject. Within the list you will find the subproject's work packages.
+### Subproject board:
+Every list represents a subproject. Within the list you will find the subproject's work packages.
-#### Parent-Child board: Every list represents a parent work package. Within the list you will find the work package's children.
+### Parent-Child board:
+Every list represents a parent work package. Within the list you will find the work package's children.
Only work packages from the current project can be selected as a list, i.e. can be chosen as the name of the list.
The Parent-Child board is ideal for depicting a **work breakdown structure (WBS)**.
Please note: This will only display one hierarchy level below the displayed work package, i.e. only immediate children and no grandchildren.
diff --git a/frontend/src/app/core/errors/sentry/sentry-reporter.ts b/frontend/src/app/core/errors/sentry/sentry-reporter.ts
index 92a0036d4c2..9167ff3baaf 100644
--- a/frontend/src/app/core/errors/sentry/sentry-reporter.ts
+++ b/frontend/src/app/core/errors/sentry/sentry-reporter.ts
@@ -79,7 +79,7 @@ export class SentryReporter implements ErrorReporter {
private loadSentry(sentryElement:HTMLElement) {
const dsn = sentryElement.dataset.dsn || '';
const version = sentryElement.dataset.version || 'unknown';
- const traceRate = parseFloat(sentryElement.dataset.tracesSampleRate || '0.1');
+ const traceFactor = parseFloat(sentryElement.dataset.tracingFactor || '0.0');
import('./sentry-dependency').then((imported) => {
const sentry = imported.Sentry;
@@ -92,8 +92,17 @@ export class SentryReporter implements ErrorReporter {
// Integrations
integrations: [new imported.Integrations.BrowserTracing()],
- // Tracing rate for performance
- tracesSampleRate: traceRate,
+ tracesSampler: (samplingContext) => {
+ switch (samplingContext.transactionContext.op) {
+ case 'op':
+ case 'navigation':
+ // Trace 1% of page loads and navigation events
+ return Math.min(0.01 * traceFactor, 1.0);
+ default:
+ // Trace 0.1% of requests
+ return Math.min(0.001 * traceFactor, 1.0);
+ }
+ },
ignoreErrors: [
// Transition movements,
diff --git a/frontend/src/app/core/forms/forms.service.ts b/frontend/src/app/core/forms/forms.service.ts
index 3cd79bcfc21..2d39053feec 100644
--- a/frontend/src/app/core/forms/forms.service.ts
+++ b/frontend/src/app/core/forms/forms.service.ts
@@ -13,8 +13,8 @@ export class FormsService {
private _httpClient:HttpClient,
) { }
- submit$(form:FormGroup, resourceEndpoint:string, resourceId?:string, formHttpMethod?: 'post' | 'patch'):Observable<any> {
- const modelToSubmit = this.formatModelToSubmit(form.getRawValue());
+ submit$(form:FormGroup, resourceEndpoint:string, resourceId?:string, formHttpMethod?: 'post' | 'patch', formSchema?:IOPFormSchema):Observable<any> {
+ const modelToSubmit = this.formatModelToSubmit(form.getRawValue(), formSchema);
const httpMethod = resourceId ? 'patch' : (formHttpMethod || 'post');
const url = resourceId ? `${resourceEndpoint}/${resourceId}` : resourceEndpoint;
@@ -38,8 +38,8 @@ export class FormsService {
);
}
- validateForm$(form:FormGroup, resourceEndpoint:string):Observable<any> {
- const modelToSubmit = this.formatModelToSubmit(form.value);
+ validateForm$(form:FormGroup, resourceEndpoint:string, formSchema?:IOPFormSchema):Observable<any> {
+ const modelToSubmit = this.formatModelToSubmit(form.value, formSchema);
return this._httpClient
.post(
@@ -56,8 +56,8 @@ export class FormsService {
);
}
- getFormBackendValidationError$(formValue: {[key:string]: any}, resourceEndpoint:string, limitValidationToKeys?:string | string[]) {
- const modelToSubmit = this.formatModelToSubmit(formValue);
+ getFormBackendValidationError$(formValue: {[key:string]: any}, resourceEndpoint:string, limitValidationToKeys?:string | string[], formSchema?:IOPFormSchema) {
+ const modelToSubmit = this.formatModelToSubmit(formValue, formSchema);
return this._httpClient
.post(
@@ -76,31 +76,67 @@ export class FormsService {
);
}
- private formatModelToSubmit(formModel:IOPFormModel):IOPFormModel {
- const resources = formModel?._links || {};
+ /** HAL resources formatting
+ * The backend form model/payload contains HAL resources nested in the '_links' property.
+ * In order to simplify its use, the model is flatted and HAL resources are placed at
+ * the first level of the model with the 'formatModelToEdit' method.
+ * 'formatModelToSubmit' places HAL resources model back to the '_links' property and formats them
+ * in the shape of '{href:hrefValue}' in order to fit the backend expectations.
+ * */
+ private formatModelToSubmit(formModel:IOPFormModel, formSchema:IOPFormSchema = {}):IOPFormModel {
+ let {_links:linksModel, ...mainModel} = formModel;
+ const resourcesModel = linksModel || Object.keys(formSchema)
+ .filter(formSchemaKey => !!formSchema[formSchemaKey]?.type && formSchema[formSchemaKey]?.location === '_links')
+ .reduce((result, formSchemaKey) => {
+ const {[formSchemaKey]:keyToRemove, ...mainModelWithoutResource} = mainModel;
+ mainModel = mainModelWithoutResource;
+
+ return {...result, [formSchemaKey]: formModel[formSchemaKey]};
+ }, {});
- const formattedResources = Object
- .keys(resources)
+ const formattedResourcesModel = Object
+ .keys(resourcesModel)
.reduce((result, resourceKey) => {
- const resource = resources[resourceKey];
+ const resourceModel = resourcesModel[resourceKey];
// Form.payload resources have a HalLinkSource interface while
// API resource options have a IAllowedValue interface
- const resourceValue = Array.isArray(resource) ?
- resource.map(resourceElement => ({ href: resourceElement?.href || resourceElement?._links?.self?.href })) :
- { href: resource?.href || resource?._links?.self?.href };
+ const formattedResourceModel = Array.isArray(resourceModel) ?
+ resourceModel.map(resourceElement => ({ href: resourceElement?.href || resourceElement?._links?.self?.href || null })) :
+ { href: resourceModel?.href || resourceModel?._links?.self?.href || null };
return {
...result,
- [resourceKey]: resourceValue,
+ [resourceKey]: formattedResourceModel,
};
}, {});
return {
- ...formModel,
- _links: formattedResources,
+ ...mainModel,
+ _links: formattedResourcesModel,
}
}
+ /** HAL resources formatting
+ * The backend form model/payload contains HAL resources nested in the '_links' property.
+ * In order to simplify its use, the model is flatted and HAL resources are placed at
+ * the first level of the model. 'NonValue' values are also removed from the model so
+ * default values from the DynamicForm are set.
+ */
+ formatModelToEdit(formModel:IOPFormModel = {}):IOPFormModel {
+ const { _links: resourcesModel, _meta: metaModel, ...otherElements } = formModel;
+ const otherElementsModel = Object.keys(otherElements)
+ .filter(key => this.isValue(otherElements[key]))
+ .reduce((model, key) => ({...model, [key]:otherElements[key]}), {});
+
+ const model = {
+ ...otherElementsModel,
+ _meta: metaModel,
+ ...this.getFormattedResourcesModel(resourcesModel),
+ };
+
+ return model;
+ }
+
private handleBackendFormValidationErrors(error:HttpErrorResponse, form:FormGroup):void {
const errors:IOPFormError[] = error?.error?._embedded?.errors ?
error?.error?._embedded?.errors : [error.error];
@@ -146,4 +182,26 @@ export class FormsService {
return formattedErrors;
}
+
+ private getFormattedResourcesModel(resourcesModel:IOPFormModel['_links'] = {}):IOPFormModel['_links'] {
+ return Object.keys(resourcesModel).reduce((result, resourceKey) => {
+ const resource = resourcesModel[resourceKey];
+ // ng-select needs a 'name' in order to show the label
+ // We need to add it in case of the form payload (HalLinkSource)
+ const resourceModel = Array.isArray(resource) ?
+ resource.map(resourceElement => ({...resourceElement, name: resourceElement?.name || resourceElement?.title})) :
+ {...resource, name: resource?.name || resource?.title};
+
+ result = {
+ ...result,
+ ...this.isValue(resourceModel) && {[resourceKey]: resourceModel},
+ };
+
+ return result;
+ }, {});
+ }
+
+ private isValue(value:any) {
+ return ![null, undefined, ''].includes(value);
+ }
}
diff --git a/frontend/src/app/features/invite-user-modal/principal/principal.component.ts b/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
index b9a89362ebf..d0e4d351bd3 100644
--- a/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
+++ b/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
@@ -174,16 +174,25 @@ export class PrincipalComponent implements OnInit {
// The code below transforms the model value as it comes from the dynamic form to the value accepted by the API.
// This is not just necessary for submit, but also so that we can reseed the initial values to the payload
// when going back to this step after having completed it once.
- const links = this.customFields!._links || {};
- const customFields = {
- ...this.customFields!,
- _links: Object.keys(links).reduce((cfs, name) => ({
- ...cfs,
- [name]: Array.isArray(links[name])
- ? links[name].map((opt:any) => opt._links ? opt._links.self : opt)
- : (links[name]._links ? links[name]._links.self : links[name])
- }), {}),
- };
+ const fieldsSchema = this.userDynamicFieldConfig.schema || {};
+ const customFields = Object.keys(fieldsSchema)
+ .reduce((result, fieldKey) => {
+ let fieldSchema = fieldsSchema[fieldKey];
+ let fieldValue = this.customFields[fieldKey];
+
+ if (fieldSchema.location === '_links') {
+ fieldValue = Array.isArray(fieldValue)
+ ? fieldValue.map((opt: any) => opt._links ? opt._links.self : opt)
+ : (fieldValue._links ? fieldValue._links.self : fieldValue)
+ }
+
+ result = {
+ ...result,
+ [fieldKey]: fieldValue,
+ };
+
+ return result;
+ }, {});
this.save.emit({
principalData: {
diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
index 38cc27d35df..85587e2f8e3 100644
--- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-form/dynamic-form.component.ts
@@ -19,7 +19,6 @@ import { NotificationsService } from "core-app/shared/components/notifications/n
import { DynamicFieldsService } from "core-app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service";
import { FormGroup } from "@angular/forms";
import { HttpErrorResponse } from "@angular/common/http";
-import { FormsService } from "core-app/core/forms/forms.service";
import { UntilDestroyedMixin } from "core-app/shared/helpers/angular/until-destroyed.mixin";
/**
@@ -143,7 +142,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
@Input() set model(payload:IOPFormModel) {
if (!this.innerModel && !payload) { return; }
- const formattedModel = this._dynamicFieldsService.getFormattedFieldsModel(payload);
+ const formattedModel = this._dynamicFormService.formatModelToEdit(payload);
this.form.patchValue(formattedModel);
}
@@ -192,7 +191,6 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
private _I18n:I18nService,
private _pathHelperService:PathHelperService,
private _notificationsService:NotificationsService,
- private _formsService:FormsService,
private _changeDetectorRef:ChangeDetectorRef,
) {
super();
@@ -260,7 +258,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
throw new Error(this.noPathToSubmitToError);
}
- return this._formsService.validateForm$(this.form, this.formEndpoint);
+ return this._dynamicFormService.validateForm$(this.form, this.formEndpoint);
}
private initializeDynamicForm(
@@ -281,7 +279,7 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
}
if (settings) {
- this.setupDynamicFormFromSettings();
+ this.setupDynamicFormFromSettings(settings);
} else {
this.setupDynamicFormFromBackend(this.formEndpoint, resourceId, payload);
}
@@ -313,11 +311,11 @@ export class DynamicFormComponent extends UntilDestroyedMixin implements OnChang
.subscribe(dynamicFormSettings => this.setupDynamicForm(dynamicFormSettings));
}
- private setupDynamicFormFromSettings() {
+ private setupDynamicFormFromSettings(settings:IOPFormSettings) {
const formattedSettings:IOPFormSettingsResource = {
_embedded: {
- payload: this.settings!.payload,
- schema: this.settings!.schema,
+ payload: settings?.payload,
+ schema: settings?.schema,
},
};
const dynamicFormSettings = this._dynamicFormService.getSettings(formattedSettings);
diff --git a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
index 2d409e8064c..f5ee76613d6 100644
--- a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.spec.ts
@@ -78,7 +78,7 @@ describe('DynamicFieldsService', () => {
expect(fieldsSchemas.length).toBe(2, 'should return only writable field schemas');
expect(fieldsSchemas[0].key).toBe('name', 'should place the correct key on primitives');
- expect(fieldsSchemas[1].key).toBe('_links.parent', 'should place the correct key on resources');
+ expect(fieldsSchemas[1].key).toBe('parent', 'should place the correct key on resources');
});
it('should format the form model (add the name property to resources (_links: single and multiple))', () => {
@@ -143,8 +143,8 @@ describe('DynamicFieldsService', () => {
// @ts-ignore
const formModel = service.getModel(formPayload);
const titleName = formModel.title;
- const parentProjectName = !Array.isArray(formModel._links!.parent) && formModel._links!.parent!.name;
- const childrenProjectsNames = Array.isArray(formModel._links!.children) && formModel._links!.children!.map((childProject: IOPFieldModel) => childProject.name);
+ const parentProjectName = !Array.isArray(formModel!.parent) && formModel!.parent!.name;
+ const childrenProjectsNames = Array.isArray(formModel!.children) && formModel!.children!.map((childProject: IOPFieldModel) => childProject.name);
expect(titleName).toBe('Project 1', 'should add the payload value on primitives');
expect(parentProjectName).toEqual('Parent project', 'should add a name property on resources');
diff --git a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
index f4848f8ee08..469228ed288 100644
--- a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
@@ -10,7 +10,7 @@ import { map } from "rxjs/operators";
import { HttpClient } from "@angular/common/http";
import { HalLink } from "core-app/features/hal/hal-link/hal-link";
import { I18nService } from "core-app/core/i18n/i18n.service";
-
+import { FormsService } from "core-app/core/forms/forms.service";
@Injectable()
export class DynamicFieldsService {
@@ -117,6 +117,7 @@ export class DynamicFieldsService {
constructor(
private httpClient:HttpClient,
private I18n:I18nService,
+ private formsService:FormsService,
) {
}
@@ -135,28 +136,7 @@ export class DynamicFieldsService {
}
getModel(formPayload:IOPFormModel):IOPFormModel {
- return this.getFormattedFieldsModel(formPayload);
- }
-
- getFormattedFieldsModel(formModel:IOPFormModel = {}):IOPFormModel {
- const { _links: resourcesModel, _meta: metaModel, ...otherElements } = formModel;
- const otherElementsModel = Object.keys(otherElements).reduce((model, key) => {
- const elementValue = otherElements[key];
-
- if (this.isValue(elementValue)) {
- model = { ...model, [key]: elementValue }
- }
-
- return model;
- }, {})
-
- const model = {
- ...otherElementsModel,
- _meta: metaModel,
- _links: this.getFormattedResourcesModel(resourcesModel),
- };
-
- return model;
+ return this.formsService.formatModelToEdit(formPayload);
}
getFormlyFormWithFieldGroups(fieldGroups:IDynamicFieldGroupConfig[] = [], formFields:IOPFormlyFieldSettings[] = []):IOPFormlyFieldSettings[] {
@@ -185,7 +165,6 @@ export class DynamicFieldsService {
private getAttributeKey(fieldSchema:IOPFieldSchema, key:string):string {
switch (fieldSchema.location) {
- case "_links":
case "_meta":
return `${fieldSchema.location}.${key}`;
default:
@@ -197,27 +176,6 @@ export class DynamicFieldsService {
return !!schemaValue?.type;
}
- private getFormattedResourcesModel(resourcesModel:IOPFormModel['_links'] = {}):IOPFormModel['_links'] {
- return Object.keys(resourcesModel).reduce((result, resourceKey) => {
- const resource = resourcesModel[resourceKey];
- // ng-select needs a 'name' in order to show the label
- // We need to add it in case of the form payload (HalLinkSource)
- const resourceModel = Array.isArray(resource) ?
- resource.map(resourceElement => resourceElement?.href && {
- ...resourceElement,
- name: resourceElement?.name || resourceElement?.title
- }) :
- resource?.href && { ...resource, name: resource?.name || resource?.title };
-
- result = {
- ...result,
- ...this.isValue(resourceModel) && { [resourceKey]: resourceModel },
- };
-
- return result;
- }, {});
- }
-
private getFormlyFieldConfig(fieldSchema:IOPFieldSchemaWithKey, formPayload:IOPFormModel):IOPFormlyFieldSettings|null {
const { key, name: label, required, hasDefault, minLength, maxLength } = fieldSchema;
const fieldTypeConfigSearch = this.getFieldTypeConfig(fieldSchema);
@@ -429,10 +387,6 @@ export class DynamicFieldsService {
private isMultiSelectField(field:IOPFieldSchemaWithKey) {
return field?.type?.startsWith('[]');
}
-
- private isValue(value:any) {
- return ![null, undefined, ''].includes(value);
- }
}
diff --git a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
index b8c93945b86..5b59072acc9 100644
--- a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.spec.ts
@@ -168,6 +168,6 @@ describe('DynamicFormService', () => {
.submit$(dynamicForm, testFormUrl)
.subscribe();
- expect(formsService.submit$).toHaveBeenCalledWith(dynamicForm, testFormUrl, undefined, undefined);
+ expect(formsService.submit$).toHaveBeenCalledWith(dynamicForm, testFormUrl, undefined, undefined, undefined);
});
});
diff --git a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.ts b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.ts
index 3b81b91879c..342267ba89c 100644
--- a/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/services/dynamic-form/dynamic-form.service.ts
@@ -14,6 +14,7 @@ import { FormsService } from "core-app/core/forms/forms.service";
@Injectable()
export class DynamicFormService {
dynamicForm:FormlyForm;
+ formSchema:IOPFormSchema;
constructor(
private _httpClient:HttpClient,
@@ -45,18 +46,26 @@ export class DynamicFormService {
}
getSettings(formConfig:IOPFormSettingsResource):IOPDynamicFormSettings {
- const formSchema = formConfig._embedded?.schema;
+ this.formSchema = formConfig._embedded?.schema;
const formPayload = formConfig._embedded?.payload;
const dynamicForm = {
form: new FormGroup({}),
- fields: this._dynamicFieldsService.getConfig(formSchema, formPayload),
+ fields: this._dynamicFieldsService.getConfig(this.formSchema, formPayload),
model: this._dynamicFieldsService.getModel(formPayload),
};
return dynamicForm;
}
+ formatModelToEdit(formModel:IOPFormModel):IOPFormModel {
+ return this._formsService.formatModelToEdit(formModel);
+ }
+
+ validateForm$(form:FormGroup, resourceEndpoint:string) {
+ return this._formsService.validateForm$(form, resourceEndpoint, this.formSchema);
+ };
+
submit$(form:FormGroup, resourceEndpoint:string, resourceId?:string, formHttpMethod?: 'post' | 'patch') {
- return this._formsService.submit$(form, resourceEndpoint, resourceId, formHttpMethod);
+ return this._formsService.submit$(form, resourceEndpoint, resourceId, formHttpMethod, this.formSchema);
}
}
\ No newline at end of file
diff --git a/lib/open_project/configuration.rb b/lib/open_project/configuration.rb
index 485beb06070..0ca678894e6 100644
--- a/lib/open_project/configuration.rb
+++ b/lib/open_project/configuration.rb
@@ -182,8 +182,13 @@ module OpenProject
# Allow separate error reporting for frontend errors
'sentry_frontend_dsn' => nil,
'sentry_host' => nil,
- # Sample rate for performance monitoring
- 'sentry_traces_sample_rate' => 0.1,
+ # Allow sentry to collect tracing samples
+ # set to 1 to enable default tracing samples (see sentry initializer)
+ # set to n >= 1 to enable n times the default tracing
+ 'sentry_trace_factor' => 0,
+ # Allow sentry to collect tracing samples on frontend
+ # set to n >= 1 to enable n times the default tracing
+ 'sentry_frontend_trace_factor' => 0,
# Allow connection to Augur
'enterprise_trial_creation_host' => 'https://augur.openproject.com',