From 0776378477a5fa781cf9227b1934d4dbbe837184 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:47:38 +1100 Subject: [PATCH] [8.x] [ResponseOps][Cases] Design Review changes PR 2 (#194681) (#195205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps][Cases] Design Review changes PR 2 (#194681)](https://github.com/elastic/kibana/pull/194681) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Georgiana-Andreea Onoleață --- .../components/custom_fields/index.test.tsx | 5 +-- .../public/components/custom_fields/index.tsx | 40 +++++++++---------- .../components/templates/index.test.tsx | 4 +- .../public/components/templates/index.tsx | 38 +++++++++--------- 4 files changed, 43 insertions(+), 44 deletions(-) diff --git a/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx b/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx index 26ee9b8476da6..fc6c774c20b0c 100644 --- a/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx +++ b/x-pack/plugins/cases/public/components/custom_fields/index.test.tsx @@ -97,13 +97,12 @@ describe('CustomFields', () => { required: false, }); } + const customFields = [...customFieldsConfigurationMock, ...generatedMockCustomFields]; appMockRender.render(); - await userEvent.click(await screen.findByTestId('add-custom-field')); - expect(await screen.findByText(i18n.MAX_CUSTOM_FIELD_LIMIT(MAX_CUSTOM_FIELDS_PER_CASE))); - expect(await screen.findByTestId('add-custom-field')).toHaveAttribute('disabled'); + expect(screen.queryByTestId('add-custom-field')).not.toBeInTheDocument(); }); }); diff --git a/x-pack/plugins/cases/public/components/custom_fields/index.tsx b/x-pack/plugins/cases/public/components/custom_fields/index.tsx index 3c754d39a63fb..d749a7aba9bea 100644 --- a/x-pack/plugins/cases/public/components/custom_fields/index.tsx +++ b/x-pack/plugins/cases/public/components/custom_fields/index.tsx @@ -80,18 +80,9 @@ const CustomFieldsComponent: React.FC = ({ onDeleteCustomField={handleDeleteCustomField} onEditCustomField={onEditCustomField} /> - {error ? ( - - - - {i18n.MAX_CUSTOM_FIELD_LIMIT(MAX_CUSTOM_FIELDS_PER_CASE)} - - - - ) : null} ) : null} - + {!customFields.length ? ( @@ -102,18 +93,27 @@ const CustomFieldsComponent: React.FC = ({ ) : null} - - {i18n.ADD_CUSTOM_FIELD} - + {customFields.length < MAX_CUSTOM_FIELDS_PER_CASE ? ( + + {i18n.ADD_CUSTOM_FIELD} + + ) : ( + + + {i18n.MAX_CUSTOM_FIELD_LIMIT(MAX_CUSTOM_FIELDS_PER_CASE)} + + + )} + ) : null; diff --git a/x-pack/plugins/cases/public/components/templates/index.test.tsx b/x-pack/plugins/cases/public/components/templates/index.test.tsx index 1c7b6cc3ff0e6..7fcb563a54dde 100644 --- a/x-pack/plugins/cases/public/components/templates/index.test.tsx +++ b/x-pack/plugins/cases/public/components/templates/index.test.tsx @@ -130,9 +130,7 @@ describe('Templates', () => { appMockRender.render(); - await userEvent.click(await screen.findByTestId('add-template')); - expect(await screen.findByText(i18n.MAX_TEMPLATE_LIMIT(MAX_TEMPLATES_LENGTH))); - expect(await screen.findByTestId('add-template')).toHaveAttribute('disabled'); + expect(screen.queryByTestId('add-template')).not.toBeInTheDocument(); }); }); diff --git a/x-pack/plugins/cases/public/components/templates/index.tsx b/x-pack/plugins/cases/public/components/templates/index.tsx index 3be2bf92411a9..479101d2889ad 100644 --- a/x-pack/plugins/cases/public/components/templates/index.tsx +++ b/x-pack/plugins/cases/public/components/templates/index.tsx @@ -92,16 +92,9 @@ const TemplatesComponent: React.FC = ({ onEditTemplate={handleEditTemplate} onDeleteTemplate={handleDeleteTemplate} /> - {error ? ( - - - {i18n.MAX_TEMPLATE_LIMIT(MAX_TEMPLATES_LENGTH)} - - - ) : null} ) : null} - + {!templates.length ? ( @@ -113,16 +106,25 @@ const TemplatesComponent: React.FC = ({ {canAddTemplates ? ( - - {i18n.ADD_TEMPLATE} - + {templates.length < MAX_TEMPLATES_LENGTH ? ( + + {i18n.ADD_TEMPLATE} + + ) : ( + + + {i18n.MAX_TEMPLATE_LIMIT(MAX_TEMPLATES_LENGTH)} + + + )} + ) : null}