Skip to content

Commit 1a8b460

Browse files
authored
[ObsUX][Infra] Update Infrastructure Anomaly Detection 'Feedback' buttons to use short links (#240847)
1 parent b05b769 commit 1a8b460

File tree

7 files changed

+61
-30
lines changed

7 files changed

+61
-30
lines changed

x-pack/solutions/observability/plugins/infra/public/components/asset_details/tabs/anomalies/anomalies.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const Anomalies = () => {
4949
<FeatureFeedbackButton
5050
data-test-subj="infraMLHostFlyoutFeedbackLink"
5151
formUrl={INFRA_ML_FLYOUT_FEEDBACK_LINK}
52+
sanitizedPath={document.location.pathname}
5253
kibanaVersion={kibanaVersion}
5354
isCloudEnv={isCloudEnv}
5455
isServerlessEnv={isServerlessEnv}

x-pack/solutions/observability/plugins/infra/public/components/ml/anomaly_detection/anomalies_table/anomalies_table.tsx

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -282,19 +282,38 @@ export interface Props {
282282
// subject to watch the completition of the request
283283
fetcherOpts?: Pick<FetcherOptions, 'autoFetch' | 'requestObservable$'>;
284284
hideSelectGroup?: boolean;
285+
onJobTypeChange?: (jobType: 'host' | 'pod') => void;
285286
}
286287

287288
const DEFAULT_DATE_RANGE: TimeRange = {
288289
from: 'now-30d',
289290
to: 'now',
290291
};
291292

293+
export const JOB_OPTIONS = [
294+
{
295+
id: `hosts` as JobType,
296+
label: i18n.translate('xpack.infra.ml.anomalyFlyout.hostBtn', {
297+
defaultMessage: 'Hosts',
298+
}),
299+
'data-test-subj': 'anomaliesHostComboBoxItem',
300+
},
301+
{
302+
id: `k8s` as JobType,
303+
label: i18n.translate('xpack.infra.ml.anomalyFlyout.podsBtn', {
304+
defaultMessage: 'Kubernetes Pods',
305+
}),
306+
'data-test-subj': 'anomaliesK8sComboBoxItem',
307+
},
308+
];
309+
292310
export const AnomaliesTable = ({
293311
closeFlyout,
294312
hostName,
295313
dateRange = DEFAULT_DATE_RANGE,
296314
hideDatePicker = false,
297315
fetcherOpts,
316+
onJobTypeChange,
298317
hideSelectGroup,
299318
}: Props) => {
300319
const [search, setSearch] = useState('');
@@ -307,26 +326,9 @@ export const AnomaliesTable = ({
307326
field: 'startTime',
308327
direction: 'desc',
309328
});
310-
const jobOptions = [
311-
{
312-
id: `hosts` as JobType,
313-
label: i18n.translate('xpack.infra.ml.anomalyFlyout.hostBtn', {
314-
defaultMessage: 'Hosts',
315-
}),
316-
'data-test-subj': 'anomaliesHostComboBoxItem',
317-
},
318-
{
319-
id: `k8s` as JobType,
320-
label: i18n.translate('xpack.infra.ml.anomalyFlyout.podsBtn', {
321-
defaultMessage: 'Kubernetes Pods',
322-
}),
323-
'data-test-subj': 'anomaliesK8sComboBoxItem',
324-
},
325-
];
326-
const [jobType, setJobType] = useState<JobType>('hosts');
327-
const [selectedJobType, setSelectedJobType] = useState<JobOption[]>([
328-
jobOptions.find((item) => item.id === 'hosts') || jobOptions[0],
329-
]);
329+
330+
const [jobType, setJobType] = useState<JobType>(JOB_OPTIONS[0].id);
331+
const [selectedJobType, setSelectedJobType] = useState<JobOption[]>([JOB_OPTIONS[0]]);
330332
const { source } = useSourceContext();
331333
const anomalyThreshold = source?.configuration.anomalyThreshold;
332334

@@ -436,10 +438,14 @@ export const AnomaliesTable = ({
436438
setSearch(e.target.value);
437439
}, []);
438440

439-
const changeJobType = useCallback((selectedOptions: any) => {
440-
setSelectedJobType(selectedOptions);
441-
setJobType(selectedOptions[0].id);
442-
}, []);
441+
const changeJobType = useCallback(
442+
(selectedOptions: any) => {
443+
setSelectedJobType(selectedOptions);
444+
setJobType(selectedOptions[0].id);
445+
onJobTypeChange?.(selectedOptions[0].id === 'hosts' ? 'host' : 'pod');
446+
},
447+
[onJobTypeChange]
448+
);
443449

444450
const changeSortOptions = useCallback(
445451
(nextSortOptions: Sort) => {
@@ -593,7 +599,7 @@ export const AnomaliesTable = ({
593599
defaultMessage: 'Select group',
594600
})}
595601
singleSelection={{ asPlainText: true }}
596-
options={jobOptions}
602+
options={JOB_OPTIONS}
597603
selectedOptions={selectedJobType}
598604
onChange={changeJobType}
599605
fullWidth

x-pack/solutions/observability/plugins/infra/public/components/ml/anomaly_detection/flyout_home.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
import { useMetricHostsModuleContext } from '../../../containers/ml/modules/metrics_hosts/module';
3737
import { useMetricK8sModuleContext } from '../../../containers/ml/modules/metrics_k8s/module';
3838
import { LoadingPrompt } from '../../loading_page';
39-
import { AnomaliesTable } from './anomalies_table/anomalies_table';
39+
import { AnomaliesTable, JOB_OPTIONS } from './anomalies_table/anomalies_table';
4040
import { SubscriptionSplashPrompt } from '../../subscription_splash_content';
4141
import { useInfraMLCapabilitiesContext } from '../../../containers/ml/infra_ml_capabilities';
4242
import { KibanaEnvironmentContext } from '../../../hooks/use_kibana';
@@ -51,11 +51,13 @@ interface Props {
5151

5252
type Tab = 'jobs' | 'anomalies';
5353

54-
export const INFRA_ML_FLYOUT_FEEDBACK_LINK =
55-
'https://docs.google.com/forms/d/e/1FAIpQLSfBixH_1HTuqeMCy38iK9w1mB8vl_eVvcLUlSPAPiWKBHeHiQ/viewform';
54+
export const INFRA_ML_FLYOUT_FEEDBACK_LINK = 'https://ela.st/infra-anomaly-feedback';
5655

5756
export const FlyoutHome = (props: Props) => {
5857
const [tab, setTab] = useState<Tab>('jobs');
58+
const [selectedJobType, setSelectedJobType] = useState<'host' | 'pod'>(
59+
JOB_OPTIONS[0].id === 'hosts' ? 'host' : 'pod'
60+
);
5961
const { goToSetup, closeFlyout } = props;
6062
const {
6163
fetchJobStatus: fetchHostJobStatus,
@@ -80,6 +82,10 @@ export const FlyoutHome = (props: Props) => {
8082
goToSetup('kubernetes');
8183
}, [goToSetup]);
8284

85+
const onJobTypeChange = useCallback((jobType: 'host' | 'pod') => {
86+
setSelectedJobType(jobType);
87+
}, []);
88+
8389
const jobIds = [
8490
...(k8sJobSummaries || []).map((k) => k.id),
8591
...(hostJobSummaries || []).map((h) => h.id),
@@ -100,11 +106,14 @@ export const FlyoutHome = (props: Props) => {
100106

101107
// Used for prefilling the feedback form (if both types are enabled do not prefill)
102108
// In case the host type is the only option (if props.hideJobType is true) - prefill 'host'
109+
// If we are in the anomalies tab, use the selected job type
103110
const mlJobTypeByNode =
104111
props.hideJobType || (hostJobSummaries.length > 0 && k8sJobSummaries.length === 0)
105112
? 'host'
106113
: hostJobSummaries.length === 0 && k8sJobSummaries.length > 0
107114
? 'pod'
115+
: tab === 'anomalies'
116+
? selectedJobType
108117
: undefined;
109118

110119
if (!hasInfraMLCapabilities) {
@@ -149,6 +158,7 @@ export const FlyoutHome = (props: Props) => {
149158
: 'infraMLFlyoutFeedbackLink'
150159
}
151160
formUrl={INFRA_ML_FLYOUT_FEEDBACK_LINK}
161+
sanitizedPath={document.location.pathname}
152162
kibanaVersion={kibanaVersion}
153163
isCloudEnv={isCloudEnv}
154164
isServerlessEnv={isServerlessEnv}
@@ -245,7 +255,11 @@ export const FlyoutHome = (props: Props) => {
245255
)}
246256

247257
{tab === 'anomalies' && (
248-
<AnomaliesTable closeFlyout={closeFlyout} hideSelectGroup={props.hideSelectGroup} />
258+
<AnomaliesTable
259+
closeFlyout={closeFlyout}
260+
hideSelectGroup={props.hideSelectGroup}
261+
onJobTypeChange={onJobTypeChange}
262+
/>
249263
)}
250264
</EuiFlyoutBody>
251265
</>

x-pack/solutions/observability/plugins/infra/public/components/ml/anomaly_detection/job_setup_screen.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export const JobSetupScreen = (props: Props) => {
279279
<FeatureFeedbackButton
280280
data-test-subj={`infraML${props.jobType}FlyoutFeedbackLink`}
281281
formUrl={INFRA_ML_FLYOUT_FEEDBACK_LINK}
282+
sanitizedPath={document.location.pathname}
282283
kibanaVersion={kibanaVersion}
283284
isCloudEnv={isCloudEnv}
284285
isServerlessEnv={isServerlessEnv}
@@ -309,7 +310,12 @@ export const JobSetupScreen = (props: Props) => {
309310
<EuiSpacer />
310311
{setupStatus.reasons.map((errorMessage, i) => (
311312
<React.Fragment key={i}>
312-
<EuiCallOut color="danger" iconType="warning" title={errorCalloutTitle}>
313+
<EuiCallOut
314+
announceOnMount
315+
color="danger"
316+
iconType="warning"
317+
title={errorCalloutTitle}
318+
>
313319
<EuiCode transparentBackground>{errorMessage}</EuiCode>
314320
</EuiCallOut>
315321
<EuiSpacer />

x-pack/solutions/observability/plugins/infra/public/pages/metrics/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ const HeaderLinkFeedbackButtonRoute = ({
239239
kibanaVersion={kibanaVersion}
240240
isCloudEnv={isCloudEnv}
241241
isServerlessEnv={isServerlessEnv}
242+
sanitizedPath={path}
242243
/>
243244
)}
244245
/>

x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/survey_kubernetes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const SurveyKubernetes = () => {
4040
isCloudEnv={isCloudEnv}
4141
isServerlessEnv={isServerlessEnv}
4242
surveyButtonText={FEEDBACK_BUTTON_KUBERNETES_TEXT}
43+
sanitizedPath={document.location.pathname}
4344
/>
4445
{!isToastSeen && (
4546
<EuiGlobalToastList
@@ -75,6 +76,7 @@ export const SurveyKubernetes = () => {
7576
isCloudEnv={isCloudEnv}
7677
isServerlessEnv={isServerlessEnv}
7778
surveyButtonText={START_SURVEY_BUTTON_TEXT}
79+
sanitizedPath={document.location.pathname}
7880
/>
7981
</EuiFlexItem>
8082
</EuiFlexGroup>

x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/survey_section.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const SurveySection = () => {
3030
kibanaVersion={kibanaVersion}
3131
isCloudEnv={isCloudEnv}
3232
isServerlessEnv={isServerlessEnv}
33+
sanitizedPath={document.location.pathname}
3334
/>
3435
)}
3536
</>

0 commit comments

Comments
 (0)