Skip to content

Commit

Permalink
Revert changes in ui filters routes that are no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Nov 15, 2019
1 parent a8b9398 commit 0442cb8
Showing 1 changed file with 41 additions and 57 deletions.
98 changes: 41 additions & 57 deletions x-pack/legacy/plugins/apm/server/routes/ui_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ const localUiBaseQueryRt = t.intersection([
rangeRt
]);

function createLocalFiltersRoute<TQueryRT extends t.HasProps>({
function createLocalFiltersRoute<
TPath extends string,
TProjection extends Projection,
TQueryRT extends t.HasProps
>({
path,
getProjection,
queryRt
}: {
path: string;
getProjection: GetProjection<Projection, TQueryRT & BaseQueryType>;
path: TPath;
getProjection: GetProjection<TProjection, TQueryRT & BaseQueryType>;
queryRt: TQueryRT;
}) {
return createRoute(() => ({
Expand Down Expand Up @@ -105,25 +109,13 @@ function createLocalFiltersRoute<TQueryRT extends t.HasProps>({
}));
}

export const servicesLocalFiltersRoute = createLocalFiltersRoute<t.TypeC<{}>>({
export const servicesLocalFiltersRoute = createLocalFiltersRoute({
path: `/api/apm/ui_filters/local_filters/services`,
getProjection: ({ setup }) => getServicesProjection({ setup }),
queryRt: t.type({})
});

const transactionGroupsLocalFiltersQueryRt = t.intersection([
t.type({
serviceName: t.string,
transactionType: t.string
}),
t.partial({
transactionName: t.string
})
]);

export const transactionGroupsLocalFiltersRoute = createLocalFiltersRoute<
typeof transactionGroupsLocalFiltersQueryRt
>({
export const transactionGroupsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/transactionGroups',
getProjection: ({ setup, query }) => {
const { transactionType, serviceName, transactionName } = query;
Expand All @@ -137,10 +129,18 @@ export const transactionGroupsLocalFiltersRoute = createLocalFiltersRoute<
}
});
},
queryRt: transactionGroupsLocalFiltersQueryRt
queryRt: t.intersection([
t.type({
serviceName: t.string,
transactionType: t.string
}),
t.partial({
transactionName: t.string
})
])
});

export const tracesLocalFiltersRoute = createLocalFiltersRoute<t.TypeC<{}>>({
export const tracesLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/traces',
getProjection: ({ setup }) => {
return getTransactionGroupsProjection({
Expand All @@ -151,15 +151,7 @@ export const tracesLocalFiltersRoute = createLocalFiltersRoute<t.TypeC<{}>>({
queryRt: t.type({})
});

const transactionsLocalFiltersQueryRt = t.type({
transactionType: t.string,
transactionName: t.string,
serviceName: t.string
});

export const transactionsLocalFiltersRoute = createLocalFiltersRoute<
typeof transactionsLocalFiltersQueryRt
>({
export const transactionsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/transactions',
getProjection: ({ setup, query }) => {
const { transactionType, serviceName, transactionName } = query;
Expand All @@ -170,21 +162,14 @@ export const transactionsLocalFiltersRoute = createLocalFiltersRoute<
transactionName
});
},
queryRt: transactionsLocalFiltersQueryRt
});

const metricsLocalFiltersQueryRt = t.intersection([
t.type({
queryRt: t.type({
transactionType: t.string,
transactionName: t.string,
serviceName: t.string
}),
t.partial({
serviceNodeName: t.string
})
]);
});

export const metricsLocalFiltersRoute = createLocalFiltersRoute<
typeof metricsLocalFiltersQueryRt
>({
export const metricsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/metrics',
getProjection: ({ setup, query }) => {
const { serviceName, serviceNodeName } = query;
Expand All @@ -194,16 +179,17 @@ export const metricsLocalFiltersRoute = createLocalFiltersRoute<
serviceNodeName
});
},
queryRt: metricsLocalFiltersQueryRt
});

const errorGroupsLocalFiltersQueryRt = t.type({
serviceName: t.string
queryRt: t.intersection([
t.type({
serviceName: t.string
}),
t.partial({
serviceNodeName: t.string
})
])
});

export const errorGroupsLocalFiltersRoute = createLocalFiltersRoute<
typeof errorGroupsLocalFiltersQueryRt
>({
export const errorGroupsLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/errorGroups',
getProjection: ({ setup, query }) => {
const { serviceName } = query;
Expand All @@ -212,24 +198,22 @@ export const errorGroupsLocalFiltersRoute = createLocalFiltersRoute<
serviceName
});
},
queryRt: errorGroupsLocalFiltersQueryRt
});

const serviceNodesLocalFiltersQueryRt = t.type({
serviceName: t.string
queryRt: t.type({
serviceName: t.string
})
});

export const serviceNodesLocalFiltersRoute = createLocalFiltersRoute<
typeof serviceNodesLocalFiltersQueryRt
>({
export const serviceNodesLocalFiltersRoute = createLocalFiltersRoute({
path: '/api/apm/ui_filters/local_filters/serviceNodes',
getProjection: ({ setup, query }) => {
return getServiceNodesProjection({
setup,
serviceName: query.serviceName
});
},
queryRt: serviceNodesLocalFiltersQueryRt
queryRt: t.type({
serviceName: t.string
})
});

type BaseQueryType = typeof localUiBaseQueryRt;
Expand Down

0 comments on commit 0442cb8

Please sign in to comment.