Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Security Solution] ThreeWayDiff UI: Migrate to using `Dif…
…fableRule` TS type in `FieldReadOnly` component (#192342) (#193333) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] ThreeWayDiff UI: Migrate to using `DiffableRule` TS type in `FieldReadOnly` component (#192342)](#192342) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nikita Indik","email":"nikita.indik@elastic.co"},"sourceCommit":{"committedDate":"2024-09-18T16:21:00Z","message":"[Security Solution] ThreeWayDiff UI: Migrate to using `DiffableRule` TS type in `FieldReadOnly` component (#192342)\n\n**Partially addresses: https://github.com/elastic/kibana/issues/171520**\r\n**Is a follow-up PR to: https://github.com/elastic/kibana/pull/191499**\r\n\r\nThis is the 2nd of the 3 PRs for `FieldReadOnly`.\r\n- The 1st [PR](#191499) added the\r\n`FieldReadOnly` and a bunch of field components.\r\n- This (2nd) PR moves away from using `DiffableAllFields` type in favour\r\nof `DiffableRule` and splits the large `FieldReadOnly` component into\r\nsmaller ones for readability.\r\n - Next (3rd) PR will add the remaining field components.\r\n\r\n## Summary\r\nThis PR changes the TS type (`DiffableAllFields` -> `DiffableRule`) used\r\nby the `FieldReadOnly` component. This component displays a read-only\r\nview of a particular rule field, similar to how fields are shown on the\r\nRule Details page. Using `DiffableRule` type makes the component\r\ncompatible with the flyout context and is safer to use than\r\n`DiffableAllFields`.\r\n\r\n### Changes\r\n- TS type used in the `FieldReadOnly` component and Storybook stories\r\nchanged to `DiffableRule`.\r\n- `FieldReadOnly` field rendering was split into multiple files by rule\r\ntype to make it more readable.\r\n- Added rule-mocking functions to Storybook to allow creation of\r\n`DiffableRule` mocks.\r\n - Added field components for `name`, `description` and `tags` fields.\r\n- Rewrote type narrowing for `Filters` component to a type guard\r\n(`isFilters`).\r\n - Fixed a couple of outdated code comments.\r\n\r\n\r\n### Running\r\n`FinalReadOnly` and its field components are not yet integrated into the\r\nflyout, but you can view components in Storybook.\r\n1. Run Storybook: `yarn storybook security_solution`\r\n2. Go to `http://localhost:9001` in browser.\r\n\r\n<img width=\"1062\" alt=\"Schermafbeelding 2024-09-03 om 13 05 11\"\r\nsrc=\"https://github.com/user-attachments/assets/13b227d4-1321-47d9-a0a7-93868c9f4a15\">","sha":"70b7d263352a73569f2809bb0b4d1e2624b43b28","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Detections and Resp","Team: SecuritySolution","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","backport:prev-minor"],"title":"[Security Solution] ThreeWayDiff UI: Migrate to using `DiffableRule` TS type in `FieldReadOnly` component","number":192342,"url":"https://github.com/elastic/kibana/pull/192342","mergeCommit":{"message":"[Security Solution] ThreeWayDiff UI: Migrate to using `DiffableRule` TS type in `FieldReadOnly` component (#192342)\n\n**Partially addresses: https://github.com/elastic/kibana/issues/171520**\r\n**Is a follow-up PR to: https://github.com/elastic/kibana/pull/191499**\r\n\r\nThis is the 2nd of the 3 PRs for `FieldReadOnly`.\r\n- The 1st [PR](#191499) added the\r\n`FieldReadOnly` and a bunch of field components.\r\n- This (2nd) PR moves away from using `DiffableAllFields` type in favour\r\nof `DiffableRule` and splits the large `FieldReadOnly` component into\r\nsmaller ones for readability.\r\n - Next (3rd) PR will add the remaining field components.\r\n\r\n## Summary\r\nThis PR changes the TS type (`DiffableAllFields` -> `DiffableRule`) used\r\nby the `FieldReadOnly` component. This component displays a read-only\r\nview of a particular rule field, similar to how fields are shown on the\r\nRule Details page. Using `DiffableRule` type makes the component\r\ncompatible with the flyout context and is safer to use than\r\n`DiffableAllFields`.\r\n\r\n### Changes\r\n- TS type used in the `FieldReadOnly` component and Storybook stories\r\nchanged to `DiffableRule`.\r\n- `FieldReadOnly` field rendering was split into multiple files by rule\r\ntype to make it more readable.\r\n- Added rule-mocking functions to Storybook to allow creation of\r\n`DiffableRule` mocks.\r\n - Added field components for `name`, `description` and `tags` fields.\r\n- Rewrote type narrowing for `Filters` component to a type guard\r\n(`isFilters`).\r\n - Fixed a couple of outdated code comments.\r\n\r\n\r\n### Running\r\n`FinalReadOnly` and its field components are not yet integrated into the\r\nflyout, but you can view components in Storybook.\r\n1. Run Storybook: `yarn storybook security_solution`\r\n2. Go to `http://localhost:9001` in browser.\r\n\r\n<img width=\"1062\" alt=\"Schermafbeelding 2024-09-03 om 13 05 11\"\r\nsrc=\"https://github.com/user-attachments/assets/13b227d4-1321-47d9-a0a7-93868c9f4a15\">","sha":"70b7d263352a73569f2809bb0b4d1e2624b43b28"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192342","number":192342,"mergeCommit":{"message":"[Security Solution] ThreeWayDiff UI: Migrate to using `DiffableRule` TS type in `FieldReadOnly` component (#192342)\n\n**Partially addresses: https://github.com/elastic/kibana/issues/171520**\r\n**Is a follow-up PR to: https://github.com/elastic/kibana/pull/191499**\r\n\r\nThis is the 2nd of the 3 PRs for `FieldReadOnly`.\r\n- The 1st [PR](#191499) added the\r\n`FieldReadOnly` and a bunch of field components.\r\n- This (2nd) PR moves away from using `DiffableAllFields` type in favour\r\nof `DiffableRule` and splits the large `FieldReadOnly` component into\r\nsmaller ones for readability.\r\n - Next (3rd) PR will add the remaining field components.\r\n\r\n## Summary\r\nThis PR changes the TS type (`DiffableAllFields` -> `DiffableRule`) used\r\nby the `FieldReadOnly` component. This component displays a read-only\r\nview of a particular rule field, similar to how fields are shown on the\r\nRule Details page. Using `DiffableRule` type makes the component\r\ncompatible with the flyout context and is safer to use than\r\n`DiffableAllFields`.\r\n\r\n### Changes\r\n- TS type used in the `FieldReadOnly` component and Storybook stories\r\nchanged to `DiffableRule`.\r\n- `FieldReadOnly` field rendering was split into multiple files by rule\r\ntype to make it more readable.\r\n- Added rule-mocking functions to Storybook to allow creation of\r\n`DiffableRule` mocks.\r\n - Added field components for `name`, `description` and `tags` fields.\r\n- Rewrote type narrowing for `Filters` component to a type guard\r\n(`isFilters`).\r\n - Fixed a couple of outdated code comments.\r\n\r\n\r\n### Running\r\n`FinalReadOnly` and its field components are not yet integrated into the\r\nflyout, but you can view components in Storybook.\r\n1. Run Storybook: `yarn storybook security_solution`\r\n2. Go to `http://localhost:9001` in browser.\r\n\r\n<img width=\"1062\" alt=\"Schermafbeelding 2024-09-03 om 13 05 11\"\r\nsrc=\"https://github.com/user-attachments/assets/13b227d4-1321-47d9-a0a7-93868c9f4a15\">","sha":"70b7d263352a73569f2809bb0b4d1e2624b43b28"}}]}] BACKPORT--> Co-authored-by: Nikita Indik <nikita.indik@elastic.co>
- Loading branch information