-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Add link-to/transaction route (#101731)
- Loading branch information
1 parent
edc5251
commit 520d1e8
Showing
4 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/apm/public/components/app/transaction_link/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiEmptyPrompt } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { Redirect, RouteComponentProps } from 'react-router-dom'; | ||
import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common'; | ||
import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher'; | ||
import { useUrlParams } from '../../../context/url_params_context/use_url_params'; | ||
import { getRedirectToTransactionDetailPageUrl } from '../TraceLink/get_redirect_to_transaction_detail_page_url'; | ||
|
||
const CentralizedContainer = euiStyled.div` | ||
height: 100%; | ||
display: flex; | ||
`; | ||
|
||
export function TransactionLink({ | ||
match, | ||
}: RouteComponentProps<{ transactionId: string }>) { | ||
const { transactionId } = match.params; | ||
const { urlParams } = useUrlParams(); | ||
const { rangeFrom, rangeTo } = urlParams; | ||
|
||
const { data = { transaction: null }, status } = useFetcher( | ||
(callApmApi) => { | ||
if (transactionId) { | ||
return callApmApi({ | ||
endpoint: 'GET /api/apm/transactions/{transactionId}', | ||
params: { | ||
path: { | ||
transactionId, | ||
}, | ||
}, | ||
}); | ||
} | ||
}, | ||
[transactionId] | ||
); | ||
if (transactionId && status === FETCH_STATUS.SUCCESS) { | ||
if (data.transaction) { | ||
return ( | ||
<Redirect | ||
to={getRedirectToTransactionDetailPageUrl({ | ||
transaction: data.transaction, | ||
rangeFrom, | ||
rangeTo, | ||
})} | ||
/> | ||
); | ||
} | ||
|
||
return <CentralizedContainer />; | ||
} | ||
|
||
return ( | ||
<CentralizedContainer> | ||
<EuiEmptyPrompt | ||
iconType="apmTrace" | ||
title={<h2>Fetching transaction...</h2>} | ||
/> | ||
</CentralizedContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters