Skip to content

Commit

Permalink
[8.x] [Secuity Solution][DQD] add historical results (Phase 1) (#191898
Browse files Browse the repository at this point in the history
…) (#195962)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Secuity Solution][DQD] add historical results (Phase 1)
(#191898)](#191898)

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

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

<!--BACKPORT [{"author":{"name":"Karen
Grigoryan","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-11T16:14:11Z","message":"[Secuity
Solution][DQD] add historical results (Phase 1) (#191898)\n\naddresses
#185882 \r\n\r\nleverages changes introduced
in\r\nhttps://github.com//pull/188468\r\n\r\n# Data
Quality Dashboard Historical Results (Phase 1)\r\n\r\nThis PR introduces
new functionality to the Data Quality Dashboard\r\n\r\nHistory tab
(new):\r\n- view last 30 days of check results by default:\r\n- filter
by historical checks by outcome (PASS/FAIL/ALL)\r\n- paginate all
results (10 per page by default)\r\n- each result can be viewed in
individually and independently\r\nexpandable/collapsible accordion panel
(collapsed by default)\r\n- each result contains an extended index stats
panel with (custom, ecs\r\nand all fields counts)\r\n- each result
contains index properties tabs (incompatible and same\r\nfamily)\r\n-
check now checks and redirects to latest check tab with latest
check\r\ninfo\r\n- switching from initial historical tab to latest check
tab triggers\r\nlatest check\r\n- subsequent switching back and forth
between already open history or\r\nlatest check tabs doesn't trigger a
check\r\n- legacy data (before release of
this\r\nhttps://github.com//pull/185025) is supported
with\r\ndegraded view (same family tab is disabled with warning
tooltip),\r\nincompatible tab tables are statically rendered from
markdown\r\n\r\nLatest checks list view (changes):\r\n- remove check
index button icon from list view\r\n- add historical results button icon
instead of check index button\r\n- historical results button icon
directly opens history tab without\r\ngoing through latest
check\r\n\r\n# UI Changes (before/after):\r\n\r\n## ESS
Changes\r\n\r\n### Latest check expand icon\r\n- expand icon is replaced
with check now icon (functionality is the\r\nsame)\r\n- tooltip text is
updated\r\n- this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![ess_before_after_0](https://github.com/user-attachments/assets/795af721-6867-4f56-882e-2a0f52793560)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![ess_before_after_1](https://github.com/user-attachments/assets/7f2c6009-35c3-488c-87ac-3048f4bded7b)\r\n\r\n###
Flyout Header\r\n- \"checked at\" subheader is now shorter (milliseconds
are removed)\r\n- Tabline with Latest check and History tabs is added
**(NEW)**\r\n\r\n![ess_before_after_2](https://github.com/user-attachments/assets/728ff743-500e-435a-a07e-4287647a0af5)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![ess_after_3](https://github.com/user-attachments/assets/36fc0cee-b103-483d-ba79-d583bba89acf)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all
fields\".\r\n- incompatible fields and same family fields view (custom,
ecs compliant\r\nand all fields view is unavailable in history
tab)\r\n\r\n![ess_after_4](https://github.com/user-attachments/assets/57e6d5a1-1470-4c4b-9272-ccc872d80dc5)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lmcu](https://github.com/user-attachments/assets/cd11435e-7335-40f3-a0b8-4e5c6bcc2f38)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-llzw](https://github.com/user-attachments/assets/a942ce8e-6e0e-46d3-9104-c30648a18208)\r\n\r\n###
Loading
view\r\n\r\n![ess_after_8](https://github.com/user-attachments/assets/1411ccc2-4978-41f6-a02d-2ca404a01c16)\r\n\r\n###
Error
view\r\n\r\n![ess_after_9](https://github.com/user-attachments/assets/adc80e19-0005-46f9-a667-ffd3bf8ecb4f)\r\n\r\n##
Serverless Changes\r\n### Empty checks result badge **(FIX)**\r\n-
**previously empty pattern check result badge was marked as
`PASS`\r\nwhich was incorrect. It was
removed.**\r\n\r\n![serverless_before_after_0](https://github.com/user-attachments/assets/67e02e9c-cd7f-46d7-9b7a-9bdaa0abfc6c)\r\n\r\n###
Latest check expand icon\r\n- expand icon is replaced with check now
icon (functionality is the\r\nsame)\r\n- tooltip text is updated\r\n-
this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![serverless_before_after_1](https://github.com/user-attachments/assets/dfac9aad-158b-4863-b719-47d50b06bda3)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![serverless_before_after_2](https://github.com/user-attachments/assets/c688c28c-2d86-4669-a9bb-ffc297d21bbf)\r\n\r\n###
Flyout Header and Body Topline\r\n- \"checked at\" subheader is now
shorter (milliseconds are removed)\r\n- Tabline with Latest check and
History tabs is added **(NEW)**\r\n- **Index Stats Panel is now also
showing here just like in latest check\r\ntab (but without phase label
as ilm is not available in
serverless)**\r\n**(NEW)**\r\n\r\n![serverless_before_after_3](https://github.com/user-attachments/assets/c3ae4160-d07c-4049-b8b4-4b66faa50320)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![serverless_after_4](https://github.com/user-attachments/assets/8b767de3-1ab1-4b9f-b0b8-84754a3776ae)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all fields\"
but **excluding ilm phase label section**.\r\n- incompatible fields and
same family fields view (custom, ecs compliant\r\nand all fields view is
unavailable in history
tab)\r\n\r\n![serverless_after_5](https://github.com/user-attachments/assets/d8fdd48f-63f2-48f2-8ede-3613bffaa157)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lkhi](https://github.com/user-attachments/assets/10adee1c-c11a-428a-9c56-ecc20a37f97f)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-ljwg](https://github.com/user-attachments/assets/8bf48778-98d6-4a96-a713-b49d4cc5165a)\r\n\r\n###
Loading
view\r\n\r\n![serverless_after_9](https://github.com/user-attachments/assets/5ba1f2cc-cbd9-4cfa-964c-962be150016f)\r\n\r\n###
Error
view\r\n\r\n![serverless_after_10](https://github.com/user-attachments/assets/b5c33ded-4ee5-46ff-9e13-f9e5dfc7546e)","sha":"e5f7739b263902bd01aca9fa902be7cc5181e855","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","Team:Threat
Hunting","release_note:feature","Team:Threat
Hunting:Explore","backport:prev-minor","ci:cloud-deploy","ci:cloud-redeploy","ci:cloud-persist-deployment","ci:build-serverless-image","ci:project-deploy-security","ci:project-persist-deployment","ci:project-redeploy","v8.16.0"],"title":"[Secuity
Solution][DQD] add historical results (Phase 1)
","number":191898,"url":"https://github.com/elastic/kibana/pull/191898","mergeCommit":{"message":"[Secuity
Solution][DQD] add historical results (Phase 1) (#191898)\n\naddresses
#185882 \r\n\r\nleverages changes introduced
in\r\nhttps://github.com//pull/188468\r\n\r\n# Data
Quality Dashboard Historical Results (Phase 1)\r\n\r\nThis PR introduces
new functionality to the Data Quality Dashboard\r\n\r\nHistory tab
(new):\r\n- view last 30 days of check results by default:\r\n- filter
by historical checks by outcome (PASS/FAIL/ALL)\r\n- paginate all
results (10 per page by default)\r\n- each result can be viewed in
individually and independently\r\nexpandable/collapsible accordion panel
(collapsed by default)\r\n- each result contains an extended index stats
panel with (custom, ecs\r\nand all fields counts)\r\n- each result
contains index properties tabs (incompatible and same\r\nfamily)\r\n-
check now checks and redirects to latest check tab with latest
check\r\ninfo\r\n- switching from initial historical tab to latest check
tab triggers\r\nlatest check\r\n- subsequent switching back and forth
between already open history or\r\nlatest check tabs doesn't trigger a
check\r\n- legacy data (before release of
this\r\nhttps://github.com//pull/185025) is supported
with\r\ndegraded view (same family tab is disabled with warning
tooltip),\r\nincompatible tab tables are statically rendered from
markdown\r\n\r\nLatest checks list view (changes):\r\n- remove check
index button icon from list view\r\n- add historical results button icon
instead of check index button\r\n- historical results button icon
directly opens history tab without\r\ngoing through latest
check\r\n\r\n# UI Changes (before/after):\r\n\r\n## ESS
Changes\r\n\r\n### Latest check expand icon\r\n- expand icon is replaced
with check now icon (functionality is the\r\nsame)\r\n- tooltip text is
updated\r\n- this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![ess_before_after_0](https://github.com/user-attachments/assets/795af721-6867-4f56-882e-2a0f52793560)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![ess_before_after_1](https://github.com/user-attachments/assets/7f2c6009-35c3-488c-87ac-3048f4bded7b)\r\n\r\n###
Flyout Header\r\n- \"checked at\" subheader is now shorter (milliseconds
are removed)\r\n- Tabline with Latest check and History tabs is added
**(NEW)**\r\n\r\n![ess_before_after_2](https://github.com/user-attachments/assets/728ff743-500e-435a-a07e-4287647a0af5)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![ess_after_3](https://github.com/user-attachments/assets/36fc0cee-b103-483d-ba79-d583bba89acf)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all
fields\".\r\n- incompatible fields and same family fields view (custom,
ecs compliant\r\nand all fields view is unavailable in history
tab)\r\n\r\n![ess_after_4](https://github.com/user-attachments/assets/57e6d5a1-1470-4c4b-9272-ccc872d80dc5)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lmcu](https://github.com/user-attachments/assets/cd11435e-7335-40f3-a0b8-4e5c6bcc2f38)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-llzw](https://github.com/user-attachments/assets/a942ce8e-6e0e-46d3-9104-c30648a18208)\r\n\r\n###
Loading
view\r\n\r\n![ess_after_8](https://github.com/user-attachments/assets/1411ccc2-4978-41f6-a02d-2ca404a01c16)\r\n\r\n###
Error
view\r\n\r\n![ess_after_9](https://github.com/user-attachments/assets/adc80e19-0005-46f9-a667-ffd3bf8ecb4f)\r\n\r\n##
Serverless Changes\r\n### Empty checks result badge **(FIX)**\r\n-
**previously empty pattern check result badge was marked as
`PASS`\r\nwhich was incorrect. It was
removed.**\r\n\r\n![serverless_before_after_0](https://github.com/user-attachments/assets/67e02e9c-cd7f-46d7-9b7a-9bdaa0abfc6c)\r\n\r\n###
Latest check expand icon\r\n- expand icon is replaced with check now
icon (functionality is the\r\nsame)\r\n- tooltip text is updated\r\n-
this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![serverless_before_after_1](https://github.com/user-attachments/assets/dfac9aad-158b-4863-b719-47d50b06bda3)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![serverless_before_after_2](https://github.com/user-attachments/assets/c688c28c-2d86-4669-a9bb-ffc297d21bbf)\r\n\r\n###
Flyout Header and Body Topline\r\n- \"checked at\" subheader is now
shorter (milliseconds are removed)\r\n- Tabline with Latest check and
History tabs is added **(NEW)**\r\n- **Index Stats Panel is now also
showing here just like in latest check\r\ntab (but without phase label
as ilm is not available in
serverless)**\r\n**(NEW)**\r\n\r\n![serverless_before_after_3](https://github.com/user-attachments/assets/c3ae4160-d07c-4049-b8b4-4b66faa50320)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![serverless_after_4](https://github.com/user-attachments/assets/8b767de3-1ab1-4b9f-b0b8-84754a3776ae)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all fields\"
but **excluding ilm phase label section**.\r\n- incompatible fields and
same family fields view (custom, ecs compliant\r\nand all fields view is
unavailable in history
tab)\r\n\r\n![serverless_after_5](https://github.com/user-attachments/assets/d8fdd48f-63f2-48f2-8ede-3613bffaa157)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lkhi](https://github.com/user-attachments/assets/10adee1c-c11a-428a-9c56-ecc20a37f97f)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-ljwg](https://github.com/user-attachments/assets/8bf48778-98d6-4a96-a713-b49d4cc5165a)\r\n\r\n###
Loading
view\r\n\r\n![serverless_after_9](https://github.com/user-attachments/assets/5ba1f2cc-cbd9-4cfa-964c-962be150016f)\r\n\r\n###
Error
view\r\n\r\n![serverless_after_10](https://github.com/user-attachments/assets/b5c33ded-4ee5-46ff-9e13-f9e5dfc7546e)","sha":"e5f7739b263902bd01aca9fa902be7cc5181e855"}},"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/191898","number":191898,"mergeCommit":{"message":"[Secuity
Solution][DQD] add historical results (Phase 1) (#191898)\n\naddresses
#185882 \r\n\r\nleverages changes introduced
in\r\nhttps://github.com//pull/188468\r\n\r\n# Data
Quality Dashboard Historical Results (Phase 1)\r\n\r\nThis PR introduces
new functionality to the Data Quality Dashboard\r\n\r\nHistory tab
(new):\r\n- view last 30 days of check results by default:\r\n- filter
by historical checks by outcome (PASS/FAIL/ALL)\r\n- paginate all
results (10 per page by default)\r\n- each result can be viewed in
individually and independently\r\nexpandable/collapsible accordion panel
(collapsed by default)\r\n- each result contains an extended index stats
panel with (custom, ecs\r\nand all fields counts)\r\n- each result
contains index properties tabs (incompatible and same\r\nfamily)\r\n-
check now checks and redirects to latest check tab with latest
check\r\ninfo\r\n- switching from initial historical tab to latest check
tab triggers\r\nlatest check\r\n- subsequent switching back and forth
between already open history or\r\nlatest check tabs doesn't trigger a
check\r\n- legacy data (before release of
this\r\nhttps://github.com//pull/185025) is supported
with\r\ndegraded view (same family tab is disabled with warning
tooltip),\r\nincompatible tab tables are statically rendered from
markdown\r\n\r\nLatest checks list view (changes):\r\n- remove check
index button icon from list view\r\n- add historical results button icon
instead of check index button\r\n- historical results button icon
directly opens history tab without\r\ngoing through latest
check\r\n\r\n# UI Changes (before/after):\r\n\r\n## ESS
Changes\r\n\r\n### Latest check expand icon\r\n- expand icon is replaced
with check now icon (functionality is the\r\nsame)\r\n- tooltip text is
updated\r\n- this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![ess_before_after_0](https://github.com/user-attachments/assets/795af721-6867-4f56-882e-2a0f52793560)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![ess_before_after_1](https://github.com/user-attachments/assets/7f2c6009-35c3-488c-87ac-3048f4bded7b)\r\n\r\n###
Flyout Header\r\n- \"checked at\" subheader is now shorter (milliseconds
are removed)\r\n- Tabline with Latest check and History tabs is added
**(NEW)**\r\n\r\n![ess_before_after_2](https://github.com/user-attachments/assets/728ff743-500e-435a-a07e-4287647a0af5)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![ess_after_3](https://github.com/user-attachments/assets/36fc0cee-b103-483d-ba79-d583bba89acf)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all
fields\".\r\n- incompatible fields and same family fields view (custom,
ecs compliant\r\nand all fields view is unavailable in history
tab)\r\n\r\n![ess_after_4](https://github.com/user-attachments/assets/57e6d5a1-1470-4c4b-9272-ccc872d80dc5)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lmcu](https://github.com/user-attachments/assets/cd11435e-7335-40f3-a0b8-4e5c6bcc2f38)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-llzw](https://github.com/user-attachments/assets/a942ce8e-6e0e-46d3-9104-c30648a18208)\r\n\r\n###
Loading
view\r\n\r\n![ess_after_8](https://github.com/user-attachments/assets/1411ccc2-4978-41f6-a02d-2ca404a01c16)\r\n\r\n###
Error
view\r\n\r\n![ess_after_9](https://github.com/user-attachments/assets/adc80e19-0005-46f9-a667-ffd3bf8ecb4f)\r\n\r\n##
Serverless Changes\r\n### Empty checks result badge **(FIX)**\r\n-
**previously empty pattern check result badge was marked as
`PASS`\r\nwhich was incorrect. It was
removed.**\r\n\r\n![serverless_before_after_0](https://github.com/user-attachments/assets/67e02e9c-cd7f-46d7-9b7a-9bdaa0abfc6c)\r\n\r\n###
Latest check expand icon\r\n- expand icon is replaced with check now
icon (functionality is the\r\nsame)\r\n- tooltip text is updated\r\n-
this new icon is still opening the index check flyout tab
(latest\r\ncheck
tab)\r\n\r\n![serverless_before_after_1](https://github.com/user-attachments/assets/dfac9aad-158b-4863-b719-47d50b06bda3)\r\n\r\n###
Historical check icon **(NEW)**\r\n- inline check now functionality is
removed\r\n- view history icon is added in its stead to open a flyout
with history\r\ntab\r\n- tooltip text is
updated\r\n\r\n![serverless_before_after_2](https://github.com/user-attachments/assets/c688c28c-2d86-4669-a9bb-ffc297d21bbf)\r\n\r\n###
Flyout Header and Body Topline\r\n- \"checked at\" subheader is now
shorter (milliseconds are removed)\r\n- Tabline with Latest check and
History tabs is added **(NEW)**\r\n- **Index Stats Panel is now also
showing here just like in latest check\r\ntab (but without phase label
as ilm is not available in
serverless)**\r\n**(NEW)**\r\n\r\n![serverless_before_after_3](https://github.com/user-attachments/assets/c3ae4160-d07c-4049-b8b4-4b66faa50320)\r\n\r\n###
History tab **(NEW)**\r\n- top left: filter by check outcome\r\n- top
right: filter by date range\r\n- list of checks collapsed by default
(individually separately\r\ncontrolled, multiple can be open at a
time)\r\n- pagination (10,25,50). 10 by
default\r\n\r\n![serverless_after_4](https://github.com/user-attachments/assets/8b767de3-1ab1-4b9f-b0b8-84754a3776ae)\r\n\r\n###
Individual check result view **(NEW)**\r\n- topline: extended index
stats including new \"custom\", \"ecs compliant\"\r\n& \"all fields\"
but **excluding ilm phase label section**.\r\n- incompatible fields and
same family fields view (custom, ecs compliant\r\nand all fields view is
unavailable in history
tab)\r\n\r\n![serverless_after_5](https://github.com/user-attachments/assets/d8fdd48f-63f2-48f2-8ede-3613bffaa157)\r\n\r\n###
Legacy check result view **(NEW)**\r\n- before this PR went to
production\r\nhttps://github.com//pull/185025 check result
data\r\ncontained information allowing to recreate detailed view of
incompatible\r\nfields from markdown only (without same family
fields)\r\n- we recreate incompatible field tables in degraded view from
markdown\r\n- same family tab is permanently disabled with an
explanation tooltip\r\n- action buttons still work as is for
incompatible fields view\r\n- index stats panel is showing as for
non-legacy
result\r\n\r\n![SCR-20241009-lkhi](https://github.com/user-attachments/assets/10adee1c-c11a-428a-9c56-ecc20a37f97f)\r\n\r\n###
No
results\r\n\r\n![SCR-20241009-ljwg](https://github.com/user-attachments/assets/8bf48778-98d6-4a96-a713-b49d4cc5165a)\r\n\r\n###
Loading
view\r\n\r\n![serverless_after_9](https://github.com/user-attachments/assets/5ba1f2cc-cbd9-4cfa-964c-962be150016f)\r\n\r\n###
Error
view\r\n\r\n![serverless_after_10](https://github.com/user-attachments/assets/b5c33ded-4ee5-46ff-9e13-f9e5dfc7546e)","sha":"e5f7739b263902bd01aca9fa902be7cc5181e855"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Karen Grigoryan <[email protected]>
  • Loading branch information
kibanamachine and kapral18 authored Oct 11, 2024
1 parent 4382f64 commit 3926570
Show file tree
Hide file tree
Showing 194 changed files with 10,022 additions and 5,057 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
*/

export const MIN_PAGE_SIZE = 10;

export const HISTORY_TAB_ID = 'history';
export const LATEST_CHECK_TAB_ID = 'latest_check';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { createContext, useContext } from 'react';
import { HistoricalResultsValue } from './types';

export const HistoricalResultsContext = createContext<HistoricalResultsValue | null>(null);

export const useHistoricalResultsContext = () => {
const context = useContext(HistoricalResultsContext);
if (context == null) {
throw new Error(
'useHistoricalResultsContext must be used inside the HistoricalResultsContextProvider.'
);
}
return context;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { HistoricalResult } from '../../../../../types';
import { UseHistoricalResultsFetch } from '../../index_check_flyout/types';

export interface HistoricalResultsValue {
historicalResultsState: {
results: HistoricalResult[];
total: number;
isLoading: boolean;
error: Error | null;
};
fetchHistoricalResults: UseHistoricalResultsFetch;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
* 2.0.
*/

export const ALL_TAB_ID = 'allTab';
export const ECS_COMPLIANT_TAB_ID = 'ecsCompliantTab';
export const CUSTOM_TAB_ID = 'customTab';
export const INCOMPATIBLE_TAB_ID = 'incompatibleTab';
export const SAME_FAMILY_TAB_ID = 'sameFamilyTab';
export const GET_INDEX_RESULTS = '/internal/ecs_data_quality_dashboard/results/{indexName}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { act, renderHook } from '@testing-library/react-hooks';

import { mockHistoricalResult } from '../../../../../mock/historical_results/mock_historical_results_response';
import { TestDataQualityProviders } from '../../../../../mock/test_providers/test_providers';
import * as fetchHistoricalResults from './utils/fetch_historical_results';
import { useHistoricalResults } from '.';

describe('useHistoricalResults', () => {
beforeEach(() => {
jest.restoreAllMocks();
});

it('should return initial historical results state and fetch historical results function', () => {
const { result } = renderHook(() => useHistoricalResults(), {
wrapper: TestDataQualityProviders,
});

expect(result.current.historicalResultsState).toEqual({
results: [],
total: 0,
isLoading: true,
error: null,
});

expect(result.current.fetchHistoricalResults).toBeInstanceOf(Function);
});

describe('when fetchHistoricalResults is called', () => {
it('should fetch historical results and update historical results state', async () => {
const fetchResultsSpy = jest
.spyOn(fetchHistoricalResults, 'fetchHistoricalResults')
.mockResolvedValue({
results: [mockHistoricalResult],
total: 1,
});

const { result } = renderHook(() => useHistoricalResults(), {
wrapper: TestDataQualityProviders,
});

const abortController = new AbortController();

await act(() =>
result.current.fetchHistoricalResults({
abortController,
indexName: 'indexName',
size: 10,
from: 0,
startDate: 'now-7d',
endDate: 'now',
outcome: 'pass',
})
);

expect(fetchResultsSpy).toHaveBeenCalledWith({
indexName: 'indexName',
httpFetch: expect.any(Function),
abortController,
size: 10,
from: 0,
startDate: 'now-7d',
endDate: 'now',
outcome: 'pass',
});

expect(result.current.historicalResultsState).toEqual({
results: [mockHistoricalResult],
total: 1,
isLoading: false,
error: null,
});
});
});

describe('when fetchHistoricalResults fails', () => {
it('should update historical results state with error', async () => {
const fetchResultsSpy = jest
.spyOn(fetchHistoricalResults, 'fetchHistoricalResults')
.mockRejectedValue(new Error('An error occurred'));

const { result } = renderHook(() => useHistoricalResults(), {
wrapper: TestDataQualityProviders,
});

const abortController = new AbortController();

await act(() =>
result.current.fetchHistoricalResults({
abortController,
indexName: 'indexName',
size: 10,
from: 0,
startDate: 'now-7d',
endDate: 'now',
outcome: 'pass',
})
);

expect(fetchResultsSpy).toHaveBeenCalledWith({
indexName: 'indexName',
httpFetch: expect.any(Function),
abortController,
size: 10,
from: 0,
startDate: 'now-7d',
endDate: 'now',
outcome: 'pass',
});

expect(result.current.historicalResultsState).toEqual({
results: [],
total: 0,
isLoading: false,
error: new Error('An error occurred'),
});
});
});

describe('during fetchHistoricalResults call', () => {
it('should set isLoading to true', async () => {
jest.spyOn(fetchHistoricalResults, 'fetchHistoricalResults').mockImplementation(() => {
return new Promise(() => {});
});

const { result } = renderHook(() => useHistoricalResults(), {
wrapper: TestDataQualityProviders,
});

const abortController = new AbortController();

act(() => {
result.current.fetchHistoricalResults({
abortController,
indexName: 'indexName',
size: 10,
from: 0,
startDate: 'now-7d',
endDate: 'now',
outcome: 'pass',
});
});

expect(result.current.historicalResultsState).toEqual({
results: [],
total: 0,
isLoading: true,
error: null,
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { useReducer, useCallback } from 'react';

import { GET_RESULTS_ERROR_TITLE } from '../../../../../translations';
import { useDataQualityContext } from '../../../../../data_quality_context';
import { useIsMountedRef } from '../../../../../hooks/use_is_mounted_ref';
import { fetchHistoricalResults } from './utils/fetch_historical_results';
import { FetchHistoricalResultsReducerState, UseHistoricalResultsReturnValue } from './types';
import { UseHistoricalResultsFetchOpts } from '../../index_check_flyout/types';
import { fetchHistoricalResultsReducer } from './reducers/fetch_historical_results_reducer';

export const initialFetchHistoricalResultsReducerState: FetchHistoricalResultsReducerState = {
results: [],
total: 0,
isLoading: true,
error: null,
};

export const useHistoricalResults = (): UseHistoricalResultsReturnValue => {
const [state, dispatch] = useReducer(
fetchHistoricalResultsReducer,
initialFetchHistoricalResultsReducerState
);
const { httpFetch, toasts } = useDataQualityContext();
const { isMountedRef } = useIsMountedRef();

const fetchResults = useCallback(
async ({
abortController,
indexName,
size,
from,
startDate,
endDate,
outcome,
}: UseHistoricalResultsFetchOpts) => {
dispatch({ type: 'FETCH_START' });

try {
const { results, total } = await fetchHistoricalResults({
indexName,
httpFetch,
abortController,
size,
from,
startDate,
endDate,
outcome,
});

if (isMountedRef.current) {
dispatch({
type: 'FETCH_SUCCESS',
payload: {
results,
total,
},
});
}
} catch (error) {
if (isMountedRef.current) {
toasts.addError(error, { title: GET_RESULTS_ERROR_TITLE });
dispatch({ type: 'FETCH_ERROR', payload: error });
}
}
},
[dispatch, httpFetch, toasts, isMountedRef]
);

return {
historicalResultsState: {
results: state.results,
total: state.total,
isLoading: state.isLoading,
error: state.error,
},
fetchHistoricalResults: fetchResults,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { mockHistoricalResult } from '../../../../../../mock/historical_results/mock_historical_results_response';
import { fetchHistoricalResultsReducer } from './fetch_historical_results_reducer';

const getInitialState = () => ({
results: [],
total: 0,
isLoading: true,
error: null,
});

describe('fetchHistoricalResultsReducer', () => {
describe('on fetch start', () => {
it('should return initial state', () => {
expect(fetchHistoricalResultsReducer(getInitialState(), { type: 'FETCH_START' })).toEqual({
results: [],
total: 0,
isLoading: true,
error: null,
});
});
});

describe('on fetch success', () => {
it('should update state with fetched results', () => {
const results = [mockHistoricalResult];
const total = 1;

expect(
fetchHistoricalResultsReducer(getInitialState(), {
type: 'FETCH_SUCCESS',
payload: { results, total },
})
).toEqual({
results,
total,
isLoading: false,
error: null,
});
});
});

describe('on fetch error', () => {
it('should update state with error', () => {
const error = new Error('An error occurred');

expect(
fetchHistoricalResultsReducer(getInitialState(), {
type: 'FETCH_ERROR',
payload: error,
})
).toEqual({
results: [],
total: 0,
isLoading: false,
error,
});
});
});
});
Loading

0 comments on commit 3926570

Please sign in to comment.