-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into drilldowns
- Loading branch information
Showing
105 changed files
with
3,397 additions
and
366 deletions.
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
27 changes: 27 additions & 0 deletions
27
x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.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,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 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 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 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 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.