Browse Source

Workflow fixes.

pull/380/head
Sebastian Stehle 7 years ago
parent
commit
22ca1b5e0b
  1. 2
      src/Squidex/Areas/Api/Controllers/Apps/Models/UpsertWorkflowDto.cs
  2. 13
      src/Squidex/app/shared/services/workflows.service.spec.ts
  3. 8
      src/Squidex/app/shared/services/workflows.service.ts

2
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)),

13
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<WorkflowPayload>;
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);

8
src/Squidex/app/shared/services/workflows.service.ts

@ -237,7 +237,7 @@ export class WorkflowsService {
}
public getWorkflow(appName: string): Observable<Versioned<WorkflowPayload>> {
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<Versioned<WorkflowPayload>> {
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);
}),

Loading…
Cancel
Save