Skip to content

Commit 49078ac

Browse files
committed
Optimize some code
Signed-off-by: gaobinlong <gbinlong@amazon.com>
1 parent 38308fd commit 49078ac

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

opensearch_dashboards.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
"configPath": [
66
"anomaly_detection_dashboards"
77
],
8-
"optionalPlugins": ["dataSource","dataSourceManagement", "dataExplorer"],
8+
"optionalPlugins": [
9+
"dataSource",
10+
"dataSourceManagement",
11+
"dataExplorer"
12+
],
913
"requiredPlugins": [
1014
"opensearchDashboardsUtils",
1115
"expressions",

public/components/DiscoverAction/GenerateAnomalyDetector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import { formikToDetector } from '../../../public/pages/ReviewAndCreate/utils/he
6161
import { FormattedFormRow } from '../../../public/components/FormattedFormRow/FormattedFormRow';
6262
import { FeatureAccordion } from '../../../public/pages/ConfigureModel/components/FeatureAccordion';
6363
import { AD_DOCS_LINK, DEFAULT_SHINGLE_SIZE, MAX_FEATURE_NUM, PLUGIN_NAME } from '../../../public/utils/constants';
64-
import { getNotifications } from '../../../public/services';
64+
import { getNotifications } from '../../services';
6565
import { prettifyErrorMessage } from '../../../server/utils/helpers';
6666
import EnhancedAccordion from '../FeatureAnywhereContextMenu/EnhancedAccordion';
6767
import MinimalAccordion from '../FeatureAnywhereContextMenu/MinimalAccordion';

public/redux/reducers/__tests__/ad.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('detector reducer actions', () => {
5454
},
5555
});
5656
expect(httpMockedClient.get).toHaveBeenCalledWith(
57-
`..${BASE_NODE_API_PATH}/detectors/${detectorId}`
57+
`${BASE_NODE_API_PATH}/detectors/${detectorId}`
5858
);
5959
});
6060
test('should invoke [REQUEST, FAILURE]', async () => {
@@ -76,7 +76,7 @@ describe('detector reducer actions', () => {
7676
errorMessage: 'Not found',
7777
});
7878
expect(httpMockedClient.get).toHaveBeenCalledWith(
79-
`..${BASE_NODE_API_PATH}/detectors/${detectorId}`
79+
`${BASE_NODE_API_PATH}/detectors/${detectorId}`
8080
);
8181
}
8282
});
@@ -104,7 +104,7 @@ describe('detector reducer actions', () => {
104104
},
105105
});
106106
expect(httpMockedClient.delete).toHaveBeenCalledWith(
107-
`..${BASE_NODE_API_PATH}/detectors/${expectedDetector.id}`
107+
`${BASE_NODE_API_PATH}/detectors/${expectedDetector.id}`
108108
);
109109
});
110110
test('should invoke [REQUEST, FAILURE]', async () => {
@@ -129,7 +129,7 @@ describe('detector reducer actions', () => {
129129
errorMessage: 'Detector is consumed by Monitor',
130130
});
131131
expect(httpMockedClient.delete).toHaveBeenCalledWith(
132-
`..${BASE_NODE_API_PATH}/detectors/${expectedDetector.id}`
132+
`${BASE_NODE_API_PATH}/detectors/${expectedDetector.id}`
133133
);
134134
}
135135
});
@@ -230,7 +230,7 @@ describe('detector reducer actions', () => {
230230
},
231231
});
232232
expect(httpMockedClient.put).toHaveBeenCalledWith(
233-
`..${BASE_NODE_API_PATH}/detectors/${detectorId}`,
233+
`${BASE_NODE_API_PATH}/detectors/${detectorId}`,
234234
{ body: JSON.stringify(randomDetector) }
235235
);
236236
});
@@ -258,7 +258,7 @@ describe('detector reducer actions', () => {
258258
errorMessage: 'Internal server error',
259259
});
260260
expect(httpMockedClient.post).toHaveBeenCalledWith(
261-
`..${BASE_NODE_API_PATH}/detectors`,
261+
`${BASE_NODE_API_PATH}/detectors`,
262262
randomDetector,
263263
{
264264
params: {
@@ -298,7 +298,7 @@ describe('detector reducer actions', () => {
298298
),
299299
});
300300
expect(httpMockedClient.post).toHaveBeenCalledWith(
301-
`..${BASE_NODE_API_PATH}/detectors/_search`,
301+
`${BASE_NODE_API_PATH}/detectors/_search`,
302302
{
303303
body: JSON.stringify(query),
304304
}
@@ -328,7 +328,7 @@ describe('detector reducer actions', () => {
328328
errorMessage: 'Internal server error',
329329
});
330330
expect(httpMockedClient.post).toHaveBeenCalledWith(
331-
`..${BASE_NODE_API_PATH}/detectors`,
331+
`${BASE_NODE_API_PATH}/detectors`,
332332
randomDetector
333333
);
334334
}

public/redux/reducers/ad.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export const validateDetector = (
390390
validationType: string,
391391
dataSourceId: string = ''
392392
): APIAction => {
393-
const baseUrl = `..${AD_NODE_API.DETECTOR}/_validate/${validationType}`;
393+
const baseUrl = `${AD_NODE_API.DETECTOR}/_validate/${validationType}`;
394394
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
395395

396396
return {
@@ -406,7 +406,7 @@ export const getDetector = (
406406
detectorId: string,
407407
dataSourceId: string = ''
408408
): APIAction => {
409-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
409+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}`;
410410
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
411411

412412
return {
@@ -421,7 +421,7 @@ export const getDetectorList = (
421421
): APIAction => {
422422
const dataSourceId = queryParams.dataSourceId || '';
423423

424-
const baseUrl = `..${AD_NODE_API.DETECTOR}/_list`;
424+
const baseUrl = `${AD_NODE_API.DETECTOR}/_list`;
425425
const url = dataSourceId
426426
? `${baseUrl}/${dataSourceId}`
427427
: baseUrl;
@@ -435,7 +435,7 @@ export const getDetectorList = (
435435
export const searchDetector = (requestBody: any): APIAction => ({
436436
type: SEARCH_DETECTOR,
437437
request: (client: HttpSetup) =>
438-
client.post(`..${AD_NODE_API.DETECTOR}/_search`, {
438+
client.post(`${AD_NODE_API.DETECTOR}/_search`, {
439439
body: JSON.stringify(requestBody),
440440
}),
441441
});
@@ -445,7 +445,7 @@ export const updateDetector = (
445445
requestBody: Detector,
446446
dataSourceId: string = ''
447447
): APIAction => {
448-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
448+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}`;
449449
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
450450

451451
return {
@@ -462,7 +462,7 @@ export const deleteDetector = (
462462
detectorId: string,
463463
dataSourceId: string = ''
464464
): APIAction => {
465-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
465+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}`;
466466
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
467467

468468
return {
@@ -492,7 +492,7 @@ export const startHistoricalDetector = (
492492
startTime: number,
493493
endTime: number
494494
): APIAction => {
495-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}`;
495+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}`;
496496
const url = dataSourceId
497497
? `${baseUrl}/${dataSourceId}/start`
498498
: `${baseUrl}/start`;
@@ -516,7 +516,7 @@ export const stopDetector = (
516516
detectorId: string,
517517
dataSourceId: string = ''
518518
): APIAction => {
519-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}/stop/${false}`;
519+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}/stop/${false}`;
520520
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
521521

522522
return {
@@ -530,7 +530,7 @@ export const stopHistoricalDetector = (
530530
detectorId: string,
531531
dataSourceId: string = ''
532532
): APIAction => {
533-
const baseUrl = `..${AD_NODE_API.DETECTOR}/${detectorId}/stop/${true}`;
533+
const baseUrl = `${AD_NODE_API.DETECTOR}/${detectorId}/stop/${true}`;
534534
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
535535

536536
return {
@@ -543,7 +543,7 @@ export const stopHistoricalDetector = (
543543
export const getDetectorProfile = (detectorId: string): APIAction => ({
544544
type: GET_DETECTOR_PROFILE,
545545
request: (client: HttpSetup) =>
546-
client.get(`..${AD_NODE_API.DETECTOR}/${detectorId}/_profile`),
546+
client.get(`${AD_NODE_API.DETECTOR}/${detectorId}/_profile`),
547547
detectorId,
548548
});
549549

0 commit comments

Comments
 (0)