From a842e09c00c35a1606ce3b5b94bc051e767dea4e Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Tue, 18 Jun 2019 08:14:46 +0200 Subject: [PATCH] Removed links. --- .../app/features/administration/state/users.state.ts | 9 ++------- .../app/shared/components/markdown-editor.component.ts | 4 ++-- src/Squidex/app/shared/components/pipes.ts | 10 +++++----- .../app/shared/components/rich-editor.component.ts | 6 +++--- src/Squidex/app/shared/services/assets.service.ts | 4 ++++ src/Squidex/app/shared/state/backups.state.ts | 8 ++------ src/Squidex/app/shared/state/clients.state.ts | 8 ++------ src/Squidex/app/shared/state/contents.state.ts | 9 ++------- src/Squidex/app/shared/state/contributors.state.ts | 8 ++------ src/Squidex/app/shared/state/languages.state.ts | 7 +------ src/Squidex/app/shared/state/patterns.state.ts | 10 +++------- src/Squidex/app/shared/state/roles.state.ts | 8 ++------ src/Squidex/app/shared/state/rules.state.ts | 8 ++------ src/Squidex/app/shared/state/schemas.state.ts | 8 ++------ 14 files changed, 34 insertions(+), 73 deletions(-) diff --git a/src/Squidex/app/features/administration/state/users.state.ts b/src/Squidex/app/features/administration/state/users.state.ts index fdaf13365..773f441a7 100644 --- a/src/Squidex/app/features/administration/state/users.state.ts +++ b/src/Squidex/app/features/administration/state/users.state.ts @@ -15,7 +15,6 @@ import { DialogService, ImmutableArray, Pager, - ResourceLinks, shareSubscribed, State } from '@app/shared'; @@ -45,9 +44,6 @@ interface Snapshot { // Indicates if the user can create a user. canCreate?: boolean; - - // The resource links. - _links?: ResourceLinks; } export type UsersList = ImmutableArray; @@ -114,7 +110,7 @@ export class UsersState extends State { this.snapshot.usersPager.pageSize, this.snapshot.usersPager.skip, this.snapshot.usersQuery).pipe( - tap(({ total, items, canCreate, _links }) => { + tap(({ total, items, canCreate }) => { if (isReload) { this.dialogs.notifyInfo('Users reloaded.'); } @@ -134,8 +130,7 @@ export class UsersState extends State { isLoaded: true, selectedUser, users, - usersPager, - _links + usersPager }; }); }), diff --git a/src/Squidex/app/shared/components/markdown-editor.component.ts b/src/Squidex/app/shared/components/markdown-editor.component.ts index f8c183cd4..bc7ed55a6 100644 --- a/src/Squidex/app/shared/components/markdown-editor.component.ts +++ b/src/Squidex/app/shared/components/markdown-editor.component.ts @@ -201,7 +201,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent 0) { @@ -244,7 +244,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent { if (Types.is(asset, AssetDto)) { - replaceText(`![${asset.fileName}](${asset._links['content'].href} '${asset.fileName}')`); + replaceText(`![${asset.fileName}](${asset.contentUrl} '${asset.fileName}')`); } }, error => { if (!Types.is(error, UploadCanceled)) { diff --git a/src/Squidex/app/shared/components/pipes.ts b/src/Squidex/app/shared/components/pipes.ts index 99a039677..11abdf943 100644 --- a/src/Squidex/app/shared/components/pipes.ts +++ b/src/Squidex/app/shared/components/pipes.ts @@ -13,10 +13,10 @@ import { map } from 'rxjs/operators'; import { ApiUrlConfig, + AssetDto, formatHistoryMessage, HistoryEventDto, MathHelper, - Resource, UserDto, UsersProviderService } from '@app/shared/internal'; @@ -216,8 +216,8 @@ export class UserPictureRefPipe extends UserAsyncPipe implements PipeTransform { pure: true }) export class AssetUrlPipe implements PipeTransform { - public transform(asset: Resource): string { - return `${asset._links['content'].href}&sq=${MathHelper.guid()}`; + public transform(asset: AssetDto): string { + return `${asset.contentUrl}&sq=${MathHelper.guid()}`; } } @@ -226,8 +226,8 @@ export class AssetUrlPipe implements PipeTransform { pure: true }) export class AssetPreviewUrlPipe implements PipeTransform { - public transform(asset: Resource): string { - return asset._links['content'].href; + public transform(asset: AssetDto): string { + return asset.contentUrl; } } diff --git a/src/Squidex/app/shared/components/rich-editor.component.ts b/src/Squidex/app/shared/components/rich-editor.component.ts index a74c486a4..2807a136f 100644 --- a/src/Squidex/app/shared/components/rich-editor.component.ts +++ b/src/Squidex/app/shared/components/rich-editor.component.ts @@ -98,7 +98,7 @@ export class RichEditorComponent extends StatefulControlComponent i this.assetUploader.uploadFile(file) .subscribe(asset => { if (Types.is(asset, AssetDto)) { - success(asset._links['content'].href); + success(asset.contentUrl); } }, error => { if (!Types.is(error, UploadCanceled)) { @@ -186,7 +186,7 @@ export class RichEditorComponent extends StatefulControlComponent i let content = ''; for (let asset of assets) { - content += `${asset.fileName}`; + content += `${asset.fileName}`; } if (content.length > 0) { @@ -216,7 +216,7 @@ export class RichEditorComponent extends StatefulControlComponent i this.assetUploader.uploadFile(file) .subscribe(asset => { if (Types.is(asset, AssetDto)) { - replaceText(`${asset.fileName}`); + replaceText(`${asset.fileName}`); } }, error => { if (!Types.is(error, UploadCanceled)) { diff --git a/src/Squidex/app/shared/services/assets.service.ts b/src/Squidex/app/shared/services/assets.service.ts index 4b9576de4..715047113 100644 --- a/src/Squidex/app/shared/services/assets.service.ts +++ b/src/Squidex/app/shared/services/assets.service.ts @@ -39,6 +39,10 @@ export class AssetDto { public readonly canUpdate: boolean; public readonly canUpload: boolean; + public get contentUrl() { + return this._links['content'].href; + } + constructor(links: ResourceLinks, meta: Metadata, public readonly id: string, public readonly created: DateTime, diff --git a/src/Squidex/app/shared/state/backups.state.ts b/src/Squidex/app/shared/state/backups.state.ts index 86f9b50c3..a74e5ac6a 100644 --- a/src/Squidex/app/shared/state/backups.state.ts +++ b/src/Squidex/app/shared/state/backups.state.ts @@ -12,7 +12,6 @@ import { tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareSubscribed, State } from '@app/framework'; @@ -30,9 +29,6 @@ interface Snapshot { // Indicates if the user can create new backups. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } type BackupsList = ImmutableArray; @@ -65,7 +61,7 @@ export class BackupsState extends State { } return this.backupsService.getBackups(this.appName).pipe( - tap(({ items, canCreate, _links }) => { + tap(({ items, canCreate }) => { if (isReload && !silent) { this.dialogs.notifyInfo('Backups reloaded.'); } @@ -73,7 +69,7 @@ export class BackupsState extends State { this.next(s => { - return { ...s, backups, isLoaded: true, canCreate, _links }; + return { ...s, backups, isLoaded: true, canCreate }; }); }), shareSubscribed(this.dialogs, { silent })); diff --git a/src/Squidex/app/shared/state/clients.state.ts b/src/Squidex/app/shared/state/clients.state.ts index 6a32456d3..377e845d3 100644 --- a/src/Squidex/app/shared/state/clients.state.ts +++ b/src/Squidex/app/shared/state/clients.state.ts @@ -14,7 +14,6 @@ import { tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareSubscribed, State, Version @@ -42,9 +41,6 @@ interface Snapshot { // Indicates if the user can create new clients. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } type ClientsList = ImmutableArray; @@ -109,12 +105,12 @@ export class ClientsState extends State { } private replaceClients(payload: ClientsPayload, version: Version) { - const { canCreate, items, _links } = payload; + const { canCreate, items } = payload; const clients = ImmutableArray.of(items); this.next(s => { - return { ...s, clients, isLoaded: true, version, canCreate, _links }; + return { ...s, clients, isLoaded: true, version, canCreate }; }); } diff --git a/src/Squidex/app/shared/state/contents.state.ts b/src/Squidex/app/shared/state/contents.state.ts index 4eddb3505..96ad17f18 100644 --- a/src/Squidex/app/shared/state/contents.state.ts +++ b/src/Squidex/app/shared/state/contents.state.ts @@ -14,7 +14,6 @@ import { ErrorDto, ImmutableArray, Pager, - ResourceLinks, shareSubscribed, State, Version, @@ -51,9 +50,6 @@ interface Snapshot { // Indicates if the user can create and publish a content. canCreateAndPublish?: boolean; - - // The links. - _links?: ResourceLinks; } function sameContent(lhs: ContentDto, rhs?: ContentDto): boolean { @@ -137,7 +133,7 @@ export abstract class ContentsStateBase extends State { this.snapshot.contentsPager.pageSize, this.snapshot.contentsPager.skip, this.snapshot.contentsQuery, undefined).pipe( - tap(({ total, items, canCreate, canCreateAndPublish, statuses, _links }) => { + tap(({ total, items, canCreate, canCreateAndPublish, statuses }) => { if (isReload) { this.dialogs.notifyInfo('Contents reloaded.'); } @@ -161,8 +157,7 @@ export abstract class ContentsStateBase extends State { contentsPager, isLoaded: true, selectedContent, - statuses, - _links + statuses }; }); })); diff --git a/src/Squidex/app/shared/state/contributors.state.ts b/src/Squidex/app/shared/state/contributors.state.ts index 794959714..cfcd6d80f 100644 --- a/src/Squidex/app/shared/state/contributors.state.ts +++ b/src/Squidex/app/shared/state/contributors.state.ts @@ -13,7 +13,6 @@ import { DialogService, ErrorDto, ImmutableArray, - ResourceLinks, shareMapSubscribed, shareSubscribed, State, @@ -45,9 +44,6 @@ interface Snapshot { // Indicates if the user can add a contributor. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } type ContributorsList = ImmutableArray; @@ -115,11 +111,11 @@ export class ContributorsState extends State { private replaceContributors(version: Version, payload: ContributorsPayload) { this.next(s => { - const { canCreate, items, maxContributors, _links } = payload; + const { canCreate, items, maxContributors } = payload; const contributors = ImmutableArray.of(items); - return { ...s, contributors, maxContributors, isLoaded: true, version, canCreate, _links }; + return { ...s, contributors, maxContributors, isLoaded: true, version, canCreate }; }); } diff --git a/src/Squidex/app/shared/state/languages.state.ts b/src/Squidex/app/shared/state/languages.state.ts index b2c948b7f..7f1a77f27 100644 --- a/src/Squidex/app/shared/state/languages.state.ts +++ b/src/Squidex/app/shared/state/languages.state.ts @@ -12,7 +12,6 @@ import { map, tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareMapSubscribed, shareSubscribed, State, @@ -58,9 +57,6 @@ interface Snapshot { // Inedicates if the user can add a language. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } type AppLanguagesList = ImmutableArray; @@ -146,7 +142,7 @@ export class LanguagesState extends State { this.next(s => { allLanguages = allLanguages || s.allLanguages; - const { canCreate, items, _links } = payload; + const { canCreate, items } = payload; const languages = ImmutableArray.of(items); @@ -157,7 +153,6 @@ export class LanguagesState extends State { allLanguages: allLanguages, allLanguagesNew: allLanguages.filter(x => !languages.find(l => l.iso2Code === x.iso2Code)), isLoaded: true, - _links, version: version }; }); diff --git a/src/Squidex/app/shared/state/patterns.state.ts b/src/Squidex/app/shared/state/patterns.state.ts index 7a9b0458d..5d6d742d0 100644 --- a/src/Squidex/app/shared/state/patterns.state.ts +++ b/src/Squidex/app/shared/state/patterns.state.ts @@ -12,7 +12,6 @@ import { tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareMapSubscribed, shareSubscribed, State, @@ -40,9 +39,6 @@ interface Snapshot { // Indicates if patterns can be created. canCreate?: boolean; - - // The links. - _links: ResourceLinks; } type PatternsList = ImmutableArray; @@ -63,7 +59,7 @@ export class PatternsState extends State { private readonly appsState: AppsState, private readonly dialogs: DialogService ) { - super({ patterns: ImmutableArray.empty(), version: Version.EMPTY, _links: {} }); + super({ patterns: ImmutableArray.empty(), version: Version.EMPTY }); } public load(isReload = false): Observable { @@ -109,10 +105,10 @@ export class PatternsState extends State { private replacePatterns(payload: PatternsPayload, version: Version) { const patterns = ImmutableArray.of(payload.items); - const { _links: links, canCreate } = payload; + const { canCreate } = payload; this.next(s => { - return { ...s, patterns, isLoaded: true, version, _links: links, canCreate }; + return { ...s, patterns, isLoaded: true, version, canCreate }; }); } diff --git a/src/Squidex/app/shared/state/roles.state.ts b/src/Squidex/app/shared/state/roles.state.ts index c8caa74fe..87daf6b53 100644 --- a/src/Squidex/app/shared/state/roles.state.ts +++ b/src/Squidex/app/shared/state/roles.state.ts @@ -12,7 +12,6 @@ import { tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareSubscribed, State, Version @@ -40,9 +39,6 @@ interface Snapshot { // Indicates if the user can add a role. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } type RolesList = ImmutableArray; @@ -107,12 +103,12 @@ export class RolesState extends State { } private replaceRoles(payload: RolesPayload, version: Version) { - const { canCreate, items, _links } = payload; + const { canCreate, items } = payload; const roles = ImmutableArray.of(items); this.next(s => { - return { ...s, roles, isLoaded: true, version, canCreate, _links }; + return { ...s, roles, isLoaded: true, version, canCreate }; }); } diff --git a/src/Squidex/app/shared/state/rules.state.ts b/src/Squidex/app/shared/state/rules.state.ts index 1fb71cf42..8e5ed5f2a 100644 --- a/src/Squidex/app/shared/state/rules.state.ts +++ b/src/Squidex/app/shared/state/rules.state.ts @@ -12,7 +12,6 @@ import { tap } from 'rxjs/operators'; import { DialogService, ImmutableArray, - ResourceLinks, shareSubscribed, State } from '@app/framework'; @@ -37,9 +36,6 @@ interface Snapshot { // Indicates if the user can read events. canReadEvents?: boolean; - - // The resource links. - _links?: ResourceLinks; } type RulesList = ImmutableArray; @@ -72,7 +68,7 @@ export class RulesState extends State { } return this.rulesService.getRules(this.appName).pipe( - tap(({ items, canCreate, canReadEvents, _links }) => { + tap(({ items, canCreate, canReadEvents }) => { if (isReload) { this.dialogs.notifyInfo('Rules reloaded.'); } @@ -80,7 +76,7 @@ export class RulesState extends State { this.next(s => { const rules = ImmutableArray.of(items); - return { ...s, rules, isLoaded: true, canCreate, canReadEvents, _links }; + return { ...s, rules, isLoaded: true, canCreate, canReadEvents }; }); }), shareSubscribed(this.dialogs)); diff --git a/src/Squidex/app/shared/state/schemas.state.ts b/src/Squidex/app/shared/state/schemas.state.ts index 15daaddd4..f26604e47 100644 --- a/src/Squidex/app/shared/state/schemas.state.ts +++ b/src/Squidex/app/shared/state/schemas.state.ts @@ -13,7 +13,6 @@ import { compareStringsAsc, DialogService, ImmutableArray, - ResourceLinks, shareMapSubscribed, shareSubscribed, State, @@ -52,9 +51,6 @@ interface Snapshot { // Indicates if the user can create a schema. canCreate?: boolean; - - // The links. - _links?: ResourceLinks; } export type SchemasList = ImmutableArray; @@ -122,7 +118,7 @@ export class SchemasState extends State { } return this.schemasService.getSchemas(this.appName).pipe( - tap(({ items, canCreate, _links }) => { + tap(({ items, canCreate }) => { if (isReload) { this.dialogs.notifyInfo('Schemas reloaded.'); } @@ -132,7 +128,7 @@ export class SchemasState extends State { const categories = buildCategories(s.categories, schemas); - return { ...s, schemas, isLoaded: true, categories, canCreate, _links }; + return { ...s, schemas, isLoaded: true, categories, canCreate }; }); }), shareSubscribed(this.dialogs));