Browse Source

Formatting

pull/380/head
Sebastian 7 years ago
parent
commit
86a85518ee
  1. 2
      src/Squidex/app/features/administration/module.ts
  2. 2
      src/Squidex/app/features/api/module.ts
  3. 2
      src/Squidex/app/features/apps/module.ts
  4. 2
      src/Squidex/app/features/assets/module.ts
  5. 2
      src/Squidex/app/features/content/module.ts
  6. 2
      src/Squidex/app/features/dashboard/module.ts
  7. 2
      src/Squidex/app/features/rules/module.ts
  8. 2
      src/Squidex/app/features/schemas/module.ts
  9. 2
      src/Squidex/app/features/settings/module.ts
  10. 2
      src/Squidex/app/framework/angular/code.component.ts
  11. 2
      src/Squidex/app/framework/angular/pipes/name.pipe.spec.ts
  12. 4
      src/Squidex/app/framework/angular/routers/router-utils.ts
  13. 6
      src/Squidex/app/framework/configurations.ts
  14. 4
      src/Squidex/app/framework/services/message-bus.service.spec.ts
  15. 2
      src/Squidex/app/framework/services/title.service.ts
  16. 2
      src/Squidex/app/framework/utils/interpolator.spec.ts
  17. 1
      src/Squidex/app/shared/internal.ts
  18. 6
      src/Squidex/app/shared/module.ts
  19. 2
      src/Squidex/app/shared/services/graphql.service.spec.ts
  20. 2
      src/Squidex/app/shared/services/ui.service.ts
  21. 22
      src/Squidex/app/shared/services/workflows.service.spec.ts
  22. 2
      src/Squidex/app/shared/state/asset-uploader.state.ts
  23. 100
      src/Squidex/app/shared/state/workflows.state.spec.ts
  24. 97
      src/Squidex/app/shared/state/workflows.state.ts
  25. 2
      src/Squidex/app/shared/utils/messages.ts

2
src/Squidex/app/features/administration/module.ts

@ -87,4 +87,4 @@ const routes: Routes = [
UsersState UsersState
] ]
}) })
export class SqxFeatureAdministrationModule { } export class SqxFeatureAdministrationModule {}

2
src/Squidex/app/features/api/module.ts

@ -45,4 +45,4 @@ const routes: Routes = [
GraphQLPageComponent GraphQLPageComponent
] ]
}) })
export class SqxFeatureApiModule { } export class SqxFeatureApiModule {}

2
src/Squidex/app/features/apps/module.ts

@ -35,4 +35,4 @@ const routes: Routes = [
OnboardingDialogComponent OnboardingDialogComponent
] ]
}) })
export class SqxFeatureAppsModule { } export class SqxFeatureAppsModule {}

2
src/Squidex/app/features/assets/module.ts

@ -39,4 +39,4 @@ const routes: Routes = [
AssetsPageComponent AssetsPageComponent
] ]
}) })
export class SqxFeatureAssetsModule { } export class SqxFeatureAssetsModule {}

2
src/Squidex/app/features/content/module.ts

@ -128,4 +128,4 @@ const routes: Routes = [
SchemasPageComponent SchemasPageComponent
] ]
}) })
export class SqxFeatureContentModule { } export class SqxFeatureContentModule {}

2
src/Squidex/app/features/dashboard/module.ts

@ -33,4 +33,4 @@ const routes: Routes = [
DashboardPageComponent DashboardPageComponent
] ]
}) })
export class SqxFeatureDashboardModule { } export class SqxFeatureDashboardModule {}

2
src/Squidex/app/features/rules/module.ts

@ -66,4 +66,4 @@ const routes: Routes = [
UsageTriggerComponent UsageTriggerComponent
] ]
}) })
export class SqxFeatureRulesModule { } export class SqxFeatureRulesModule {}

2
src/Squidex/app/features/schemas/module.ts

@ -112,4 +112,4 @@ const routes: Routes = [
TagsValidationComponent TagsValidationComponent
] ]
}) })
export class SqxFeatureSchemasModule { } export class SqxFeatureSchemasModule {}

