-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Uptime] Add Settings Page #53550
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
Merged
Merged
[Uptime] Add Settings Page #53550
Changes from all commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
d408981
check
andrewvc 49665d4
Moar
andrewvc 3947cac
More similarity to infra
andrewvc 8247b21
Fix syntax
andrewvc 7f5e8b6
Fix mappings key
andrewvc a1bc3ff
check
andrewvc 0e5cf0a
dynamic settings work
andrewvc 4a04c71
Temp
andrewvc b03253d
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc e6af3f9
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc ba99dd9
Fix type issues
andrewvc 134018c
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 5150e14
Rough out settings page
andrewvc 29a26ca
Checkpoint
andrewvc 90acfd0
Checkpoint
andrewvc 4cd5daa
checkpoint
andrewvc 4c16ec3
checkpoint
andrewvc be3d8dc
More form stuff
andrewvc 4d8830b
Checkpoint
andrewvc c96241c
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc cc4ab4b
checkpoint
andrewvc d26d7a9
checkpoint
andrewvc 252dbbd
form saves work
andrewvc 8879189
form saves work
andrewvc daa38be
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 54e303b
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 7a1d1c3
Fix routes
andrewvc e38c263
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc dfb879c
settings page sets
andrewvc b4ed4f0
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc d917bbd
Move SO type
andrewvc 88cf2b9
Checkpoint
andrewvc 8940500
Checkpoint
andrewvc 79541a3
It works (mostly)!
andrewvc ba99f79
Checkpoint
andrewvc fecd39b
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 0c5a4be
Saves work again
andrewvc 800fc39
Fix type issue
andrewvc 2ea3da5
Fix type issue
andrewvc 43b0180
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc c37beee
Much cleanup
andrewvc 28bf3cd
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc f790060
Remove needless comment
andrewvc f142580
Consolidate saved objects code
andrewvc d73c8fd
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 4c427fe
fmt
andrewvc fe2bd0c
Add dynamic settings API tests
andrewvc 379ffff
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 44a9661
Add form tag, link to settings, tests
andrewvc 6366a7c
Add functional tests
andrewvc bd64489
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc b8570c8
Don't return create error to user
andrewvc 409a3f0
Fix syntax
andrewvc 2023b43
Add header
andrewvc 75acc74
Remove unnecessary ts-ignore
andrewvc 69a1670
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc de99c50
Apply suggestions from code review
andrewvc 0bc3b51
Fix syntax
andrewvc 8b26a88
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 4df2f4b
Fix types
andrewvc 61f7b42
Only update fixtures if changed
andrewvc 56160c6
Merge branch 'master' into source-settings
andrewvc 8507737
Various improvements
andrewvc 42d908c
Move settings buttons inside panel
andrewvc 2154b69
Finish splitting out breadcrumbs
andrewvc 6fc4d1c
Remove unused files
andrewvc 88a8270
Better handling of privileges with settings
andrewvc 9ff2c92
Toasts kind of work
andrewvc be5e839
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 16ac622
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc dbe68c1
Better toasts
andrewvc 838f9da
Security / functionality improvement
andrewvc 0b6785d
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 8332b5d
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 2ea058c
Path fixes
andrewvc 7f2d080
Revert "Path fixes"
andrewvc 129b4b3
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc a9b3abf
Undo yarn lock change
andrewvc c7bf15c
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 3d86dd9
Fix tests
andrewvc b5e5ab9
All tests pass again
andrewvc b24a00c
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 27fda4c
Tidy tests
andrewvc 87edaf8
Merge branch 'master' into source-settings
elasticmachine 6296c93
Merge branch 'master' into source-settings
elasticmachine e4dcbfc
Merge remote-tracking branch 'avc/source-settings' into source-settings
andrewvc eada6da
Incorporate PR feedback
andrewvc 4a8abb2
Merge branch 'master' into source-settings
elasticmachine 1ad5741
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 7fe5e49
Merge remote-tracking branch 'avc/source-settings' into source-settings
andrewvc b35ef72
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 1bc87ee
Merge branch 'master' into source-settings
elasticmachine 9ce1004
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc 37d0545
Fix failing tests
andrewvc 12c3347
Merge remote-tracking branch 'avc/source-settings' into source-settings
andrewvc bcadf4c
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc b794065
Fix failing tests
andrewvc 474d1dd
Fix index collision
andrewvc e5c8298
Merge remote-tracking branch 'origin/master' into source-settings
andrewvc c99d896
Update snap
andrewvc b93eb0f
Remove unused var
andrewvc 8b75416
Fetch settings lazily
andrewvc 18a6cb6
Invoke settings in test blocks only
andrewvc 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 hidden or 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
27 changes: 27 additions & 0 deletions
27
x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.ts
This file contains hidden or 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,27 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import * as t from 'io-ts'; | ||
|
|
||
| export const DynamicSettingsType = t.type({ | ||
| heartbeatIndices: t.string, | ||
| }); | ||
|
|
||
| export const DynamicSettingsSaveType = t.intersection([ | ||
| t.type({ | ||
| success: t.boolean, | ||
| }), | ||
| t.partial({ | ||
| error: t.string, | ||
| }), | ||
| ]); | ||
|
|
||
| export type DynamicSettings = t.TypeOf<typeof DynamicSettingsType>; | ||
| export type DynamicSettingsSaveResponse = t.TypeOf<typeof DynamicSettingsSaveType>; | ||
|
|
||
| export const defaultDynamicSettings: DynamicSettings = { | ||
| heartbeatIndices: 'heartbeat-8*', | ||
| }; | ||
This file contains hidden or 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
1 change: 1 addition & 0 deletions
1
...blic/components/functional/empty_state/__tests__/__snapshots__/data_missing.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...ublic/components/functional/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
63 changes: 63 additions & 0 deletions
63
x-pack/legacy/plugins/uptime/public/hooks/__tests__/use_breadcrumbs.test.tsx
This file contains hidden or 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,63 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { ChromeBreadcrumb } from 'kibana/public'; | ||
| import React from 'react'; | ||
| import { Route } from 'react-router-dom'; | ||
| import { mountWithRouter } from '../../lib'; | ||
| import { OVERVIEW_ROUTE } from '../../../common/constants'; | ||
| import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; | ||
| import { UptimeUrlParams, getSupportedUrlParams } from '../../lib/helper'; | ||
| import { makeBaseBreadcrumb, useBreadcrumbs } from '../../hooks/use_breadcrumbs'; | ||
|
|
||
| describe('useBreadcrumbs', () => { | ||
| it('sets the given breadcrumbs', () => { | ||
| const [getBreadcrumbs, core] = mockCore(); | ||
|
|
||
| const expectedCrumbs: ChromeBreadcrumb[] = [ | ||
| { | ||
| text: 'Crumb: ', | ||
| href: 'http://href.example.net', | ||
| }, | ||
| { | ||
| text: 'Crumb II: Son of Crumb', | ||
| href: 'http://href2.example.net', | ||
| }, | ||
| ]; | ||
|
|
||
| const Component = () => { | ||
| useBreadcrumbs(expectedCrumbs); | ||
| return <>Hello</>; | ||
| }; | ||
|
|
||
| mountWithRouter( | ||
| <KibanaContextProvider services={{ ...core }}> | ||
| <Route path={OVERVIEW_ROUTE}> | ||
| <Component /> | ||
| </Route> | ||
| </KibanaContextProvider> | ||
| ); | ||
|
|
||
| const urlParams: UptimeUrlParams = getSupportedUrlParams({}); | ||
| expect(getBreadcrumbs()).toStrictEqual([makeBaseBreadcrumb(urlParams)].concat(expectedCrumbs)); | ||
| }); | ||
| }); | ||
|
|
||
| const mockCore: () => [() => ChromeBreadcrumb[], any] = () => { | ||
| let breadcrumbObj: ChromeBreadcrumb[] = []; | ||
| const get = () => { | ||
| return breadcrumbObj; | ||
| }; | ||
| const core = { | ||
| chrome: { | ||
| setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => { | ||
| breadcrumbObj = newBreadcrumbs; | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| return [get, core]; | ||
| }; |
41 changes: 41 additions & 0 deletions
41
x-pack/legacy/plugins/uptime/public/hooks/use_breadcrumbs.ts
This file contains hidden or 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,41 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { ChromeBreadcrumb } from 'kibana/public'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { useEffect } from 'react'; | ||
| import { UptimeUrlParams } from '../lib/helper'; | ||
| import { stringifyUrlParams } from '../lib/helper/stringify_url_params'; | ||
| import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; | ||
| import { useUrlParams } from '.'; | ||
|
|
||
| export const makeBaseBreadcrumb = (params?: UptimeUrlParams): ChromeBreadcrumb => { | ||
| let href = '#/'; | ||
| if (params) { | ||
| const crumbParams: Partial<UptimeUrlParams> = { ...params }; | ||
| // We don't want to encode this values because they are often set to Date.now(), the relative | ||
| // values in dateRangeStart are better for a URL. | ||
| delete crumbParams.absoluteDateRangeStart; | ||
| delete crumbParams.absoluteDateRangeEnd; | ||
| href += stringifyUrlParams(crumbParams, true); | ||
| } | ||
| return { | ||
| text: i18n.translate('xpack.uptime.breadcrumbs.overviewBreadcrumbText', { | ||
| defaultMessage: 'Uptime', | ||
| }), | ||
| href, | ||
| }; | ||
| }; | ||
|
|
||
| export const useBreadcrumbs = (extraCrumbs: ChromeBreadcrumb[]) => { | ||
| const params = useUrlParams()[0](); | ||
| const setBreadcrumbs = useKibana().services.chrome?.setBreadcrumbs; | ||
| useEffect(() => { | ||
| if (setBreadcrumbs) { | ||
| setBreadcrumbs([makeBaseBreadcrumb(params)].concat(extraCrumbs)); | ||
| } | ||
| }, [extraCrumbs, params, setBreadcrumbs]); | ||
| }; |
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.
Shouldn't this be moved to constants?
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 would argue that not everything needs to be a constant, it's just an extra file. Mind if we try putting some stuff more inline? It is in the
commonfolder and is near it's natural home IMHO, which is theDynamicSettingstype definition.