diff --git a/frontend/awx/access/common/useViewActivityStream.tsx b/frontend/awx/access/common/useViewActivityStream.tsx index f1aa3f4de7..d751f26e0e 100644 --- a/frontend/awx/access/common/useViewActivityStream.tsx +++ b/frontend/awx/access/common/useViewActivityStream.tsx @@ -18,7 +18,11 @@ export function useViewActivityStream() { const location = useLocation(); const firstURLItems = location.pathname.split('/')[1]; const secondURLItems = location.pathname.split('/')[2]; + const thirdUrlItems = location.pathname.split('/')[3]; const isSchedule = location.pathname.split('/').includes('schedules'); + const isNumeric = (value: string) => { + return /^-?\d+$/.test(value); + }; const pathIdentifier = isSchedule ? 'schedules' @@ -46,10 +50,18 @@ export function useViewActivityStream() { case 'instance-groups': type = 'instance_group'; break; + case 'templates': + type = secondURLItems.replace(/-/g, '_'); + break; default: type = pathIdentifier.slice(0, -1); break; } + // add host__id=..., instance_group__id=... depending on url + const query = { query: { type } }; + if (isNumeric(thirdUrlItems)) { + query['query'][`${type}__id`] = thirdUrlItems; + } return useMemo[] | []>(() => { if (config?.license_info.product_name !== 'AWX') return []; return [ @@ -58,9 +70,9 @@ export function useViewActivityStream() { selection: PageActionSelection.Single, icon: HistoryIcon, label: t('View activity stream'), - onClick: () => pageNavigate(AwxRoute.ActivityStream, { query: { type } }), + onClick: () => pageNavigate(AwxRoute.ActivityStream, query), }, { type: PageActionType.Seperator }, ]; - }, [type, pageNavigate, t, config?.license_info.product_name]); + }, [pageNavigate, t, config?.license_info.product_name, query]); } diff --git a/frontend/awx/common/useAwxView.tsx b/frontend/awx/common/useAwxView.tsx index 15c6519e90..96ef13b2d4 100644 --- a/frontend/awx/common/useAwxView.tsx +++ b/frontend/awx/common/useAwxView.tsx @@ -107,6 +107,13 @@ export function useAwxView(options: { .split('+') .join(',')}&or__object2__in=${values[0].split('+').join(',')}`; } + // add Activity Stream id filtering, like host__id=2 + for (const keyId in filterState) { + if (/.+__id/.test(keyId)) { + const valId: string = filterState[keyId]; + queryString += `&${keyId}=${valId}`; + } + } } else if (toolbarFilter.query === 'search') { queryString += values.map((value) => `${toolbarFilter.query}=${value}`).join('&'); } else {