Closes #36992 by fixing path params bug by checking if serviceName even (#37062) (#37202)

exists in the current pathname
This commit is contained in:
Oliver Gupte 2019-05-28 03:03:46 -04:00 committed by GitHub
parent a93ffdbfed
commit 8eb1f571e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -78,12 +78,6 @@ export const EnvironmentFilter: React.FC = () => {
const { urlParams, uiFilters } = useUrlParams();
const { start, end, serviceName } = urlParams;
// TODO fix the bug in urlParams that this code defensively overcomes
let realServiceName = serviceName;
if (serviceName === 'services') {
realServiceName = undefined;
}
const { environment } = uiFilters;
const { data: environments = [], status = 'loading' } = useFetcher(
() => {
@ -91,11 +85,11 @@ export const EnvironmentFilter: React.FC = () => {
return loadEnvironmentsFilter({
start,
end,
serviceName: realServiceName
serviceName
});
}
},
[start, end, realServiceName]
[start, end, serviceName]
);
return (

View file

@ -58,7 +58,7 @@ export function removeUndefinedProps<T>(obj: T): Partial<T> {
export function getPathParams(pathname: string = '') {
const paths = getPathAsArray(pathname);
const pageName = paths[1];
const pageName = paths.length > 1 ? paths[1] : paths[0];
// TODO: use react router's real match params instead of guessing the path order
switch (pageName) {
@ -80,6 +80,12 @@ export function getPathParams(pathname: string = '') {
processorEvent: 'metric',
serviceName: paths[0]
};
case 'services': // fall thru since services and traces share path params
case 'traces':
return {
processorEvent: 'transaction',
serviceName: undefined
};
default:
return {
processorEvent: 'transaction',