Skip to content

Commit

Permalink
[8.x] [ResponseOps][Cases] Design Review changes PR 2 (elastic#194681) (
Browse files Browse the repository at this point in the history
elastic#195205)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases] Design Review changes PR 2
(elastic#194681)](elastic#194681)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Georgiana-Andreea
Onoleață","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-07T09:47:40Z","message":"[ResponseOps][Cases]
Design Review changes PR 2 (elastic#194681)\n\n## Summary\r\n\r\nConnects to
elastic#188187 \r\n\r\n- the \"add
template\" button is now hidden once the user reaches the\r\nlimit of 10
templates and the message is displayed in a subdued color to\r\ninform
the user that the limit has been reached.\r\n\r\n![Screenshot 2024-10-03
at 13
47\r\n32](https://github.com/user-attachments/assets/42622eff-2582-41e6-9318-18126e477f12)\r\n\r\n-
same applies to custom fields\r\n\r\n![Screenshot 2024-10-03 at 13
52\r\n20](https://github.com/user-attachments/assets/b0f13235-4345-45f1-b772-0cc5ccc771bb)","sha":"d5e2afdeee9a48d2da763fc6e300723cb855b953","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor","v8.16.0"],"title":"[ResponseOps][Cases]
Design Review changes PR
2","number":194681,"url":"https://github.com/elastic/kibana/pull/194681","mergeCommit":{"message":"[ResponseOps][Cases]
Design Review changes PR 2 (elastic#194681)\n\n## Summary\r\n\r\nConnects to
elastic#188187 \r\n\r\n- the \"add
template\" button is now hidden once the user reaches the\r\nlimit of 10
templates and the message is displayed in a subdued color to\r\ninform
the user that the limit has been reached.\r\n\r\n![Screenshot 2024-10-03
at 13
47\r\n32](https://github.com/user-attachments/assets/42622eff-2582-41e6-9318-18126e477f12)\r\n\r\n-
same applies to custom fields\r\n\r\n![Screenshot 2024-10-03 at 13
52\r\n20](https://github.com/user-attachments/assets/b0f13235-4345-45f1-b772-0cc5ccc771bb)","sha":"d5e2afdeee9a48d2da763fc6e300723cb855b953"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194681","number":194681,"mergeCommit":{"message":"[ResponseOps][Cases]
Design Review changes PR 2 (elastic#194681)\n\n## Summary\r\n\r\nConnects to
elastic#188187 \r\n\r\n- the \"add
template\" button is now hidden once the user reaches the\r\nlimit of 10
templates and the message is displayed in a subdued color to\r\ninform
the user that the limit has been reached.\r\n\r\n![Screenshot 2024-10-03
at 13
47\r\n32](https://github.com/user-attachments/assets/42622eff-2582-41e6-9318-18126e477f12)\r\n\r\n-
same applies to custom fields\r\n\r\n![Screenshot 2024-10-03 at 13
52\r\n20](https://github.com/user-attachments/assets/b0f13235-4345-45f1-b772-0cc5ccc771bb)","sha":"d5e2afdeee9a48d2da763fc6e300723cb855b953"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Georgiana-Andreea Onoleață <[email protected]>
  • Loading branch information
kibanamachine and georgianaonoleata1904 authored Oct 7, 2024
1 parent a0e118d commit 0776378
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ describe('CustomFields', () => {
required: false,
});
}

const customFields = [...customFieldsConfigurationMock, ...generatedMockCustomFields];

appMockRender.render(<CustomFields {...{ ...props, customFields }} />);

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();
});
});
40 changes: 20 additions & 20 deletions x-pack/plugins/cases/public/components/custom_fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,9 @@ const CustomFieldsComponent: React.FC<Props> = ({
onDeleteCustomField={handleDeleteCustomField}
onEditCustomField={onEditCustomField}
/>
{error ? (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiText color="danger">
{i18n.MAX_CUSTOM_FIELD_LIMIT(MAX_CUSTOM_FIELDS_PER_CASE)}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
) : null}
</>
) : null}
<EuiSpacer size="m" />
<EuiSpacer size="s" />
{!customFields.length ? (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false} data-test-subj="empty-custom-fields">
Expand All @@ -102,18 +93,27 @@ const CustomFieldsComponent: React.FC<Props> = ({
) : null}
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
isLoading={isLoading}
isDisabled={disabled || error}
size="s"
onClick={onAddCustomField}
iconType="plusInCircle"
data-test-subj="add-custom-field"
>
{i18n.ADD_CUSTOM_FIELD}
</EuiButtonEmpty>
{customFields.length < MAX_CUSTOM_FIELDS_PER_CASE ? (
<EuiButtonEmpty
isLoading={isLoading}
isDisabled={disabled || error}
size="s"
onClick={onAddCustomField}
iconType="plusInCircle"
data-test-subj="add-custom-field"
>
{i18n.ADD_CUSTOM_FIELD}
</EuiButtonEmpty>
) : (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiText>{i18n.MAX_CUSTOM_FIELD_LIMIT(MAX_CUSTOM_FIELDS_PER_CASE)}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
)}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
</EuiPanel>
</EuiDescribedFormGroup>
) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ describe('Templates', () => {

appMockRender.render(<Templates {...{ ...props, templates: mockTemplates }} />);

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();
});
});
38 changes: 20 additions & 18 deletions x-pack/plugins/cases/public/components/templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,9 @@ const TemplatesComponent: React.FC<Props> = ({
onEditTemplate={handleEditTemplate}
onDeleteTemplate={handleDeleteTemplate}
/>
{error ? (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiText color="danger">{i18n.MAX_TEMPLATE_LIMIT(MAX_TEMPLATES_LENGTH)}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
) : null}
</>
) : null}
<EuiSpacer size="m" />
<EuiSpacer size="s" />
{!templates.length ? (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false} data-test-subj="empty-templates">
Expand All @@ -113,16 +106,25 @@ const TemplatesComponent: React.FC<Props> = ({
{canAddTemplates ? (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
isLoading={isLoading}
isDisabled={disabled || error}
size="s"
onClick={handleAddTemplate}
iconType="plusInCircle"
data-test-subj="add-template"
>
{i18n.ADD_TEMPLATE}
</EuiButtonEmpty>
{templates.length < MAX_TEMPLATES_LENGTH ? (
<EuiButtonEmpty
isLoading={isLoading}
isDisabled={disabled || error}
size="s"
onClick={handleAddTemplate}
iconType="plusInCircle"
data-test-subj="add-template"
>
{i18n.ADD_TEMPLATE}
</EuiButtonEmpty>
) : (
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiText>{i18n.MAX_TEMPLATE_LIMIT(MAX_TEMPLATES_LENGTH)}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
)}
<EuiSpacer size="s" />
</EuiFlexItem>
</EuiFlexGroup>
) : null}
Expand Down

0 comments on commit 0776378

Please sign in to comment.