diff --git a/src/Squidex/Areas/Api/Controllers/Apps/Models/UpsertWorkflowDto.cs b/src/Squidex/Areas/Api/Controllers/Apps/Models/UpsertWorkflowDto.cs index f091ced6c..d808c60b6 100644 --- a/src/Squidex/Areas/Api/Controllers/Apps/Models/UpsertWorkflowDto.cs +++ b/src/Squidex/Areas/Api/Controllers/Apps/Models/UpsertWorkflowDto.cs @@ -33,7 +33,7 @@ namespace Squidex.Areas.Api.Controllers.Apps.Models x => x.Key, x => new WorkflowStep( x.Value?.Transitions.ToDictionary( - y => x.Key, + y => y.Key, y => new WorkflowTransition(y.Value.Expression, y.Value.Role)), x.Value.Color, x.Value.NoUpdate)), diff --git a/src/Squidex/app/shared/services/workflows.service.spec.ts b/src/Squidex/app/shared/services/workflows.service.spec.ts index 634052471..cdf96ce7f 100644 --- a/src/Squidex/app/shared/services/workflows.service.spec.ts +++ b/src/Squidex/app/shared/services/workflows.service.spec.ts @@ -11,6 +11,7 @@ import { inject, TestBed } from '@angular/core/testing'; import { AnalyticsService, ApiUrlConfig, + Resource, Version, Versioned, WorkflowDto, @@ -48,7 +49,7 @@ describe('WorkflowsService', () => { workflow = result; }); - const req = httpMock.expectOne('http://service/p/api/apps/my-app/workflows'); + const req = httpMock.expectOne('http://service/p/api/apps/my-app/workflow'); expect(req.request.method).toEqual('GET'); expect(req.request.headers.get('If-Match')).toBeNull(); @@ -66,15 +67,19 @@ describe('WorkflowsService', () => { it('should make a put request to assign a workflow', inject([WorkflowsService, HttpTestingController], (workflowsService: WorkflowsService, httpMock: HttpTestingController) => { - const dto = createWorkflow('Draft'); + const resource: Resource = { + _links: { + update: { method: 'PUT', href: '/api/apps/my-app/workflow' } + } + }; let workflow: Versioned; - workflowsService.putWorkflow('my-app', dto, dto.workflow.serialize(), version).subscribe(result => { + workflowsService.putWorkflow('my-app', resource, {}, version).subscribe(result => { workflow = result; }); - const req = httpMock.expectOne('http://service/p/api/apps/my-app/workflows'); + const req = httpMock.expectOne('http://service/p/api/apps/my-app/workflow'); expect(req.request.method).toEqual('PUT'); expect(req.request.headers.get('If-Match')).toEqual(version.value); diff --git a/src/Squidex/app/shared/services/workflows.service.ts b/src/Squidex/app/shared/services/workflows.service.ts index 4f8450cdf..ce9861f10 100644 --- a/src/Squidex/app/shared/services/workflows.service.ts +++ b/src/Squidex/app/shared/services/workflows.service.ts @@ -237,7 +237,7 @@ export class WorkflowsService { } public getWorkflow(appName: string): Observable> { - const url = this.apiUrl.buildUrl(`api/apps/${appName}/workflows`); + const url = this.apiUrl.buildUrl(`api/apps/${appName}/workflow`); return HTTP.getVersioned(this.http, url).pipe( mapVersioned(({ body }) => { @@ -247,9 +247,11 @@ export class WorkflowsService { } public putWorkflow(appName: string, resource: Resource, dto: any, version: Version): Observable> { - const url = this.apiUrl.buildUrl(`api/apps/${appName}/workflows`); + const link = resource._links['update']; - return HTTP.putVersioned(this.http, url, resource, version).pipe( + const url = this.apiUrl.buildUrl(link.href); + + return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( mapVersioned(({ body }) => { return parseWorkflowPayload(body); }),