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.
[Uptime] Use dynamic index pattern in Uptime (elastic#55446)
* Using auto attribute field and fixed title * added constant * refactor index pattern state * fixed type * PR feedback * resolve conflcits Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
0314efc
commit 19f3c19
Showing
40 changed files
with
416 additions
and
301 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.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,93 @@ | ||
/* | ||
* 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 React, { useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { useUrlParams } from '../../../hooks'; | ||
import { parseFiltersMap } from '../../functional/filter_group/parse_filter_map'; | ||
import { AppState } from '../../../state'; | ||
import { fetchOverviewFilters, GetOverviewFiltersPayload } from '../../../state/actions'; | ||
import { FilterGroupComponent } from '../../functional/filter_group'; | ||
import { OverviewFilters } from '../../../../common/runtime_types/overview_filters'; | ||
|
||
interface OwnProps { | ||
esFilters?: string; | ||
} | ||
|
||
interface StoreProps { | ||
esKuery: string; | ||
lastRefresh: number; | ||
loading: boolean; | ||
overviewFilters: OverviewFilters; | ||
} | ||
|
||
interface DispatchProps { | ||
loadFilterGroup: typeof fetchOverviewFilters; | ||
} | ||
|
||
type Props = OwnProps & StoreProps & DispatchProps; | ||
|
||
export const Container: React.FC<Props> = ({ | ||
esKuery, | ||
esFilters, | ||
loading, | ||
loadFilterGroup, | ||
overviewFilters, | ||
}: Props) => { | ||
const [getUrlParams, updateUrl] = useUrlParams(); | ||
|
||
const { dateRangeStart, dateRangeEnd, statusFilter, filters: urlFilters } = getUrlParams(); | ||
|
||
useEffect(() => { | ||
const filterSelections = parseFiltersMap(urlFilters); | ||
loadFilterGroup({ | ||
dateRangeStart, | ||
dateRangeEnd, | ||
locations: filterSelections.locations ?? [], | ||
ports: filterSelections.ports ?? [], | ||
schemes: filterSelections.schemes ?? [], | ||
search: esKuery, | ||
statusFilter, | ||
tags: filterSelections.tags ?? [], | ||
}); | ||
}, [dateRangeStart, dateRangeEnd, esKuery, esFilters, statusFilter, urlFilters, loadFilterGroup]); | ||
|
||
// update filters in the URL from filter group | ||
const onFilterUpdate = (filtersKuery: string) => { | ||
if (urlFilters !== filtersKuery) { | ||
updateUrl({ filters: filtersKuery, pagination: '' }); | ||
} | ||
}; | ||
|
||
return ( | ||
<FilterGroupComponent | ||
currentFilter={urlFilters} | ||
overviewFilters={overviewFilters} | ||
loading={loading} | ||
onFilterUpdate={onFilterUpdate} | ||
/> | ||
); | ||
}; | ||
|
||
const mapStateToProps = ({ | ||
overviewFilters: { loading, filters }, | ||
ui: { esKuery, lastRefresh }, | ||
}: AppState): StoreProps => ({ | ||
esKuery, | ||
overviewFilters: filters, | ||
lastRefresh, | ||
loading, | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: any): DispatchProps => ({ | ||
loadFilterGroup: (payload: GetOverviewFiltersPayload) => dispatch(fetchOverviewFilters(payload)), | ||
}); | ||
|
||
export const FilterGroup = connect<StoreProps, DispatchProps, OwnProps>( | ||
// @ts-ignore connect is expecting null | undefined for some reason | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Container); |
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
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.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,21 @@ | ||
/* | ||
* 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 { connect } from 'react-redux'; | ||
import { AppState } from '../../../state'; | ||
import { selectIndexPattern } from '../../../state/selectors'; | ||
import { getIndexPattern } from '../../../state/actions'; | ||
import { KueryBarComponent } from '../../functional'; | ||
|
||
const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); | ||
|
||
const mapDispatchToProps = (dispatch: any) => ({ | ||
loadIndexPattern: () => { | ||
dispatch(getIndexPattern({})); | ||
}, | ||
}); | ||
|
||
export const KueryBar = connect(mapStateToProps, mapDispatchToProps)(KueryBarComponent); |
14 changes: 14 additions & 0 deletions
14
x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.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,14 @@ | ||
/* | ||
* 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 { connect } from 'react-redux'; | ||
import { OverviewPageComponent } from '../../../pages/overview'; | ||
import { selectIndexPattern } from '../../../state/selectors'; | ||
import { AppState } from '../../../state'; | ||
|
||
const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); | ||
|
||
export const OverviewPage = connect(mapStateToProps)(OverviewPageComponent); |
10 changes: 10 additions & 0 deletions
10
...ents/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.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
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
Oops, something went wrong.