forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ILM] Read only view (elastic#186955)
## Summary Fixes elastic#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 <img width="545" alt="Screenshot 2024-09-06 at 17 40 46" src="https://github.com/user-attachments/assets/74d3beb2-857c-4803-b308-80a2c1509696"> <img width="540" alt="Screenshot 2024-09-06 at 17 40 59" src="https://github.com/user-attachments/assets/82046408-cbef-4de3-aa7d-7b69193ad6b7"> 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 <[email protected]> (cherry picked from commit 1e572cf)
- Loading branch information
Showing
76 changed files
with
2,766 additions
and
369 deletions.
There are no files selected for viewing
1,027 changes: 1,027 additions & 0 deletions
1,027
x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_flyout.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
x-pack/plugins/index_lifecycle_management/__jest__/mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* 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 type { PolicyFromES } from '../common/types'; | ||
|
||
export const policyAllPhases: PolicyFromES = { | ||
name: 'test', | ||
modifiedDate: '2024-08-12T12:17:06.271Z', | ||
version: 1, | ||
policy: { | ||
name: 'test', | ||
phases: { | ||
hot: { | ||
actions: { | ||
rollover: { | ||
max_age: '30d', | ||
max_primary_shard_size: '50gb', | ||
max_primary_shard_docs: 25, | ||
max_docs: 235, | ||
max_size: '2gb', | ||
}, | ||
set_priority: { | ||
priority: 100, | ||
}, | ||
forcemerge: { | ||
max_num_segments: 3, | ||
index_codec: 'best_compression', | ||
}, | ||
shrink: { | ||
number_of_shards: 1, | ||
}, | ||
readonly: {}, | ||
}, | ||
min_age: '0ms', | ||
}, | ||
warm: { | ||
min_age: '3d', | ||
actions: { | ||
set_priority: { | ||
priority: 50, | ||
}, | ||
shrink: { | ||
max_primary_shard_size: '4gb', | ||
}, | ||
forcemerge: { | ||
max_num_segments: 44, | ||
index_codec: 'best_compression', | ||
}, | ||
allocate: { | ||
number_of_replicas: 3, | ||
}, | ||
downsample: { | ||
fixed_interval: '1d', | ||
}, | ||
}, | ||
}, | ||
cold: { | ||
min_age: '55d', | ||
actions: { | ||
searchable_snapshot: { | ||
snapshot_repository: 'found-snapshots', | ||
}, | ||
set_priority: { | ||
priority: 0, | ||
}, | ||
allocate: { | ||
number_of_replicas: 3, | ||
}, | ||
downsample: { | ||
fixed_interval: '4d', | ||
}, | ||
}, | ||
}, | ||
frozen: { | ||
min_age: '555d', | ||
actions: { | ||
searchable_snapshot: { | ||
snapshot_repository: 'found-snapshots', | ||
}, | ||
}, | ||
}, | ||
delete: { | ||
min_age: '7365d', | ||
actions: { | ||
wait_for_snapshot: { | ||
policy: 'cloud-snapshot-policy', | ||
}, | ||
delete: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
57 changes: 57 additions & 0 deletions
57
x-pack/plugins/index_lifecycle_management/__jest__/policy_flyout.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 React, { ReactElement } from 'react'; | ||
import { mountWithIntl } from '@kbn/test-jest-helpers'; | ||
import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test'; | ||
|
||
import { docLinksServiceMock } from '@kbn/core/public/mocks'; | ||
|
||
import type { PolicyFromES } from '../common/types'; | ||
import { KibanaContextProvider } from '../public/shared_imports'; | ||
import { PolicyListContextProvider } from '../public/application/sections/policy_list/policy_list_context'; | ||
import { ViewPolicyFlyout } from '../public/application/sections/policy_list/policy_flyout'; | ||
import * as readOnlyHook from '../public/application/lib/use_is_read_only'; | ||
import { policyAllPhases } from './mocks'; | ||
|
||
let component: ReactElement; | ||
const TestComponent = ({ policy }: { policy: PolicyFromES }) => { | ||
return ( | ||
<KibanaContextProvider | ||
services={{ getUrlForApp: () => '', docLinks: docLinksServiceMock.createStartContract() }} | ||
> | ||
<PolicyListContextProvider> | ||
<ViewPolicyFlyout policy={policy} /> | ||
</PolicyListContextProvider> | ||
</KibanaContextProvider> | ||
); | ||
}; | ||
|
||
describe('View policy flyout', () => { | ||
beforeAll(() => { | ||
jest.spyOn(readOnlyHook, 'useIsReadOnly').mockReturnValue(false); | ||
component = <TestComponent policy={policyAllPhases} />; | ||
}); | ||
it('shows all phases', () => { | ||
const rendered = mountWithIntl(component); | ||
expect(takeMountedSnapshot(rendered)).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders manage button', () => { | ||
const rendered = mountWithIntl(component); | ||
const button = findTestSubject(rendered, 'managePolicyButton'); | ||
expect(button.exists()).toBeTruthy(); | ||
}); | ||
|
||
it(`doesn't render manage button in read only view`, () => { | ||
jest.spyOn(readOnlyHook, 'useIsReadOnly').mockReturnValue(true); | ||
component = <TestComponent policy={policyAllPhases} />; | ||
const rendered = mountWithIntl(component); | ||
const button = findTestSubject(rendered, 'managePolicyButton'); | ||
expect(button.exists()).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.