-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RAM] Apply maintenance windows privilege to UI #156191
Merged
XavierM
merged 13 commits into
elastic:main
from
XavierM:add-window-maintenance-capabilities-ui
May 2, 2023
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0c6dc9
introduce UI link with kibana privilege
XavierM 45851eb
fix UI on table action when it is read only
XavierM 7a79199
unit test
XavierM 6f6d61e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 0f04c32
fix security solution for wm callout
XavierM e5bf02d
Merge branch 'main' of github.com:elastic/kibana into add-window-main…
XavierM 74b9279
Merge branch 'add-window-maintenance-capabilities-ui' of github.com:X…
XavierM 3202027
fix security test
XavierM c86fb95
Merge branch 'main' of github.com:elastic/kibana into add-window-main…
XavierM 6115ff9
Merge branch 'main' of github.com:elastic/kibana into add-window-main…
XavierM 2d30475
review
XavierM e71ad02
fix translations
XavierM ccee13b
Merge branch 'main' into add-window-maintenance-capabilities-ui
XavierM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
84 changes: 84 additions & 0 deletions
84
x-pack/plugins/alerting/public/pages/maintenance_windows/index.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,84 @@ | ||
/* | ||
* 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 from 'react'; | ||
import { licensingMock } from '@kbn/licensing-plugin/public/mocks'; | ||
import type { Capabilities } from '@kbn/core-capabilities-common'; | ||
import { AppMockRenderer, createAppMockRenderer } from '../../lib/test_utils'; | ||
import { useFindMaintenanceWindows } from '../../hooks/use_find_maintenance_windows'; | ||
import { MaintenanceWindowsPage } from '.'; | ||
import { MAINTENANCE_WINDOW_FEATURE_ID } from '../../../common'; | ||
|
||
jest.mock('../../hooks/use_find_maintenance_windows', () => ({ | ||
useFindMaintenanceWindows: jest.fn(), | ||
})); | ||
|
||
describe('Maintenance windows page', () => { | ||
let appMockRenderer: AppMockRenderer; | ||
let license = licensingMock.createLicense({ | ||
license: { type: 'platinum' }, | ||
}); | ||
let capabilities: Capabilities = { | ||
[MAINTENANCE_WINDOW_FEATURE_ID]: { | ||
show: true, | ||
save: true, | ||
}, | ||
navLinks: {}, | ||
management: {}, | ||
catalogue: {}, | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
(useFindMaintenanceWindows as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
maintenanceWindows: [], | ||
refetch: jest.fn(), | ||
}); | ||
license = licensingMock.createLicense({ | ||
license: { type: 'platinum' }, | ||
}); | ||
capabilities = { | ||
maintenanceWindow: { | ||
show: true, | ||
save: true, | ||
}, | ||
navLinks: {}, | ||
management: {}, | ||
catalogue: {}, | ||
}; | ||
appMockRenderer = createAppMockRenderer({ capabilities, license }); | ||
}); | ||
|
||
test('show license prompt', () => { | ||
license = licensingMock.createLicense({ | ||
license: { type: 'gold' }, | ||
}); | ||
appMockRenderer = createAppMockRenderer({ capabilities, license }); | ||
const result = appMockRenderer.render(<MaintenanceWindowsPage />); | ||
expect(result.queryByTestId('mw-license-prompt')).toBeInTheDocument(); | ||
}); | ||
|
||
test('show empty prompt', () => { | ||
const result = appMockRenderer.render(<MaintenanceWindowsPage />); | ||
expect(result.queryByTestId('mw-empty-prompt')).toBeInTheDocument(); | ||
expect(appMockRenderer.mocked.setBadge).not.toBeCalled(); | ||
}); | ||
|
||
test('show table in read only', () => { | ||
capabilities = { | ||
...capabilities, | ||
[MAINTENANCE_WINDOW_FEATURE_ID]: { | ||
show: true, | ||
save: false, | ||
}, | ||
}; | ||
appMockRenderer = createAppMockRenderer({ capabilities, license }); | ||
const result = appMockRenderer.render(<MaintenanceWindowsPage />); | ||
expect(result.queryByTestId('mw-table')).toBeInTheDocument(); | ||
expect(appMockRenderer.mocked.setBadge).toBeCalledTimes(1); | ||
}); | ||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't catch this earlier, and it's a bit unrelated to privileges, but I think we should rename this file to
MaintenanceWindowsPage
instead ofindex
, since it's not really an index file, same for the test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do that in follow up PR