From f40bfba63fcea7e3180b1a97227d160ca7fe6300 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Thu, 8 Jun 2023 12:47:47 -0700 Subject: [PATCH 1/4] make feature anywhere formatted detector name an assgiend value to return Signed-off-by: Jackie Han --- .../CreateAnomalyDetector/helpers.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx index 4a990b67..9084f4a4 100644 --- a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx +++ b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx @@ -30,10 +30,10 @@ export function visFeatureListToFormik( } export function formikToDetectorName(title) { - const detectorName = + let detectorName = title + '_anomaly_detector_' + Math.floor(100000 + Math.random() * 900000); - detectorName.replace(/[^a-zA-Z0-9-_]/g, '_'); - return detectorName; + const formattedName = detectorName.replace(/[^a-zA-Z0-9\-_]/g, '_'); + return formattedName; } const getFeatureNameFromVisParams = (id, seriesParams) => { @@ -43,7 +43,8 @@ const getFeatureNameFromVisParams = (id, seriesParams) => { } }); - return name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); + const formaedFeatureName = name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); + return formaedFeatureName }; function visAggregationToFormik(value) { From ce749e01b1461bd1656eded584779d72ec80d9e8 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Thu, 8 Jun 2023 14:09:48 -0700 Subject: [PATCH 2/4] update feature anywhere documentation link Signed-off-by: Jackie Han --- public/utils/constants.ts | 3 +++ public/utils/contextMenu/getActions.tsx | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/utils/constants.ts b/public/utils/constants.ts index ce576412..fb2d2c72 100644 --- a/public/utils/constants.ts +++ b/public/utils/constants.ts @@ -59,6 +59,9 @@ export const AD_DOCS_LINK = export const AD_HIGH_CARDINALITY_LINK = 'https://opensearch.org/docs/latest/observing-your-data/ad/index/#optional-set-category-fields-for-high-cardinality'; +export const AD_FEATURE_ANYWHERE_LINK = + 'https://opensearch.org/docs/latest/observing-your-data/ad/dashboards-anomaly-detection/'; + export const MAX_DETECTORS = 1000; export const MAX_ANOMALIES = 10000; diff --git a/public/utils/contextMenu/getActions.tsx b/public/utils/contextMenu/getActions.tsx index 26bf8f06..baf31b70 100644 --- a/public/utils/contextMenu/getActions.tsx +++ b/public/utils/contextMenu/getActions.tsx @@ -13,7 +13,7 @@ import AnywhereParentFlyout from '../../components/FeatureAnywhereContextMenu/An import { Provider } from 'react-redux'; import configureStore from '../../redux/configureStore'; import DocumentationTitle from '../../components/FeatureAnywhereContextMenu/DocumentationTitle/containers/DocumentationTitle'; -import { AD_DOCS_LINK, APM_TRACE } from '../constants'; +import { AD_FEATURE_ANYWHERE_LINK, APM_TRACE } from '../constants'; import { getClient, getOverlays } from '../../../public/services'; import { FLYOUT_MODES } from '../../../public/components/FeatureAnywhereContextMenu/AnywhereParentFlyout/constants'; @@ -80,7 +80,7 @@ export const getActions = () => { icon: 'documentation' as EuiIconType, order: 98, onClick: () => { - window.open(AD_DOCS_LINK, '_blank'); + window.open(AD_FEATURE_ANYWHERE_LINK, '_blank'); }, }, ].map((options) => createADAction({ ...options, grouping })); From 67e1258e0cac69025941a2ec0666abbbc61f92e4 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Thu, 8 Jun 2023 16:56:31 -0700 Subject: [PATCH 3/4] correct type Signed-off-by: Jackie Han --- .../CreateAnomalyDetector/helpers.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx index 9084f4a4..63de8efe 100644 --- a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx +++ b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx @@ -43,8 +43,8 @@ const getFeatureNameFromVisParams = (id, seriesParams) => { } }); - const formaedFeatureName = name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); - return formaedFeatureName + const formatedFeatureName = name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); + return formatedFeatureName }; function visAggregationToFormik(value) { From be591221726d8be6798e88c85e0a34b8d224d7a4 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Fri, 9 Jun 2023 12:07:34 -0700 Subject: [PATCH 4/4] correct typo Signed-off-by: Jackie Han --- .../CreateAnomalyDetector/helpers.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx index 63de8efe..9bd6de0a 100644 --- a/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx +++ b/public/components/FeatureAnywhereContextMenu/CreateAnomalyDetector/helpers.tsx @@ -30,21 +30,21 @@ export function visFeatureListToFormik( } export function formikToDetectorName(title) { - let detectorName = + const detectorName = title + '_anomaly_detector_' + Math.floor(100000 + Math.random() * 900000); const formattedName = detectorName.replace(/[^a-zA-Z0-9\-_]/g, '_'); return formattedName; } const getFeatureNameFromVisParams = (id, seriesParams) => { - let name = find(seriesParams, function (param) { + const name = find(seriesParams, function (param) { if (param.data.id === id) { return true; } }); - const formatedFeatureName = name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); - return formatedFeatureName + const formattedFeatureName = name.data.label.replace(/[^a-zA-Z0-9-_]/g, '_'); + return formattedFeatureName }; function visAggregationToFormik(value) {