From 10899f34bd2e6384061da8a0baffea3ca1750e3d Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 23 Mar 2021 10:45:25 +0100 Subject: [PATCH] fix(admin-ui): Fix display of string results in JobQueue list --- .../components/object-tree/object-tree.component.html | 2 +- .../components/object-tree/object-tree.component.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.html b/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.html index 6e58ca73b1..f9a6600100 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.html +++ b/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.html @@ -9,7 +9,7 @@ [class.expanded]="expanded" >
  • - {{ entry.key }}: + {{ entry.key }}: diff --git a/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.ts b/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.ts index 1d29410272..79774f9a35 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.ts +++ b/packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.ts @@ -10,7 +10,7 @@ import { ChangeDetectionStrategy, Component, Input, OnInit, Optional, SkipSelf } changeDetection: ChangeDetectionStrategy.OnPush, }) export class ObjectTreeComponent implements OnInit { - @Input() value: { [key: string]: any }; + @Input() value: { [key: string]: any } | string; @Input() isArrayItem = false; depth: number; expanded: boolean; @@ -25,7 +25,7 @@ export class ObjectTreeComponent implements OnInit { } ngOnInit() { - this.entries = Object.entries(this.value).map(([key, value]) => ({ key, value })); + this.entries = this.getEntries(this.value); this.expanded = this.depth === 0 || this.isArrayItem; this.valueIsArray = Object.keys(this.value).every(v => Number.isInteger(+v)); } @@ -33,4 +33,11 @@ export class ObjectTreeComponent implements OnInit { isObject(value: any): boolean { return typeof value === 'object' && value !== null; } + + private getEntries(inputValue: { [key: string]: any } | string): Array<{ key: string; value: any }> { + if (typeof inputValue === 'string') { + return [{ key: '', value: inputValue }]; + } + return Object.entries(inputValue).map(([key, value]) => ({ key, value })); + } }