Skip to content
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

[7.x] [Uptime] replace fetch with kibana http (#59881) #60729

Merged
merged 2 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion x-pack/legacy/plugins/uptime/common/constants/rest_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

export enum REST_API_URLS {
export enum API_URLS {
INDEX_PATTERN = `/api/uptime/index_pattern`,
INDEX_STATUS = '/api/uptime/index_status',
MONITOR_LOCATIONS = `/api/uptime/monitor/locations`,
MONITOR_DURATION = `/api/uptime/monitor/duration`,
MONITOR_DETAILS = `/api/uptime/monitor/details`,
MONITOR_SELECTED = `/api/uptime/monitor/selected`,
MONITOR_STATUS = `/api/uptime/monitor/status`,
PINGS = '/api/uptime/pings',
PING_HISTOGRAM = `/api/uptime/ping/histogram`,
SNAPSHOT_COUNT = `/api/uptime/snapshot/count`,
FILTERS = `/api/uptime/filters`,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { useUrlParams } from '../../../hooks';
import { AppState } from '../../../state';
import { fetchSnapshotCount } from '../../../state/actions';
import { getSnapshotCountAction } from '../../../state/actions';
import { SnapshotComponent } from '../../functional/snapshot';
import { Snapshot as SnapshotType } from '../../../../common/runtime_types';
import { SnapShotQueryParams } from '../../../state/api';

/**
* Props expected from parent components.
Expand All @@ -37,7 +38,7 @@ interface StoreProps {
* for this component's life cycle
*/
interface DispatchProps {
loadSnapshotCount: typeof fetchSnapshotCount;
loadSnapshotCount: typeof getSnapshotCountAction;
}

/**
Expand All @@ -57,7 +58,7 @@ export const Container: React.FC<Props> = ({
const { dateRangeStart, dateRangeEnd, statusFilter } = getUrlParams();

useEffect(() => {
loadSnapshotCount(dateRangeStart, dateRangeEnd, esKuery, statusFilter);
loadSnapshotCount({ dateRangeStart, dateRangeEnd, filters: esKuery, statusFilter });
}, [dateRangeStart, dateRangeEnd, esKuery, lastRefresh, loadSnapshotCount, statusFilter]);
return <SnapshotComponent count={count} height={height} loading={loading} />;
};
Expand All @@ -81,13 +82,8 @@ const mapStateToProps = ({
* @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));
loadSnapshotCount: (params: SnapShotQueryParams): DispatchProps => {
return dispatch(getSnapshotCountAction(params));
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { AppState } from '../../../state';
import { getMonitorDetails } from '../../../state/selectors';
import { monitorDetailsSelector } from '../../../state/selectors';
import { MonitorDetailsActionPayload } from '../../../state/actions/types';
import { fetchMonitorDetails } from '../../../state/actions/monitor';
import { getMonitorDetailsAction } from '../../../state/actions/monitor';
import { MonitorListDrawerComponent } from '../../functional/monitor_list/monitor_list_drawer/monitor_list_drawer';
import { useUrlParams } from '../../../hooks';
import { MonitorSummary } from '../../../../common/graphql/types';
Expand All @@ -18,7 +18,7 @@ import { MonitorDetails } from '../../../../common/runtime_types/monitor';
interface ContainerProps {
summary: MonitorSummary;
monitorDetails: MonitorDetails;
loadMonitorDetails: typeof fetchMonitorDetails;
loadMonitorDetails: typeof getMonitorDetailsAction;
}

const Container: React.FC<ContainerProps> = ({ summary, loadMonitorDetails, monitorDetails }) => {
Expand All @@ -38,12 +38,12 @@ const Container: React.FC<ContainerProps> = ({ summary, loadMonitorDetails, moni
};

const mapStateToProps = (state: AppState, { summary }: any) => ({
monitorDetails: getMonitorDetails(state, summary),
monitorDetails: monitorDetailsSelector(state, summary),
});

const mapDispatchToProps = (dispatch: any) => ({
loadMonitorDetails: (actionPayload: MonitorDetailsActionPayload) =>
dispatch(fetchMonitorDetails(actionPayload)),
dispatch(getMonitorDetailsAction(actionPayload)),
});

export const MonitorListDrawer = connect(mapStateToProps, mapDispatchToProps)(Container);
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ 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 { monitorLocationsSelector, selectMonitorStatus } from '../../../state/selectors';
import { MonitorStatusBarComponent } from '../../functional/monitor_status_details/monitor_status_bar';
import { getMonitorStatus, getSelectedMonitor } from '../../../state/actions';
import { getMonitorStatusAction, getSelectedMonitorAction } from '../../../state/actions';
import { useUrlParams } from '../../../hooks';
import { Ping } from '../../../../common/graphql/types';
import { MonitorLocations } from '../../../../common/runtime_types/monitor';
Expand Down Expand Up @@ -57,20 +57,20 @@ const Container: React.FC<Props> = ({

const mapStateToProps = (state: AppState, ownProps: OwnProps) => ({
monitorStatus: selectMonitorStatus(state),
monitorLocations: selectMonitorLocations(state, ownProps.monitorId),
monitorLocations: monitorLocationsSelector(state, ownProps.monitorId),
});

const mapDispatchToProps = (dispatch: Dispatch<any>): DispatchProps => ({
loadMonitorStatus: (dateStart: string, dateEnd: string, monitorId: string) => {
dispatch(
getMonitorStatus({
getMonitorStatusAction({
monitorId,
dateStart,
dateEnd,
})
);
dispatch(
getSelectedMonitor({
getSelectedMonitorAction({
monitorId,
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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 { monitorLocationsSelector } from '../../../state/selectors';
import { getMonitorLocationsAction, MonitorLocationsPayload } from '../../../state/actions/monitor';
import { MonitorStatusDetailsComponent } from '../../functional/monitor_status_details';
import { MonitorLocations } from '../../../../common/runtime_types';
import { UptimeRefreshContext } from '../../../contexts';
Expand All @@ -24,7 +24,7 @@ interface StoreProps {
}

interface DispatchProps {
loadMonitorLocations: typeof fetchMonitorLocations;
loadMonitorLocations: typeof getMonitorLocationsAction;
}

type Props = OwnProps & StoreProps & DispatchProps;
Expand All @@ -48,12 +48,12 @@ export const Container: React.FC<Props> = ({
);
};
const mapStateToProps = (state: AppState, { monitorId }: OwnProps) => ({
monitorLocations: selectMonitorLocations(state, monitorId),
monitorLocations: monitorLocationsSelector(state, monitorId),
});

const mapDispatchToProps = (dispatch: Dispatch<any>) => ({
loadMonitorLocations: (params: MonitorLocationsPayload) => {
dispatch(fetchMonitorLocations(params));
dispatch(getMonitorLocationsAction(params));
},
});

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/uptime/public/lib/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
export { combineFiltersAndUserSearch } from './combine_filters_and_user_search';
export { convertMicrosecondsToMilliseconds } from './convert_measurements';
export * from './observability_integration';
export { getApiPath } from './get_api_path';
export { getChartDateLabel } from './charts';
export { parameterizeValues } from './parameterize_values';
export { seriesHasDownValues } from './series_has_down_values';
export { stringifyKueries } from './stringify_kueries';
export { UptimeUrlParams, getSupportedUrlParams } from './url_params';

This file was deleted.

4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/uptime/public/pages/monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MonitorStatusDetails } from '../components/connected';
import { Ping } from '../../common/graphql/types';
import { AppState } from '../state';
import { selectSelectedMonitor } from '../state/selectors';
import { getSelectedMonitor } from '../state/actions';
import { getSelectedMonitorAction } from '../state/actions';
import { PageHeader } from './page_header';

interface StateProps {
Expand Down Expand Up @@ -102,7 +102,7 @@ const mapDispatchToProps: MapDispatchToPropsFunction<DispatchProps, {}> = (dispa
return {
dispatchGetMonitorStatus: (monitorId: string) => {
dispatch(
getSelectedMonitor({
getSelectedMonitorAction({
monitorId,
})
);
Expand Down
Loading