-
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.
[7.6] [Uptime] Refresh absolute date ranges for Ping Histogram (#56381)…
… (#56649) * [Uptime] Refresh absolute date ranges for Ping Histogram (#56381) * fix abs date mismatch * fixed types * update pr * simplify params Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * fix snaps * update filter Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
54b7eac
commit 4ad0312
Showing
33 changed files
with
1,203 additions
and
505 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
98 changes: 98 additions & 0 deletions
98
x-pack/legacy/plugins/uptime/public/components/connected/charts/snapshot_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,98 @@ | ||
/* | ||
* 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 { AppState } from '../../../state'; | ||
import { fetchSnapshotCount } from '../../../state/actions'; | ||
import { SnapshotComponent } from '../../functional/snapshot'; | ||
import { Snapshot as SnapshotType } from '../../../../common/runtime_types'; | ||
|
||
/** | ||
* Props expected from parent components. | ||
*/ | ||
interface OwnProps { | ||
/** | ||
* Height is needed, since by default charts takes height of 100% | ||
*/ | ||
height?: string; | ||
} | ||
|
||
/** | ||
* Props given by the Redux store based on action input. | ||
*/ | ||
interface StoreProps { | ||
count: SnapshotType; | ||
lastRefresh: number; | ||
loading: boolean; | ||
esKuery: string; | ||
} | ||
|
||
/** | ||
* Contains functions that will dispatch actions used | ||
* for this component's life cycle | ||
*/ | ||
interface DispatchProps { | ||
loadSnapshotCount: typeof fetchSnapshotCount; | ||
} | ||
|
||
/** | ||
* Props used to render the Snapshot component. | ||
*/ | ||
type Props = OwnProps & StoreProps & DispatchProps; | ||
|
||
export const Container: React.FC<Props> = ({ | ||
count, | ||
height, | ||
lastRefresh, | ||
loading, | ||
esKuery, | ||
loadSnapshotCount, | ||
}: Props) => { | ||
const [getUrlParams] = useUrlParams(); | ||
const { dateRangeStart, dateRangeEnd, statusFilter } = getUrlParams(); | ||
|
||
useEffect(() => { | ||
loadSnapshotCount(dateRangeStart, dateRangeEnd, esKuery, statusFilter); | ||
}, [dateRangeStart, dateRangeEnd, esKuery, lastRefresh, loadSnapshotCount, statusFilter]); | ||
return <SnapshotComponent count={count} height={height} loading={loading} />; | ||
}; | ||
|
||
/** | ||
* Provides state to connected component. | ||
* @param state the root app state | ||
*/ | ||
const mapStateToProps = ({ | ||
snapshot: { count, loading }, | ||
ui: { lastRefresh, esKuery }, | ||
}: AppState): StoreProps => ({ | ||
count, | ||
lastRefresh, | ||
loading, | ||
esKuery, | ||
}); | ||
|
||
/** | ||
* Used for fetching snapshot counts. | ||
* @param dispatch redux-provided action dispatcher | ||
*/ | ||
const mapDispatchToProps = (dispatch: any) => ({ | ||
loadSnapshotCount: ( | ||
dateRangeStart: string, | ||
dateRangeEnd: string, | ||
filters?: string, | ||
statusFilter?: string | ||
): DispatchProps => { | ||
return dispatch(fetchSnapshotCount(dateRangeStart, dateRangeEnd, filters, statusFilter)); | ||
}, | ||
}); | ||
|
||
export const Snapshot = 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
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
85 changes: 85 additions & 0 deletions
85
x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_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,85 @@ | ||
/* | ||
* 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, { useContext, useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Dispatch } from 'redux'; | ||
import { AppState } from '../../../state'; | ||
import { selectMonitorLocations, selectMonitorStatus } from '../../../state/selectors'; | ||
import { MonitorStatusBarComponent } from '../../functional/monitor_status_details/monitor_status_bar'; | ||
import { getMonitorStatus, getSelectedMonitor } from '../../../state/actions'; | ||
import { useUrlParams } from '../../../hooks'; | ||
import { Ping } from '../../../../common/graphql/types'; | ||
import { MonitorLocations } from '../../../../common/runtime_types/monitor'; | ||
import { UptimeRefreshContext } from '../../../contexts'; | ||
|
||
interface StateProps { | ||
monitorStatus: Ping; | ||
monitorLocations: MonitorLocations; | ||
} | ||
|
||
interface DispatchProps { | ||
loadMonitorStatus: (dateStart: string, dateEnd: string, monitorId: string) => void; | ||
} | ||
|
||
interface OwnProps { | ||
monitorId: string; | ||
} | ||
|
||
type Props = OwnProps & StateProps & DispatchProps; | ||
|
||
export const Container: React.FC<Props> = ({ | ||
loadMonitorStatus, | ||
monitorId, | ||
monitorStatus, | ||
monitorLocations, | ||
}: Props) => { | ||
const { lastRefresh } = useContext(UptimeRefreshContext); | ||
|
||
const [getUrlParams] = useUrlParams(); | ||
const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = getUrlParams(); | ||
|
||
useEffect(() => { | ||
loadMonitorStatus(dateStart, dateEnd, monitorId); | ||
}, [monitorId, dateStart, dateEnd, loadMonitorStatus, lastRefresh]); | ||
|
||
return ( | ||
<MonitorStatusBarComponent | ||
monitorId={monitorId} | ||
monitorStatus={monitorStatus} | ||
monitorLocations={monitorLocations} | ||
/> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state: AppState, ownProps: OwnProps) => ({ | ||
monitorStatus: selectMonitorStatus(state), | ||
monitorLocations: selectMonitorLocations(state, ownProps.monitorId), | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch<any>): DispatchProps => ({ | ||
loadMonitorStatus: (dateStart: string, dateEnd: string, monitorId: string) => { | ||
dispatch( | ||
getMonitorStatus({ | ||
monitorId, | ||
dateStart, | ||
dateEnd, | ||
}) | ||
); | ||
dispatch( | ||
getSelectedMonitor({ | ||
monitorId, | ||
}) | ||
); | ||
}, | ||
}); | ||
|
||
// @ts-ignore TODO: Investigate typescript issues here | ||
export const MonitorStatusBar = connect<StateProps, DispatchProps, MonitorStatusBarProps>( | ||
// @ts-ignore TODO: Investigate typescript issues here | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Container); |
64 changes: 64 additions & 0 deletions
64
...ck/legacy/plugins/uptime/public/components/connected/monitor/status_details_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,64 @@ | ||
/* | ||
* 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, { useContext, useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Dispatch } from 'redux'; | ||
import { useUrlParams } from '../../../hooks'; | ||
import { AppState } from '../../../state'; | ||
import { selectMonitorLocations } from '../../../state/selectors'; | ||
import { fetchMonitorLocations, MonitorLocationsPayload } from '../../../state/actions/monitor'; | ||
import { MonitorStatusDetailsComponent } from '../../functional/monitor_status_details'; | ||
import { MonitorLocations } from '../../../../common/runtime_types'; | ||
import { UptimeRefreshContext } from '../../../contexts'; | ||
|
||
interface OwnProps { | ||
monitorId: string; | ||
} | ||
|
||
interface StoreProps { | ||
monitorLocations: MonitorLocations; | ||
} | ||
|
||
interface DispatchProps { | ||
loadMonitorLocations: typeof fetchMonitorLocations; | ||
} | ||
|
||
type Props = OwnProps & StoreProps & DispatchProps; | ||
|
||
export const Container: React.FC<Props> = ({ | ||
loadMonitorLocations, | ||
monitorLocations, | ||
monitorId, | ||
}: Props) => { | ||
const { lastRefresh } = useContext(UptimeRefreshContext); | ||
|
||
const [getUrlParams] = useUrlParams(); | ||
const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = getUrlParams(); | ||
|
||
useEffect(() => { | ||
loadMonitorLocations({ dateStart, dateEnd, monitorId }); | ||
}, [loadMonitorLocations, monitorId, dateStart, dateEnd, lastRefresh]); | ||
|
||
return ( | ||
<MonitorStatusDetailsComponent monitorId={monitorId} monitorLocations={monitorLocations} /> | ||
); | ||
}; | ||
const mapStateToProps = (state: AppState, { monitorId }: OwnProps) => ({ | ||
monitorLocations: selectMonitorLocations(state, monitorId), | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch<any>) => ({ | ||
loadMonitorLocations: (params: MonitorLocationsPayload) => { | ||
dispatch(fetchMonitorLocations(params)); | ||
}, | ||
}); | ||
|
||
export const MonitorStatusDetails = connect<StoreProps, DispatchProps, OwnProps>( | ||
// @ts-ignore TODO: Investigate typescript issues here | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Container); |
2 changes: 0 additions & 2 deletions
2
.../uptime/public/components/functional/__tests__/__snapshots__/monitor_charts.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
Oops, something went wrong.