Skip to content

Commit 139d315

Browse files
committed
make dataSourceId type safe
Signed-off-by: Jackie Han <jkhanjob@gmail.com>
1 parent 50e407b commit 139d315

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

public/pages/Dashboard/utils/utils.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export const getLatestAnomalyResultsByTimeRange = async (
443443
checkLastIndexOnly: boolean,
444444
resultIndex: string,
445445
onlyQueryCustomResultIndex: boolean,
446-
dataSourceId = ''
446+
dataSourceId: string
447447
): Promise<object[]> => {
448448
let from = 0;
449449
let anomalyResults = [] as object[];
@@ -504,7 +504,7 @@ export const getLatestAnomalyResultsForDetectorsByTimeRange = async (
504504
checkLastIndexOnly: boolean,
505505
resultIndex: string,
506506
onlyQueryCustomResultIndex: boolean,
507-
dataSourceId = ''
507+
dataSourceId: string
508508
): Promise<object[]> => {
509509
const detectorAndIdMap = buildDetectorAndIdMap(selectedDetectors);
510510
let from = 0;
@@ -615,7 +615,7 @@ export const getAnomalyDistributionForDetectorsByTimeRange = async (
615615
onlyQueryCustomResultIndex: boolean
616616
) => APIAction,
617617
selectedDetectors: DetectorListItem[],
618-
dataSourceId = '',
618+
dataSourceId: string,
619619
timeRange: string,
620620
dispatch: Dispatch<any>,
621621
threshold: number,

public/pages/DetectorDetail/hooks/useFetchMonitorInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { searchMonitors } from '../../../redux/reducers/alerting';
1919
//A hook which gets AD monitor.
2020
export const useFetchMonitorInfo = (
2121
detectorId: string,
22-
dataSourceId = '',
22+
dataSourceId: string,
2323
dataSourceEnabled: boolean
2424
): {
2525
monitor: Monitor | undefined;

public/pages/main/Main.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export function Main(props: MainProps) {
5252
'from=0&size=20&search=&indices=&sortField=name&sortDirection=asc';
5353

5454
const constructHrefWithDataSourceId = (
55-
basePath,
56-
existingParams = '',
57-
dataSourceId = ''
55+
basePath: string,
56+
existingParams: string,
57+
dataSourceId: string
5858
) => {
5959
const searchParams = new URLSearchParams(existingParams);
6060

public/redux/reducers/ad.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ const reducer = handleActions<Detectors>(
371371

372372
export const createDetector = (
373373
requestBody: Detector,
374-
dataSourceId = ''
374+
dataSourceId: string
375375
): APIAction => {
376376
const url = dataSourceId
377377
? `..${AD_NODE_API.DETECTOR}/${dataSourceId}`
@@ -399,7 +399,7 @@ export const validateDetector = (
399399

400400
export const getDetector = (
401401
detectorId: string,
402-
dataSourceId = ''
402+
dataSourceId: string
403403
): APIAction => {
404404
const baseUrl = `..${AD_NODE_API.DETECTOR}`;
405405
const url = dataSourceId
@@ -449,7 +449,7 @@ export const updateDetector = (
449449

450450
export const deleteDetector = (
451451
detectorId: string,
452-
dataSourceId = ''
452+
dataSourceId: string
453453
): APIAction => {
454454
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
455455
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
@@ -463,7 +463,7 @@ export const deleteDetector = (
463463

464464
export const startDetector = (
465465
detectorId: string,
466-
dataSourceId = ''
466+
dataSourceId: string
467467
): APIAction => {
468468
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}/start`;
469469
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
@@ -477,7 +477,7 @@ export const startDetector = (
477477

478478
export const startHistoricalDetector = (
479479
detectorId: string,
480-
dataSourceId = '',
480+
dataSourceId: string,
481481
startTime: number,
482482
endTime: number
483483
): APIAction => {
@@ -503,7 +503,7 @@ export const startHistoricalDetector = (
503503

504504
export const stopDetector = (
505505
detectorId: string,
506-
dataSourceId = ''
506+
dataSourceId: string
507507
): APIAction => {
508508
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}/stop/${false}`;
509509
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
@@ -517,7 +517,7 @@ export const stopDetector = (
517517

518518
export const stopHistoricalDetector = (
519519
detectorId: string,
520-
dataSourceId = ''
520+
dataSourceId: string
521521
): APIAction => {
522522
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
523523
const url = dataSourceId

public/redux/reducers/alerting.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const reducer = handleActions<Monitors>(
9494
initialDetectorsState
9595
);
9696

97-
export const searchMonitors = (dataSourceId = ''): APIAction => {
97+
export const searchMonitors = (dataSourceId: string): APIAction => {
9898
const baseUrl = `..${ALERTING_NODE_API._SEARCH}`;
9999
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
100100

public/redux/reducers/anomalyResults.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const reducer = handleActions<Anomalies>(
9494

9595
export const getDetectorResults = (
9696
id: string,
97-
dataSourceId = '',
97+
dataSourceId: string,
9898
queryParams: any,
9999
isHistorical: boolean,
100100
resultIndex: string,
@@ -119,7 +119,7 @@ export const getDetectorResults = (
119119
export const searchResults = (
120120
requestBody: any,
121121
resultIndex: string,
122-
dataSourceId = '',
122+
dataSourceId: string,
123123
onlyQueryCustomResultIndex: boolean
124124
): APIAction => {
125125
let baseUrl = `..${AD_NODE_API.DETECTOR}/results/_search`;

public/redux/reducers/opensearch.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const reducer = handleActions<OpenSearchState>(
246246
initialState
247247
);
248248

249-
export const getIndices = (searchKey = '', dataSourceId = '') => {
249+
export const getIndices = (searchKey = '', dataSourceId: string) => {
250250
const baseUrl = `..${AD_NODE_API._INDICES}`;
251251
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
252252

@@ -259,7 +259,7 @@ export const getIndices = (searchKey = '', dataSourceId = '') => {
259259

260260
export const getAliases = (
261261
searchKey: string = '',
262-
dataSourceId = ''
262+
dataSourceId: string
263263
): APIAction => {
264264
const baseUrl = `..${AD_NODE_API._ALIASES}`;
265265
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
@@ -287,7 +287,7 @@ export const searchOpenSearch = (requestData: any): APIAction => ({
287287
}),
288288
});
289289

290-
export const createIndex = (indexConfig: any, dataSourceId = ''): APIAction => {
290+
export const createIndex = (indexConfig: any, dataSourceId: string): APIAction => {
291291
const url = dataSourceId
292292
? `${AD_NODE_API.CREATE_INDEX}/${dataSourceId}`
293293
: AD_NODE_API.CREATE_INDEX;
@@ -300,7 +300,7 @@ export const createIndex = (indexConfig: any, dataSourceId = ''): APIAction => {
300300
};
301301
};
302302

303-
export const bulk = (body: any, dataSourceId = ''): APIAction => {
303+
export const bulk = (body: any, dataSourceId: string): APIAction => {
304304
const url = dataSourceId
305305
? `${AD_NODE_API.BULK}/${dataSourceId}`
306306
: AD_NODE_API.BULK;
@@ -318,7 +318,7 @@ export const deleteIndex = (index: string): APIAction => ({
318318
});
319319

320320
export const getPrioritizedIndices =
321-
(searchKey: string, dataSourceId = ''): ThunkAction =>
321+
(searchKey: string, dataSourceId: string): ThunkAction =>
322322
async (dispatch, getState) => {
323323
//Fetch Indices and Aliases with text provided
324324
await dispatch(getIndices(searchKey, dataSourceId));

public/redux/reducers/sampleData.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const reducer = handleActions<SampleDataState>(
5656

5757
export const createSampleData = (
5858
sampleDataType: SAMPLE_TYPE,
59-
dataSourceId = ''
59+
dataSourceId: string
6060
): APIAction => {
6161
const url = dataSourceId
6262
? `..${AD_NODE_API.CREATE_SAMPLE_DATA}/${sampleDataType}/${dataSourceId}`

0 commit comments

Comments
 (0)