Skip to content

Commit 7ea4f28

Browse files
[Uptime] Migrate to TypeScript project references (#90510)
* Add reference to Uptime plugin to root tsconfig.refs.json. * Add Uptime path to excluded list, and reference to references prop in `x-pack/tsconfig.json`. * Add reference to Uptime project in `x-pack/test/tsconfig.json`. * Add `tsconfig.json` project file to Uptime. * Fix broken JSON structure in test fixture. * Fix broken type exports. Introduce missing types. * Implement PR feedback. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent a1af217 commit 7ea4f28

22 files changed

Lines changed: 117 additions & 47 deletions

File tree

x-pack/plugins/uptime/common/constants/alerts.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,33 @@
77

88
import { ActionGroup } from '../../../alerts/common';
99

10+
export type MonitorStatusActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.monitorStatus'>;
11+
export type TLSActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.tls'>;
12+
export type DurationAnomalyActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.durationAnomaly'>;
13+
14+
export const MONITOR_STATUS: MonitorStatusActionGroup = {
15+
id: 'xpack.uptime.alerts.actionGroups.monitorStatus',
16+
name: 'Uptime Down Monitor',
17+
};
18+
19+
export const TLS: TLSActionGroup = {
20+
id: 'xpack.uptime.alerts.actionGroups.tls',
21+
name: 'Uptime TLS Alert',
22+
};
23+
24+
export const DURATION_ANOMALY: DurationAnomalyActionGroup = {
25+
id: 'xpack.uptime.alerts.actionGroups.durationAnomaly',
26+
name: 'Uptime Duration Anomaly',
27+
};
28+
1029
export const ACTION_GROUP_DEFINITIONS: {
11-
MONITOR_STATUS: ActionGroup<'xpack.uptime.alerts.actionGroups.monitorStatus'>;
12-
TLS: ActionGroup<'xpack.uptime.alerts.actionGroups.tls'>;
13-
DURATION_ANOMALY: ActionGroup<'xpack.uptime.alerts.actionGroups.durationAnomaly'>;
30+
MONITOR_STATUS: MonitorStatusActionGroup;
31+
TLS: TLSActionGroup;
32+
DURATION_ANOMALY: DurationAnomalyActionGroup;
1433
} = {
15-
MONITOR_STATUS: {
16-
id: 'xpack.uptime.alerts.actionGroups.monitorStatus',
17-
name: 'Uptime Down Monitor',
18-
},
19-
TLS: {
20-
id: 'xpack.uptime.alerts.actionGroups.tls',
21-
name: 'Uptime TLS Alert',
22-
},
23-
DURATION_ANOMALY: {
24-
id: 'xpack.uptime.alerts.actionGroups.durationAnomaly',
25-
name: 'Uptime Duration Anomaly',
26-
},
34+
MONITOR_STATUS,
35+
TLS,
36+
DURATION_ANOMALY,
2737
};
2838

2939
export const CLIENT_ALERT_TYPES = {

x-pack/plugins/uptime/public/components/monitor/synthetics/waterfall/components/styles.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
* 2.0.
66
*/
77

8-
import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
8+
import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText, EuiPanelProps } from '@elastic/eui';
99
import { rgba } from 'polished';
10-
import { euiStyled } from '../../../../../../../../../src/plugins/kibana_react/common';
10+
import { FunctionComponent } from 'react';
11+
import { StyledComponent } from 'styled-components';
12+
import { euiStyled, EuiTheme } from '../../../../../../../../../src/plugins/kibana_react/common';
1113
import { FIXED_AXIS_HEIGHT } from './constants';
1214

1315
interface WaterfallChartOuterContainerProps {
@@ -40,7 +42,10 @@ export const WaterfallChartFixedTopContainer = euiStyled.div`
4042
border-bottom: ${(props) => `1px solid ${props.theme.eui.euiColorLightShade}`};
4143
`;
4244

43-
export const WaterfallChartFixedTopContainerSidebarCover = euiStyled(EuiPanel)`
45+
export const WaterfallChartFixedTopContainerSidebarCover: StyledComponent<
46+
FunctionComponent<EuiPanelProps>,
47+
EuiTheme
48+
> = euiStyled(EuiPanel)`
4449
height: 100%;
4550
border-radius: 0 !important;
4651
border: none;
@@ -60,7 +65,10 @@ export const WaterfallChartSidebarContainer = euiStyled.div<WaterfallChartSideba
6065
overflow-y: hidden;
6166
`;
6267

63-
export const WaterfallChartSidebarContainerInnerPanel = euiStyled(EuiPanel)`
68+
export const WaterfallChartSidebarContainerInnerPanel: StyledComponent<
69+
FunctionComponent<EuiPanelProps>,
70+
EuiTheme
71+
> = euiStyled(EuiPanel)`
6472
border: 0;
6573
height: 100%;
6674
`;

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IntegrationGroup } from './integration_group';
1212
import { MonitorSummary } from '../../../../../../common/runtime_types';
1313
import { toggleIntegrationsPopover, PopoverState } from '../../../../../state/actions';
1414

15-
interface ActionsPopoverProps {
15+
export interface ActionsPopoverProps {
1616
summary: MonitorSummary;
1717
popoverState: PopoverState | null;
1818
togglePopoverIsVisible: typeof toggleIntegrationsPopover;

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/data.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,25 @@
261261
},
262262
"state": {
263263
"agent": null,
264-
"checks": ,
264+
"checks": [
265+
{
266+
"agent": { "id": "8f9a37fb-573a-4fdc-9895-440a5b39c250", "__typename": "Agent" },
267+
"container": null,
268+
"kubernetes": null,
269+
"monitor": {
270+
"ip": "127.0.0.1",
271+
"name": "localhost",
272+
"status": "up",
273+
"__typename": "CheckMonitor"
274+
},
275+
"observer": {
276+
"geo": { "name": null, "location": null, "__typename": "CheckGeo" },
277+
"__typename": "CheckObserver"
278+
},
279+
"timestamp": "1570538246143",
280+
"__typename": "Check"
281+
}
282+
],
265283
"geo": null,
266284
"observer": {
267285
"geo": { "name": [], "location": null, "__typename": "StateGeo" },

x-pack/plugins/uptime/public/state/alerts/alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const deleteAnomalyAlertAction = createAsyncAction<{ alertId: string }, a
5353
'DELETE ANOMALY ALERT'
5454
);
5555

56-
interface AlertState {
56+
export interface AlertState {
5757
connectors: AsyncInitState<ActionConnector[]>;
5858
newAlert: AsyncInitState<Alert<UptimeAlertTypeParams>>;
5959
alerts: AsyncInitState<AlertsResult>;

x-pack/plugins/uptime/public/state/certificates/certificates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const getCertificatesAction = createAsyncAction<GetCertsParams, CertResul
1919
'GET_CERTIFICATES'
2020
);
2121

22-
interface CertificatesState {
22+
export interface CertificatesState {
2323
certs: AsyncInitState<CertResult>;
2424
}
2525

x-pack/plugins/uptime/public/state/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
* 2.0.
66
*/
77

8-
import { compose, createStore, applyMiddleware } from 'redux';
8+
import { createStore, applyMiddleware } from 'redux';
9+
import { composeWithDevTools } from 'redux-devtools-extension';
910
import createSagaMiddleware from 'redux-saga';
1011
import { rootEffect } from './effects';
1112
import { rootReducer } from './reducers';
1213

1314
export type AppState = ReturnType<typeof rootReducer>;
1415

15-
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
16-
1716
const sagaMW = createSagaMiddleware();
1817

19-
export const store = createStore(rootReducer, composeEnhancers(applyMiddleware(sagaMW)));
18+
export const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(sagaMW)));
2019

2120
sagaMW.run(rootEffect);

x-pack/plugins/uptime/public/state/reducers/journey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface JourneyState {
2424
error?: Error;
2525
}
2626

27-
interface JourneyKVP {
27+
export interface JourneyKVP {
2828
[checkGroup: string]: JourneyState;
2929
}
3030

x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import moment from 'moment';
1010
import { schema } from '@kbn/config-schema';
1111
import { ActionGroupIdsOf } from '../../../../alerts/common';
1212
import { updateState } from './common';
13-
import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts';
13+
import { DURATION_ANOMALY } from '../../../common/constants/alerts';
1414
import { commonStateTranslations, durationAnomalyTranslations } from './translations';
1515
import { AnomaliesTableRecord } from '../../../../ml/common/types/anomalies';
1616
import { getSeverityType } from '../../../../ml/common/util/anomaly_utils';
@@ -21,7 +21,6 @@ import { getMLJobId } from '../../../common/lib';
2121
import { getLatestMonitor } from '../requests/get_latest_monitor';
2222
import { uptimeAlertWrapper } from './uptime_alert_wrapper';
2323

24-
const { DURATION_ANOMALY } = ACTION_GROUP_DEFINITIONS;
2524
export type ActionGroupIds = ActionGroupIdsOf<typeof DURATION_ANOMALY>;
2625

2726
export const getAnomalySummary = (anomaly: AnomaliesTableRecord, monitorInfo: Ping) => {

x-pack/plugins/uptime/server/lib/alerts/status_check.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
Ping,
1818
GetMonitorAvailabilityParams,
1919
} from '../../../common/runtime_types';
20-
import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts';
20+
import { MONITOR_STATUS } from '../../../common/constants/alerts';
2121
import { updateState } from './common';
2222
import { commonMonitorStateI18, commonStateTranslations, DOWN_LABEL } from './translations';
2323
import { stringifyKueries, combineFiltersAndUserSearch } from '../../../common/lib';
@@ -29,7 +29,6 @@ import { MonitorStatusTranslations } from '../../../common/translations';
2929
import { getUptimeIndexPattern, IndexPatternTitleAndFields } from '../requests/get_index_pattern';
3030
import { UMServerLibs, UptimeESClient } from '../lib';
3131

32-
const { MONITOR_STATUS } = ACTION_GROUP_DEFINITIONS;
3332
export type ActionGroupIds = ActionGroupIdsOf<typeof MONITOR_STATUS>;
3433

3534
const getMonIdByLoc = (monitorId: string, location: string) => {

0 commit comments

Comments
 (0)