From 41a8a10da710748c685723d43d39011792d6642c Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Fri, 14 Aug 2020 12:17:57 +0200 Subject: [PATCH] [ML] update expanded row --- x-pack/plugins/ml/common/types/inference.ts | 2 +- .../models_management/expanded_row.tsx | 176 ++++++++++-------- 2 files changed, 96 insertions(+), 82 deletions(-) diff --git a/x-pack/plugins/ml/common/types/inference.ts b/x-pack/plugins/ml/common/types/inference.ts index 18214836d92a4b..9d4e6eeb474c63 100644 --- a/x-pack/plugins/ml/common/types/inference.ts +++ b/x-pack/plugins/ml/common/types/inference.ts @@ -59,5 +59,5 @@ export interface ModelConfigResponse { model_id: string; tags: string; version: string; - inference_config: any; + inference_config?: Record; } diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/models_management/expanded_row.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/models_management/expanded_row.tsx index 0b99516df0ac91..6793a1f434a193 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/models_management/expanded_row.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/models_management/expanded_row.tsx @@ -48,6 +48,17 @@ export const ExpandedRow: FC = ({ item }) => { license_level, }; + function formatToListItems(items: Record) { + return Object.entries(items) + .map(([title, value]) => ({ + title, + description: typeof value === 'object' ? JSON.stringify(value) : value, + })) + .filter(({ description }) => { + return description !== undefined; + }); + } + const tabs = [ { id: 'details', @@ -57,38 +68,6 @@ export const ExpandedRow: FC = ({ item }) => { defaultMessage="Details" /> ), - content: ( - <> - - - -
- -
-
- - ({ - title, - description: typeof value === 'object' ? JSON.stringify(value) : value, - }))} - /> -
- - ), - }, - { - id: 'config', - name: ( - - ), content: ( <> @@ -98,51 +77,84 @@ export const ExpandedRow: FC = ({ item }) => {
({ - title, - description: - typeof value === 'object' ? JSON.stringify(value) : (value as any), - }) - )} + listItems={formatToListItems(details)} /> - {metadata?.analytics_config && ( - - - -
- -
-
- - ({ - title, - description: - typeof value === 'object' ? JSON.stringify(value) : (value as any), - }))} - /> -
-
- )} ), }, + ...(inferenceConfig + ? [ + { + id: 'config', + name: ( + + ), + content: ( + <> + + + + + +
+ +
+
+ + +
+
+ {metadata?.analytics_config && ( + + + +
+ +
+
+ + +
+
+ )} +
+ + ), + }, + ] + : []), + { id: 'stats', name: ( @@ -154,24 +166,26 @@ export const ExpandedRow: FC = ({ item }) => { content: ( <> - - -
- + + + +
+ +
+
+ + -
-
- - ({ - title, - description: typeof value === 'object' ? JSON.stringify(value) : value, - }))} - /> -
+ + + ), },