提交 540cf831 编写于 作者: S Sebastian Florek 提交者: Kubernetes Prow Robot

Fix config map data display (#4455)

上级 8af89acd
......@@ -36,8 +36,8 @@ enum EditorTheme {
styleUrls: ['./style.scss'],
})
export class TextInputComponent implements OnInit {
@Output() textChange = new EventEmitter<string | StringMap>();
@Input() text: string | StringMap;
@Output() textChange = new EventEmitter<string>();
@Input() text: string;
@Input() readOnly = false;
@Input() mode = 'yaml';
@Input() prettify = true;
......@@ -64,19 +64,14 @@ export class TextInputComponent implements OnInit {
}
}
onTextChange(text: string | StringMap): void {
this.text = String(text);
this.textChange.emit(this.text);
onTextChange(text: string): void {
this.textChange.emit(text);
}
private prettify_(): void {
switch (this.mode) {
case 'json':
if (typeof this.text === 'string') {
this.text = JSON.stringify(JSON.parse(this.text), null, '\t');
} else {
this.text = JSON.stringify(this.text, null, '\t');
}
this.text = JSON.stringify(JSON.parse(this.text), null, '\t');
break;
default:
// Do nothing when mode is not recognized.
......
......@@ -21,5 +21,5 @@ limitations under the License.
[mode]="mode"
[theme]="theme"
[ngClass]="{'kd-border': border}"
(textChange)="onTextChange($event)"
(textChange)="onTextChange($event.toString())"
class="kd-ace"></ace-editor>
......@@ -57,4 +57,12 @@ export class ConfigMapDetailComponent implements OnInit, OnDestroy {
this.configMapSubscription_.unsubscribe();
this.actionbar_.onDetailsLeave.emit();
}
getConfigMapData(cm: ConfigMapDetail): string {
if (!cm) {
return '';
}
return JSON.stringify(cm.data);
}
}
......@@ -23,7 +23,7 @@ limitations under the License.
i18n>Data</div>
<div content>
<kd-text-input *ngIf="configMap?.data"
[text]="configMap?.data"
[text]="getConfigMapData(configMap)"
[readOnly]="true"
[border]="false"
mode="json"></kd-text-input>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册