Skip to content

Commit

Permalink
addressing PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Sep 28, 2020
1 parent 2283497 commit dcf8e85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import {
SelectAnomalySeverity,
} from './SelectAnomalySeverity';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
import {
TRANSACTION_PAGE_LOAD,
TRANSACTION_REQUEST,
} from '../../../../common/transaction_types';
import {
EnvironmentField,
ServiceField,
Expand Down Expand Up @@ -53,21 +49,17 @@ export function TransactionDurationAnomalyAlertTrigger(props: Props) {
const { urlParams } = useUrlParams();
const transactionTypes = useServiceTransactionTypes(urlParams);
const { serviceName } = useParams<{ serviceName?: string }>();
const { start, end } = urlParams;
const { start, end, transactionType } = urlParams;
const { environmentOptions } = useEnvironments({ serviceName, start, end });

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

const transactionType = transactionTypes.find(
(type) => type === urlParams.transactionType
);

const defaults: Params = {
windowSize: 15,
windowUnit: 'm',
transactionType,
transactionType: transactionType || transactionTypes[0],
serviceName,
environment: urlParams.environment || ENVIRONMENT_ALL.value,
anomalySeverityType: ANOMALY_SEVERITY.CRITICAL,
Expand All @@ -80,7 +72,11 @@ export function TransactionDurationAnomalyAlertTrigger(props: Props) {

const fields = [
<ServiceField value={serviceName} />,
<TransactionTypeField currentValue={transactionType} />,
<TransactionTypeField
currentValue={params.transactionType}
options={transactionTypes.map((key) => ({ text: key, value: key }))}
onChange={(e) => setAlertParams('transactionType', e.target.value)}
/>,
<EnvironmentField
currentValue={params.environment}
options={environmentOptions}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/public/components/alerting/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function TransactionTypeField({
options,
onChange,
}: {
currentValue: string;
currentValue?: string;
options?: EuiSelectOption[];
onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
}) {
Expand Down

0 comments on commit dcf8e85

Please sign in to comment.