Skip to content

Commit

Permalink
Fix issues with serviceName
Browse files Browse the repository at this point in the history
  • Loading branch information
sqren committed Sep 15, 2020
1 parent 5b47bd8 commit 3843ec0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiFieldNumber, EuiSelect, EuiExpression } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { map } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -60,10 +61,11 @@ export function TransactionDurationAlertTrigger(props: Props) {
const { setAlertParams, alertParams, setAlertProperty } = props;
const { urlParams } = useUrlParams();
const transactionTypes = useServiceTransactionTypes(urlParams);
const { serviceName, start, end, transactionType } = urlParams;
const { serviceName } = useParams<{ serviceName?: string }>();
const { start, end, transactionType } = urlParams;
const { environmentOptions } = useEnvironments({ serviceName, start, end });

if (!transactionTypes.length) {
if (!transactionTypes.length || !serviceName) {
return null;
}

Expand All @@ -72,7 +74,9 @@ export function TransactionDurationAlertTrigger(props: Props) {
aggregationType: 'avg',
windowSize: 5,
windowUnit: 'm',
transactionType,

// use the current transaction type or default to the first in the list
transactionType: transactionType || transactionTypes[0],
environment: urlParams.environment || ENVIRONMENT_ALL.value,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiExpression, EuiSelect } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { ALERT_TYPES_CONFIG } from '../../../../common/alert_types';
Expand Down Expand Up @@ -42,9 +43,9 @@ interface Props {

export function TransactionDurationAnomalyAlertTrigger(props: Props) {
const { setAlertParams, alertParams, setAlertProperty } = props;
const { serviceName } = alertParams;
const { urlParams } = useUrlParams();
const transactionTypes = useServiceTransactionTypes(urlParams);
const { serviceName } = useParams<{ serviceName?: string }>();
const { start, end } = urlParams;
const { environmentOptions } = useEnvironments({ serviceName, start, end });
const supportedTransactionTypes = transactionTypes.filter((transactionType) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiFieldNumber, EuiSelect, EuiExpression } from '@elastic/eui';
import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { ForLastExpression } from '../../../../../triggers_actions_ui/public';
Expand Down Expand Up @@ -37,18 +38,19 @@ export function TransactionErrorRateAlertTrigger(props: Props) {
const { setAlertParams, alertParams, setAlertProperty } = props;
const { urlParams } = useUrlParams();
const transactionTypes = useServiceTransactionTypes(urlParams);
const { serviceName, start, end, transactionType } = urlParams;
const { serviceName } = useParams<{ serviceName?: string }>();
const { start, end } = urlParams;
const { environmentOptions } = useEnvironments({ serviceName, start, end });

if (!transactionTypes.length) {
if (!transactionTypes.length || !serviceName) {
return null;
}

const defaultParams = {
threshold: 30,
windowSize: 5,
windowUnit: 'm',
transactionType,
transactionType: transactionType || transactionTypes[0],
environment: urlParams.environment || ENVIRONMENT_ALL.value,
};

Expand Down

0 comments on commit 3843ec0

Please sign in to comment.