From 788dae973a1deee7427a4b4cc139d0692a642a5a Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Fri, 29 Sep 2023 07:10:27 +0100 Subject: [PATCH] [ML] Improves display for long descriptions in transforms (#165149) Improves the display of long descriptions of transforms in the Transform management page and when editing the description in the transform wizard or edit flyout. Previously If there was a long description, the text would not be wrapped in the table on the management page, and it would not be possible to view the full text in the text input when editing. This PR adds line wrapping for the description column, and uses a text area for editing the text. Part of https://github.com/elastic/kibana/issues/163147 --- .../step_details/step_details_form.tsx | 3 +- .../capitalize_first_letter.ts | 10 +++ .../edit_transform_flyout_form.tsx | 3 +- .../edit_transform_flyout_form_text_area.tsx | 61 +++++++++++++++++++ .../edit_transform_flyout_form_text_input.tsx | 5 +- .../components/transform_list/use_columns.tsx | 15 ++++- 6 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/capitalize_first_letter.ts create mode 100644 x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form_text_area.tsx diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx index da9ebbf9b2ef7..0d93a31f9e3f2 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx @@ -22,6 +22,7 @@ import { EuiSpacer, EuiCallOut, EuiText, + EuiTextArea, } from '@elastic/eui'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; @@ -421,7 +422,7 @@ export const StepDetailsForm: FC = React.memo( defaultMessage: 'Transform description', })} > - ( - = ({ + field, + label, + helpText, + placeHolder = false, +}) => { + const { defaultValue, errorMessages, value } = useEditTransformFlyout(field); + const { formField } = useEditTransformFlyout('actions'); + const upperCaseField = capitalizeFirstLetter(field); + + return ( + 0} + error={errorMessages} + > + 0} + value={value} + onChange={(e) => formField({ field, value: e.target.value })} + aria-label={label} + /> + + ); +}; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form_text_input.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form_text_input.tsx index d9310762ef3e0..9c93d286cb9c4 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form_text_input.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/edit_transform_flyout/edit_transform_flyout_form_text_input.tsx @@ -15,10 +15,7 @@ import { useEditTransformFlyout, type EditTransformHookTextInputSelectors, } from './use_edit_transform_flyout'; - -function capitalizeFirstLetter(str: string) { - return str.charAt(0).toUpperCase() + str.slice(1); -} +import { capitalizeFirstLetter } from './capitalize_first_letter'; interface EditTransformFlyoutFormTextInputProps { field: EditTransformHookTextInputSelectors; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_columns.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_columns.tsx index fb578ec06aa3c..732261bde89d2 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_columns.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/use_columns.tsx @@ -222,7 +222,20 @@ export const useColumns = ( 'data-test-subj': 'transformListColumnDescription', name: i18n.translate('xpack.transform.description', { defaultMessage: 'Description' }), sortable: true, - truncateText: true, + render(text: string) { + return ( + + {text} + + ); + }, }, { name: i18n.translate('xpack.transform.type', { defaultMessage: 'Type' }),