2
src/Squidex/app/features/settings/module.ts

@ -209,4 +209,4 @@ const routes: Routes = [
WorkflowStepComponent WorkflowStepComponent
] ]
}) })
export class SqxFeatureSettingsModule { } export class SqxFeatureSettingsModule {}

2
src/Squidex/app/framework/angular/code.component.ts

@ -13,4 +13,4 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
templateUrl: './code.component.html', templateUrl: './code.component.html',
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class CodeComponent { } export class CodeComponent {}

2
src/Squidex/app/framework/angular/pipes/name.pipe.spec.ts

@ -54,6 +54,6 @@ describe('DisplayNamePipe', () => {
it('should return empty string if also fallback not found', () => { it('should return empty string if also fallback not found', () => {
const pipe = new DisplayNamePipe(); const pipe = new DisplayNamePipe();
expect(pipe.transform({ })).toBe(''); expect(pipe.transform({})).toBe('');
}); });
}); });

4
src/Squidex/app/framework/angular/routers/router-utils.ts

@ -10,7 +10,7 @@ import { ActivatedRoute, ActivatedRouteSnapshot, Data, Params, RouterStateSnapsh
export function allData(value: ActivatedRouteSnapshot | ActivatedRoute): Data { export function allData(value: ActivatedRouteSnapshot | ActivatedRoute): Data {
let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value; let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value;
const result: { [key: string]: any } = { }; const result: { [key: string]: any } = {};
while (snapshot) { while (snapshot) {
for (let key in snapshot.data) { for (let key in snapshot.data) {
@ -27,7 +27,7 @@ export function allData(value: ActivatedRouteSnapshot | ActivatedRoute): Data {
export function allParams(value: ActivatedRouteSnapshot | ActivatedRoute): Params { export function allParams(value: ActivatedRouteSnapshot | ActivatedRoute): Params {
let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value; let snapshot: ActivatedRouteSnapshot | null = value['snapshot'] || value;
const result: { [key: string]: any } = { }; const result: { [key: string]: any } = {};
while (snapshot) { while (snapshot) {
for (let key in snapshot.params) { for (let key in snapshot.params) {

6
src/Squidex/app/framework/configurations.ts

@ -35,13 +35,13 @@ export class CurrencyConfig {
} }
export class AnalyticsIdConfig { export class AnalyticsIdConfig {
constructor(public value: string) { } constructor(public value: string) {}
} }
export class DecimalSeparatorConfig { export class DecimalSeparatorConfig {
constructor(public readonly value: string) { } constructor(public readonly value: string) {}
} }
export class ProductionModeConfig { export class ProductionModeConfig {
constructor(public readonly isProductionMode: boolean) { } constructor(public readonly isProductionMode: boolean) {}
} }

4
src/Squidex/app/framework/services/message-bus.service.spec.ts

@ -7,8 +7,8 @@
import { MessageBus, MessageBusFactory } from './message-bus.service'; import { MessageBus, MessageBusFactory } from './message-bus.service';
class Event1 { } class Event1 {}
class Event2 { } class Event2 {}
describe('MessageBus', () => { describe('MessageBus', () => {
it('should instantiate from factory', () => { it('should instantiate from factory', () => {

2
src/Squidex/app/framework/services/title.service.ts

@ -22,7 +22,7 @@ export const TitleServiceFactory = (titles: TitlesConfig) => {
@Injectable() @Injectable()
export class TitleService { export class TitleService {
constructor(private readonly titles: TitlesConfig) { } constructor(private readonly titles: TitlesConfig) {}
public setTitle(key: string, parameters?: { [key: string]: string }) { public setTitle(key: string, parameters?: { [key: string]: string }) {
let title = this.titles.value[key] || key; let title = this.titles.value[key] || key;

2
src/Squidex/app/framework/utils/interpolator.spec.ts

@ -58,7 +58,7 @@ describe('interpolate', () => {
}); });
it('should return undefined if it resolved to object', () => { it('should return undefined if it resolved to object', () => {
const result = interpolate('hello ${data}', { data: { } }); const result = interpolate('hello ${data}', { data: {} });
expect(result).toEqual('hello undefined'); expect(result).toEqual('hello undefined');
}); });

1
src/Squidex/app/shared/internal.ts

@ -63,6 +63,7 @@ export * from './state/rules.state';
export * from './state/schemas.forms'; export * from './state/schemas.forms';
export * from './state/schemas.state'; export * from './state/schemas.state';
export * from './state/ui.state'; export * from './state/ui.state';
export * from './state/workflows.state';
export * from './utils/messages'; export * from './utils/messages';

6
src/Squidex/app/shared/module.ts

@ -93,7 +93,9 @@ import {
UserPicturePipe, UserPicturePipe,
UserPictureRefPipe, UserPictureRefPipe,
UsersProviderService, UsersProviderService,
UsersService UsersService,
WorkflowsService,
WorkflowsState
} from './declarations'; } from './declarations';
@NgModule({ @NgModule({
@ -224,6 +226,8 @@ export class SqxSharedModule {
UsagesService, UsagesService,
UsersProviderService, UsersProviderService,
UsersService, UsersService,
WorkflowsService,
WorkflowsState,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor, useClass: AuthInterceptor,

2
src/Squidex/app/shared/services/graphql.service.spec.ts

@ -32,7 +32,7 @@ describe('GraphQlService', () => {
let graphQlResult: any = null; let graphQlResult: any = null;
graphQlService.query('my-app', { }).subscribe(result => { graphQlService.query('my-app', {}).subscribe(result => {
graphQlResult = result; graphQlResult = result;
}); });

2
src/Squidex/app/shared/services/ui.service.ts

@ -41,7 +41,7 @@ export class UIService {
return this.http.get<object>(url).pipe( return this.http.get<object>(url).pipe(
catchError(() => { catchError(() => {
return of({ }); return of({});
})); }));
} }

22
src/Squidex/app/shared/services/workflows.service.spec.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { WorkflowDto } from '@app/shared/internal'; import { WorkflowDto, WorkflowPayload } from '@app/shared/internal';
describe('Workflow', () => { describe('Workflow', () => {
it('should create empty workflow', () => { it('should create empty workflow', () => {
@ -296,4 +296,22 @@ describe('Workflow', () => {
initial: '2' initial: '2'
}); });
}); });
}); });
export function createWorkflow(name: string): WorkflowPayload {
return {
workflow: new WorkflowDto({
update: { method: 'PUT', href: '/api/workflows' }
},
`${name}1`,
[
{ name: `${name}1`, color: `${name}1`, noUpdate: true, isLocked: true },
{ name: `${name}2`, color: `${name}1`, noUpdate: true, isLocked: true }
],
[
{ from: `${name}1`, to: `${name}2`, expression: 'Expression1', role: 'Role1' },
{ from: `${name}2`, to: `${name}1`, expression: 'Expression2', role: 'Role2' }
]),
_links: {}
};
}

2
src/Squidex/app/shared/state/asset-uploader.state.ts

@ -43,7 +43,7 @@ interface Snapshot {
uploads: UploadList; uploads: UploadList;
} }
export class UploadCanceled { } export class UploadCanceled {}
type UploadList = ImmutableArray<Upload>; type UploadList = ImmutableArray<Upload>;
type UploadResult = AssetDto | number; type UploadResult = AssetDto | number;

100
src/Squidex/app/shared/state/workflows.state.spec.ts

@ -0,0 +1,100 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { of } from 'rxjs';
import { IMock, It, Mock, Times } from 'typemoq';
import {
DialogService,
versioned,
WorkflowPayload,
WorkflowsService,
WorkflowsState
} from '@app/shared/internal';
import { createWorkflow } from '../services/workflows.service.spec';
import { TestValues } from './_test-helpers';
describe('WorkflowsState', () => {
const {
app,
appsState,
newVersion,
version
} = TestValues;
const oldWorkflow = createWorkflow('test');
let dialogs: IMock<DialogService>;
let workflowsService: IMock<WorkflowsService>;
let workflowsState: WorkflowsState;
beforeEach(() => {
dialogs = Mock.ofType<DialogService>();
workflowsService = Mock.ofType<WorkflowsService>();
workflowsState = new WorkflowsState(workflowsService.object, appsState.object, dialogs.object);
});
afterEach(() => {
workflowsService.verifyAll();
});
describe('Loading', () => {
it('should load workflow', () => {
workflowsService.setup(x => x.getWorkflow(app))
.returns(() => of(versioned(version, oldWorkflow))).verifiable();
workflowsState.load().subscribe();
expect(workflowsState.snapshot.workflow).toEqual(oldWorkflow.workflow);
expect(workflowsState.snapshot.isLoaded).toBeTruthy();
expect(workflowsState.snapshot.version).toEqual(version);
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.never());
});
it('should show notification on load when reload is true', () => {
workflowsService.setup(x => x.getWorkflow(app))
.returns(() => of(versioned(version, oldWorkflow))).verifiable();
workflowsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
});
describe('Updates', () => {
beforeEach(() => {
workflowsService.setup(x => x.getWorkflow(app))
.returns(() => of(versioned(version, oldWorkflow))).verifiable();
workflowsState.load().subscribe();
});
it('should update workflows when saved', () => {
const updated = createWorkflow('updated');
const request = oldWorkflow.workflow.serialize();
workflowsService.setup(x => x.putWorkflow(app, oldWorkflow, request, version))
.returns(() => of(versioned(newVersion, updated))).verifiable();
workflowsState.save().subscribe();
expectNewWorkflows(updated);
});
function expectNewWorkflows(updated: WorkflowPayload) {
expect(workflowsState.snapshot.workflow).toEqual(updated.workflow);
expect(workflowsState.snapshot.version).toEqual(newVersion);
}
});
});

97
src/Squidex/app/shared/state/workflows.state.ts

@ -0,0 +1,97 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
// tslint:disable: no-shadowed-variable
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import {
DialogService,
shareSubscribed,
State,
Version
} from '@app/framework';
import { AppsState } from './apps.state';
import {
WorkflowDto,
WorkflowPayload,
WorkflowsService
} from './../services/workflows.service';
interface Snapshot {
// The current workflow.
workflow?: WorkflowDto;
// The app version.
version: Version;
// Indicates if the workflows are loaded.
isLoaded?: boolean;
}
@Injectable()
export class WorkflowsState extends State<Snapshot> {
public workflow =
this.project(x => x.workflow);
public isLoaded =
this.project(x => !!x.isLoaded);
constructor(
private readonly workflowsService: WorkflowsService,
private readonly appsState: AppsState,
private readonly dialogs: DialogService
) {
super({ version: Version.EMPTY });
}
public load(isReload = false): Observable<any> {
if (!isReload) {
this.resetState();
}
return this.workflowsService.getWorkflow(this.appName).pipe(
tap(({ version, payload }) => {
if (isReload) {
this.dialogs.notifyInfo('Workflow reloaded.');
}
this.replaceWorkflow(payload, version);
}),
shareSubscribed(this.dialogs));
}
public save(): Observable<any> {
const workflow = this.snapshot.workflow!;
return this.workflowsService.putWorkflow(this.appName, workflow, workflow.serialize(), this.version).pipe(
tap(({ version, payload }) => {
this.replaceWorkflow(payload, version);
}),
shareSubscribed(this.dialogs));
}
private replaceWorkflow(payload: WorkflowPayload, version: Version) {
const { workflow } = payload;
this.next(s => {
return { ...s, workflow, isLoaded: true, version };
});
}
private get appName() {
return this.appsState.appName;
}
private get version() {
return this.snapshot.version;
}
}

2
src/Squidex/app/shared/utils/messages.ts

@ -5,4 +5,4 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
export class HistoryChannelUpdated { } export class HistoryChannelUpdated {}
Loading…
Cancel
Save