forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tic#39570) * [APM] Context-aware query examples for the query bar We now adjust the query example based on whether the user is viewing transactions, errors or metrics. * Change query example for transactions * Address review feedback * Fix ts issues in unit tests * Use enum for route names, clarify queryExample w/ comment
- Loading branch information
1 parent
175d576
commit 66263d6
Showing
10 changed files
with
143 additions
and
39 deletions.
There are no files selected for viewing
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
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
18 changes: 18 additions & 0 deletions
18
x-pack/legacy/plugins/apm/public/components/app/Main/route_config/route_names.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,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export enum RouteName { | ||
HOME = 'home', | ||
SERVICES = 'services', | ||
TRACES = 'traces', | ||
SERVICE = 'service', | ||
TRANSACTIONS = 'transactions', | ||
ERRORS = 'errors', | ||
ERROR = 'error', | ||
METRICS = 'metrics', | ||
TRANSACTION_TYPE = 'transaction_type', | ||
TRANSACTION_NAME = 'transaction_name' | ||
} |
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
32 changes: 32 additions & 0 deletions
32
x-pack/legacy/plugins/apm/public/context/MatchedRouteContext.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { useMemo } from 'react'; | ||
import { matchPath } from 'react-router-dom'; | ||
import { routes } from '../components/app/Main/route_config'; | ||
import { useLocation } from '../hooks/useLocation'; | ||
|
||
export const MatchedRouteContext = React.createContext<Array<typeof routes[0]>>( | ||
[] | ||
); | ||
|
||
export const MatchedRouteProvider: React.FC = ({ children }) => { | ||
const { pathname } = useLocation(); | ||
|
||
const contextValue = useMemo( | ||
() => { | ||
return routes.filter(route => { | ||
return matchPath(pathname, { | ||
path: route.path | ||
}); | ||
}); | ||
}, | ||
[pathname] | ||
); | ||
|
||
return ( | ||
<MatchedRouteContext.Provider value={contextValue} children={children} /> | ||
); | ||
}; |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/apm/public/hooks/useMatchedRoutes.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,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { useContext } from 'react'; | ||
import { MatchedRouteContext } from '../context/MatchedRouteContext'; | ||
|
||
export function useMatchedRoutes() { | ||
return useContext(MatchedRouteContext); | ||
} |
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