diff --git a/cypress/fixtures/api/insights-results-aggregator/v2/workloads.json b/cypress/fixtures/api/insights-results-aggregator/v2/workloads.json new file mode 100644 index 00000000..7d9e49ff --- /dev/null +++ b/cypress/fixtures/api/insights-results-aggregator/v2/workloads.json @@ -0,0 +1,876 @@ +[ + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000006", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000006" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 1, + "objects": 100, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 1, + "2": 3, + "3": 4, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "17a2e369-e96b-436e-924a-afa055280e44", + "name": "Namespace name 17a2e369-e96b-436e-924a-afa055280e44" + }, + "metadata": { + "recommendations": 1, + "objects": 1, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 2, + "3": 3, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "76f364f4-4369-4a18-96c3-0aaf07aa16f1", + "name": "Namespace name 76f364f4-4369-4a18-96c3-0aaf07aa16f1" + }, + "metadata": { + "recommendations": 3, + "objects": 3, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 3, + "hits_by_severity": { + "1": 0, + "2": 1, + "3": 2, + "4": 0 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "70aba366-f6a4-4d6a-9109-57e1ab867b08", + "name": "Namespace name 70aba366-f6a4-4d6a-9109-57e1ab867b08" + }, + "metadata": { + "recommendations": 4, + "objects": 24, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 3, + "hits_by_severity": { + "1": 4, + "2": 0, + "3": 5, + "4": 0 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "ea8bde67-d544-46aa-9f53-705060649e75", + "name": "Namespace name ea8bde67-d544-46aa-9f53-705060649e75" + }, + "metadata": { + "recommendations": 2, + "objects": 4, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 5, + "2": 2, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "e4a6778e-f75c-477c-8370-234b398277ca", + "name": "Namespace name e4a6778e-f75c-477c-8370-234b398277ca" + }, + "metadata": { + "recommendations": 3, + "objects": 3, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 2, + "hits_by_severity": { + "1": 5, + "2": 1, + "3": 0, + "4": 0 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 4, + "objects": 1536, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 1, + "2": 0, + "3": 3, + "4": 3 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "d00b47da-fc6f-4c72-abc1-94f525441c75", + "name": "Namespace name d00b47da-fc6f-4c72-abc1-94f525441c75" + }, + "metadata": { + "recommendations": 6, + "objects": 6, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 2, + "2": 0, + "3": 3, + "4": 6 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "0fab74ee-61ce-498d-bcd4-070ad950b0d7", + "name": "Namespace name 0fab74ee-61ce-498d-bcd4-070ad950b0d7" + }, + "metadata": { + "recommendations": 4, + "objects": 8, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 1, + "hits_by_severity": { + "1": 1, + "2": 0, + "3": 0, + "4": 0 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "4b2adb7d-490d-48ca-ba28-1c22c8924c29", + "name": "Namespace name 4b2adb7d-490d-48ca-ba28-1c22c8924c29" + }, + "metadata": { + "recommendations": 6, + "objects": 8, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 2, + "hits_by_severity": { + "1": 0, + "2": 2, + "3": 0, + "4": 0 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "7eb1d18b-701b-4f51-aea0-5f235daf1e07", + "name": "Namespace name 7eb1d18b-701b-4f51-aea0-5f235daf1e07" + }, + "metadata": { + "recommendations": 4, + "objects": 16, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 4 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "8bd032ea-243c-43f8-b9f8-7bba1ab723ee", + "name": "Namespace name 8bd032ea-243c-43f8-b9f8-7bba1ab723ee" + }, + "metadata": { + "recommendations": 4, + "objects": 458, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 4 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f", + "name": "Namespace name fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f" + }, + "metadata": { + "recommendations": 5, + "objects": 7, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 5 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "e6ed9bb3-efc3-46a6-b3ae-3f1a6e59546c", + "name": "Namespace name e6ed9bb3-efc3-46a6-b3ae-3f1a6e59546c" + }, + "metadata": { + "recommendations": 7, + "objects": 11, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 7 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "4354a80c-a7a6-405b-bfa6-9666b24e3b48", + "name": "Namespace name 4354a80c-a7a6-405b-bfa6-9666b24e3b48" + }, + "metadata": { + "recommendations": 4, + "objects": 28, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 4 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "3f32904e-037d-4449-b57c-32a7b0134aeb", + "name": "Namespace name 3f32904e-037d-4449-b57c-32a7b0134aeb" + }, + "metadata": { + "recommendations": 4, + "objects": 444, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 4 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000001", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000001" + }, + "namespace": { + "uuid": "a6c13355-60b6-42fb-9120-5819d9a0f5ad", + "name": "Namespace name a6c13355-60b6-42fb-9120-5819d9a0f5ad" + }, + "metadata": { + "recommendations": 2, + "objects": 10, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 2 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "e4a6778e-f75c-477c-8370-234b398277ca", + "name": "Namespace name e4a6778e-f75c-477c-8370-234b398277ca" + }, + "metadata": { + "recommendations": 1, + "objects": 1, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "e6ed9bb3-efc3-46a6-b3ae-3f1a6e59546c", + "name": "Namespace name e6ed9bb3-efc3-46a6-b3ae-3f1a6e59546c" + }, + "metadata": { + "recommendations": 3, + "objects": 5, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 3 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "3f32904e-037d-4449-b57c-32a7b0134aeb", + "name": "Namespace name 3f32904e-037d-4449-b57c-32a7b0134aeb" + }, + "metadata": { + "recommendations": 1, + "objects": 55, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 1, + "objects": 2, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "4354a80c-a7a6-405b-bfa6-9666b24e3b48", + "name": "Namespace name 4354a80c-a7a6-405b-bfa6-9666b24e3b48" + }, + "metadata": { + "recommendations": 1, + "objects": 7, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "70aba366-f6a4-4d6a-9109-57e1ab867b08", + "name": "Namespace name 70aba366-f6a4-4d6a-9109-57e1ab867b08" + }, + "metadata": { + "recommendations": 1, + "objects": 6, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "4b2adb7d-490d-48ca-ba28-1c22c8924c29", + "name": "Namespace name 4b2adb7d-490d-48ca-ba28-1c22c8924c29" + }, + "metadata": { + "recommendations": 1, + "objects": 1, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "8bd032ea-243c-43f8-b9f8-7bba1ab723ee", + "name": "Namespace name 8bd032ea-243c-43f8-b9f8-7bba1ab723ee" + }, + "metadata": { + "recommendations": 1, + "objects": 3, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "ea8bde67-d544-46aa-9f53-705060649e75", + "name": "Namespace name ea8bde67-d544-46aa-9f53-705060649e75" + }, + "metadata": { + "recommendations": 1, + "objects": 2, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f", + "name": "Namespace name fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f" + }, + "metadata": { + "recommendations": 2, + "objects": 3, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 2 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "7eb1d18b-701b-4f51-aea0-5f235daf1e07", + "name": "Namespace name 7eb1d18b-701b-4f51-aea0-5f235daf1e07" + }, + "metadata": { + "recommendations": 1, + "objects": 4, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "17a2e369-e96b-436e-924a-afa055280e44", + "name": "Namespace name 17a2e369-e96b-436e-924a-afa055280e44" + }, + "metadata": { + "recommendations": 1, + "objects": 1, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "d00b47da-fc6f-4c72-abc1-94f525441c75", + "name": "Namespace name d00b47da-fc6f-4c72-abc1-94f525441c75" + }, + "metadata": { + "recommendations": 3, + "objects": 3, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 3 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "0fab74ee-61ce-498d-bcd4-070ad950b0d7", + "name": "Namespace name 0fab74ee-61ce-498d-bcd4-070ad950b0d7" + }, + "metadata": { + "recommendations": 1, + "objects": 2, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000002", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000002" + }, + "namespace": { + "uuid": "a6c13355-60b6-42fb-9120-5819d9a0f5ad", + "name": "Namespace name a6c13355-60b6-42fb-9120-5819d9a0f5ad" + }, + "metadata": { + "recommendations": 1, + "objects": 5, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000003", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000003" + }, + "namespace": { + "uuid": "3f32904e-037d-4449-b57c-32a7b0134aeb", + "name": "Namespace name 3f32904e-037d-4449-b57c-32a7b0134aeb" + }, + "metadata": { + "recommendations": 1, + "objects": 57, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000003", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000003" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 1, + "objects": 10, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000003", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000003" + }, + "namespace": { + "uuid": "8bd032ea-243c-43f8-b9f8-7bba1ab723ee", + "name": "Namespace name 8bd032ea-243c-43f8-b9f8-7bba1ab723ee" + }, + "metadata": { + "recommendations": 1, + "objects": 33, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000004", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000004" + }, + "namespace": { + "uuid": "8bd032ea-243c-43f8-b9f8-7bba1ab723ee", + "name": "Namespace name 8bd032ea-243c-43f8-b9f8-7bba1ab723ee" + }, + "metadata": { + "recommendations": 1, + "objects": 80, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000004", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000004" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 1, + "objects": 20, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + }, + { + "cluster": { + "uuid": "00000001-0001-0001-0001-000000000005", + "display_name": "Cluster name 00000001-0001-0001-0001-000000000005" + }, + "namespace": { + "uuid": "fad82c1f-96db-430f-b3ec-503fb9eeb7bb", + "name": "Namespace name fad82c1f-96db-430f-b3ec-503fb9eeb7bb" + }, + "metadata": { + "recommendations": 1, + "objects": 100, + "reported_at": "2023-11-02T16:55:54+01:00", + "last_checked_at": "2023-11-02T16:55:54+01:00", + "highest_severity": 4, + "hits_by_severity": { + "1": 0, + "2": 0, + "3": 0, + "4": 1 + } + } + } +] \ No newline at end of file diff --git a/src/Components/Common/Tables.js b/src/Components/Common/Tables.js index abac318d..3cd1951f 100644 --- a/src/Components/Common/Tables.js +++ b/src/Components/Common/Tables.js @@ -275,3 +275,68 @@ export const addFilterParam = (currentFilters, updateFilters, param, values) => ...{ [param]: values }, }) : removeFilterParam(currentFilters, updateFilters, param); + +export const severityTypeToText = (value) => { + value = parseInt(value); + if (value === 1) { + return 'Low'; + } else if (value === 2) { + return 'Moderate'; + } else if (value === 3) { + return 'Important'; + } else { + return 'Critical'; + } +}; + +export const remappingSeverity = (obj) => { + const mapping = { + 1: 'low', + 2: 'moderate', + 3: 'important', + 4: 'critical', + }; + + const updatedObj = {}; + + for (const key in obj) { + if (key in mapping) { + updatedObj[mapping[key]] = obj[key]; + } + } + + return updatedObj; +}; + +function hasAnyValueGreaterThanZero(obj, stringsToCheck) { + for (const key of stringsToCheck) { + if (obj[key] > 0) { + return true; // Return true if any matching string has a value greater than 0 + } + } +} + +export const passFilterWorkloads = (workloads, filters) => { + const severityRemapped = remappingSeverity( + workloads.metadata.hits_by_severity + ); + return Object.entries(filters).every(([filterKey, filterValue]) => { + switch (filterKey) { + case 'cluster_name': + return workloads.cluster.display_name + .toLowerCase() + .includes(filterValue.toLowerCase()); + case 'namespace_name': + return workloads.namespace.name + .toLowerCase() + .includes(filterValue.toLowerCase()); + case 'highest_severity': + return ( + filterValue.length === 0 || + hasAnyValueGreaterThanZero(severityRemapped, filters.highest_severity) + ); + default: + return true; + } + }); +}; diff --git a/src/Components/HighestSeverityBadge/HighestSeverityBadge.js b/src/Components/HighestSeverityBadge/HighestSeverityBadge.js index f6a80a06..5cfcdb52 100644 --- a/src/Components/HighestSeverityBadge/HighestSeverityBadge.js +++ b/src/Components/HighestSeverityBadge/HighestSeverityBadge.js @@ -3,21 +3,9 @@ import { Tooltip } from '@patternfly/react-core'; import { TooltipPosition } from '@patternfly/react-core/dist/js/components/Tooltip'; import InsightsLabel from '@redhat-cloud-services/frontend-components/InsightsLabel'; import PropTypes from 'prop-types'; +import { severityTypeToText } from '../Common/Tables'; export const HighestSeverityBadge = ({ highestSeverity, severities }) => { - const severityTypeToText = (value) => { - value = parseInt(value); - if (value === 1) { - return 'Low'; - } else if (value === 2) { - return 'Moderate'; - } else if (value === 3) { - return 'Important'; - } else { - return 'Critical'; - } - }; - const severitiesToDisplay = Object.keys(severities) .map((severityType) => { return severities[severityType] > 0 ? ( diff --git a/src/Components/WorkloadsListTable/WorkloadsListTable.js b/src/Components/WorkloadsListTable/WorkloadsListTable.js index 78ae0191..3bae23b6 100644 --- a/src/Components/WorkloadsListTable/WorkloadsListTable.js +++ b/src/Components/WorkloadsListTable/WorkloadsListTable.js @@ -1,8 +1,5 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import useFeatureFlag, { - WORKLOADS_ENABLE_FLAG, -} from '../../Utilities/useFeatureFlag'; import PrimaryToolbar from '@redhat-cloud-services/frontend-components/PrimaryToolbar'; import { Table, @@ -28,34 +25,59 @@ import { updateWorkloadsListFilters, } from '../../Services/Filters'; import isEqual from 'lodash/isEqual'; -import { buildFilterChips } from '../Common/Tables'; +import { + addFilterParam, + buildFilterChips, + passFilterWorkloads, +} from '../Common/Tables'; import { ErrorState, NoMatchingClusters } from '../MessageState/EmptyStates'; import Loading from '../Loading/Loading'; +//import mockdata from '../../../cypress/fixtures/api/insights-results-aggregator/v2/workloads.json'; const WorkloadsListTable = ({ query: { isError, isUninitialized, isFetching, isSuccess, data }, }) => { const dispatch = useDispatch(); - const workloadsEnabled = useFeatureFlag(WORKLOADS_ENABLE_FLAG); const filters = useSelector(({ filters }) => filters.workloadsListState); - console.log(workloadsEnabled, 'FLAG'); const workloads = data?.workloads || []; + //to check all types of filters use the mockdata json + //const workloads = mockdata; - const [rows, setRows] = React.useState([]); + const [rows, setRows] = useState([]); + const [filteredRows, setFilteredRows] = useState([]); + const [rowsFiltered, setRowsFiltered] = useState(false); const updateFilters = (payload) => dispatch(updateWorkloadsListFilters(payload)); - const loadingState = isUninitialized || isFetching; + const loadingState = isUninitialized || isFetching || !rowsFiltered; const errorState = isError; const noMatch = rows.length === 0; const successState = isSuccess; useEffect(() => { - setRows(buildRows(workloads)); - }, [data]); + setRows(buildFilteredRows(workloads)); + //should be refactored to smth like setDisplayedRows(buildDisplayedRows(filteredRows)); + //when we add pagination + setRowsFiltered(true); + }, [data, filteredRows]); + + useEffect(() => { + setFilteredRows(buildFilteredRows(workloads)); + }, [ + filters.namespace_name, + filters.cluster_name, + filters.highest_severity, + filters.sortDirection, + filters.sortIndex, + ]); + + const buildFilteredRows = (items) => { + setRowsFiltered(false); + const filtered = items.filter((workloadData) => { + return passFilterWorkloads(workloadData, filters); + }); - const buildRows = (items) => { - return items.map((item, index) => { + return filtered.map((item, index) => { return { entity: item, cells: [ @@ -116,7 +138,7 @@ const WorkloadsListTable = ({ filterValues: { key: `${WORKLOADS_TABLE_FILTER_CATEGORIES.highest_severity.urlParam}-filter`, onChange: (_event, value) => - updateFilters({ ...filters, offset: 0, highest_severity: value }), + addFilterParam(filters, updateFilters, 'highest_severity', value), value: filters.highest_severity, items: WORKLOADS_TABLE_FILTER_CATEGORIES.highest_severity.values, placeholder: 'Filter by highest severity',