From 1e572cfad9014fb0e30aff61429582154072f3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:17:17 +0200 Subject: [PATCH] [ILM] Read only view (#186955) ## Summary Fixes https://github.com/elastic/kibana/issues/184805 This PR adds a flyout to view an ILM policy. With this change, the ILM plugin can be also accessed by users with "read" permission for ILM. To test this PR, create a new role with `read_ilm` Elasticsearch privileges and all Kibana privileges. ### Screenshots https://github.com/user-attachments/assets/01fb445a-120a-489e-8f8d-26375ce391b1 ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../__snapshots__/policy_flyout.test.tsx.snap | 1027 +++++++++++++++++ .../__jest__/mocks.ts | 97 ++ .../__jest__/policy_flyout.test.tsx | 57 + .../__jest__/policy_table.test.tsx | 40 +- .../common/types/policies.ts | 70 +- .../integration_tests/app/app.helpers.ts | 15 +- .../integration_tests/app/app.test.ts | 12 +- .../public/application/components/index.ts | 8 + .../public/application/constants/policy.ts | 1 - .../public/application/constants/ui_metric.ts | 1 + .../public/application/index.tsx | 3 +- .../application/lib/use_is_read_only.ts | 19 + .../edit_policy/components/edit_warning.tsx | 2 +- .../delete_searchable_snapshot_field.tsx | 12 +- .../components/phases/hot_phase/hot_phase.tsx | 8 +- .../data_tier_allocation_field.tsx | 10 +- .../phases/shared_fields/downsample_field.tsx | 9 +- .../phases/shared_fields/forcemerge_field.tsx | 9 +- .../shared_fields/index_priority_field.tsx | 4 +- .../min_age_field/min_age_field.tsx | 30 +- .../phases/shared_fields/readonly_field.tsx | 10 +- .../phases/shared_fields/replicas_field.tsx | 11 +- .../searchable_snapshot_field.tsx | 8 +- .../phases/shared_fields/shrink_field.tsx | 11 +- .../shared_fields/snapshot_policies_field.tsx | 10 +- .../components/timeline/timeline.tsx | 41 +- .../sections/edit_policy/edit_policy.tsx | 16 +- .../sections/edit_policy/form/deserializer.ts | 1 - .../sections/edit_policy/form/schema.ts | 34 +- .../sections/edit_policy/i18n_texts.ts | 81 +- .../application/sections/edit_policy/types.ts | 2 +- .../components/deprecated_policy_badge.tsx | 32 + .../sections/policy_list/components/index.ts | 13 + .../components/list_action_handler.tsx | 17 +- .../components/managed_policy_badge.tsx | 33 + .../policy_list/components/policy_table.tsx | 168 ++- .../policy_list/policy_flyout/cold_phase.tsx | 37 + .../components/action_description.tsx | 39 + .../components/data_allocation.tsx | 85 ++ .../components/delete_searchable_snapshot.tsx | 27 + .../policy_flyout/components/downsample.tsx | 27 + .../policy_flyout/components/forcemerge.tsx | 38 + .../policy_flyout/components/i18n_texts.ts | 17 + .../policy_flyout/components/index.ts | 19 + .../components/index_priority.tsx | 29 + .../policy_flyout/components/min_age.tsx | 21 + .../policy_flyout/components/readonly.tsx | 23 + .../policy_flyout/components/replicas.tsx | 28 + .../policy_flyout/components/rollover.tsx | 76 ++ .../components/searchable_snapshot.tsx | 35 + .../policy_flyout/components/shrink.tsx | 49 + .../policy_flyout/components/types.ts | 13 + .../components/wait_for_snapshot.tsx | 24 + .../policy_flyout/delete_phase.tsx | 28 + .../policy_flyout/frozen_phase.tsx | 24 + .../policy_list/policy_flyout/hot_phase.tsx | 37 + .../policy_list/policy_flyout/index.ts | 8 + .../policy_flyout/phase_description.tsx | 43 + .../policy_flyout/phase_indicator.tsx | 32 + .../policy_list/policy_flyout/timeline.tsx | 31 + .../policy_flyout/view_policy_flyout.tsx | 204 ++++ .../policy_list/policy_flyout/warm_phase.tsx | 39 + .../sections/policy_list/policy_list.tsx | 37 +- .../policy_list/policy_list_context.tsx | 2 +- .../public/application/services/navigation.ts | 4 + .../public/types.ts | 1 + .../server/plugin.ts | 6 +- .../translations/translations/fr-FR.json | 4 - .../translations/translations/ja-JP.json | 4 - .../translations/translations/zh-CN.json | 4 - .../apps/group1/index_lifecycle_management.ts | 37 +- .../index_lifecycle_management/home_page.ts | 6 + .../apps/index_lifecycle_management/index.ts | 1 + .../read_only_view.ts | 43 + x-pack/test/functional/config.base.js | 14 + .../index_lifecycle_management_page.ts | 17 + 76 files changed, 2766 insertions(+), 369 deletions(-) create mode 100644 x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_flyout.test.tsx.snap create mode 100644 x-pack/plugins/index_lifecycle_management/__jest__/mocks.ts create mode 100644 x-pack/plugins/index_lifecycle_management/__jest__/policy_flyout.test.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/components/index.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/lib/use_is_read_only.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/components/deprecated_policy_badge.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/components/index.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/components/managed_policy_badge.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/cold_phase.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/action_description.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/data_allocation.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/delete_searchable_snapshot.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/downsample.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/forcemerge.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/i18n_texts.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/index.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/index_priority.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/min_age.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/readonly.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/replicas.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/rollover.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/searchable_snapshot.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/shrink.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/types.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/components/wait_for_snapshot.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/delete_phase.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/frozen_phase.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/hot_phase.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/index.ts create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/phase_description.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/phase_indicator.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/timeline.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/view_policy_flyout.tsx create mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/policy_list/policy_flyout/warm_phase.tsx create mode 100644 x-pack/test/functional/apps/index_lifecycle_management/read_only_view.ts diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_flyout.test.tsx.snap b/x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_flyout.test.tsx.snap new file mode 100644 index 0000000000000..91a77cb2096f2 --- /dev/null +++ b/x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_flyout.test.tsx.snap @@ -0,0 +1,1027 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`View policy flyout shows all phases 1`] = ` +
+ found-snapshots
+
+
+ found-snapshots
+
+
+ cloud-snapshot-policy
+
+