From 248e075e24eac15b840a7aca4b86abd37342ae3b Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 7 Jun 2019 11:02:45 -0700 Subject: [PATCH] Web console: Simplify task and supervisor detail displays (#7848) * simplify detail display * update tests --- .../src/components/show-json/show-json.tsx | 9 ++- ...pervisor-table-action-dialog.spec.tsx.snap | 58 +++++++++---------- .../supervisor-table-action-dialog.tsx | 50 ++++++++++++---- .../task-table-action-dialog.spec.tsx.snap | 58 +++++++++---------- .../task-table-action-dialog.tsx | 53 +++++++++++++---- 5 files changed, 143 insertions(+), 85 deletions(-) diff --git a/web-console/src/components/show-json/show-json.tsx b/web-console/src/components/show-json/show-json.tsx index 27995321a5d..91cdf6d39c7 100644 --- a/web-console/src/components/show-json/show-json.tsx +++ b/web-console/src/components/show-json/show-json.tsx @@ -29,6 +29,7 @@ import './show-json.scss'; export interface ShowJsonProps extends React.Props { endpoint: string; + transform?: (x: any) => any; downloadFilename?: string; } @@ -47,12 +48,14 @@ export class ShowJson extends React.PureComponent } private getJsonInfo = async (): Promise => { - const { endpoint } = this.props; + const { endpoint, transform } = this.props; + try { const resp = await axios.get(endpoint); - const data = resp.data; + let data = resp.data; + if (transform) data = transform(data); this.setState({ - jsonValue: typeof (data) === 'string' ? data : JSON.stringify(data, undefined, 2) + jsonValue: typeof data === 'string' ? data : JSON.stringify(data, undefined, 2) }); } catch (e) { this.setState({ diff --git a/web-console/src/dialogs/supervisor-table-action-dialog/__snapshots__/supervisor-table-action-dialog.spec.tsx.snap b/web-console/src/dialogs/supervisor-table-action-dialog/__snapshots__/supervisor-table-action-dialog.spec.tsx.snap index f216fcf3887..84017de7f81 100644 --- a/web-console/src/dialogs/supervisor-table-action-dialog/__snapshots__/supervisor-table-action-dialog.spec.tsx.snap +++ b/web-console/src/dialogs/supervisor-table-action-dialog/__snapshots__/supervisor-table-action-dialog.spec.tsx.snap @@ -61,35 +61,6 @@ exports[`supervisor table action dialog matches snapshot 1`] = ` - + - +