logs list page should respect the for-me variant

This commit is contained in:
jasquat 2023-02-23 10:23:26 -05:00
parent 1daaf7995c
commit 81a402dd7d
3 changed files with 20 additions and 8 deletions

View File

@ -110,7 +110,11 @@ export default function AdminRoutes() {
/> />
<Route <Route
path="logs/:process_model_id/:process_instance_id" path="logs/:process_model_id/:process_instance_id"
element={<ProcessInstanceLogList />} element={<ProcessInstanceLogList variant="all" />}
/>
<Route
path="logs/for-me/:process_model_id/:process_instance_id"
element={<ProcessInstanceLogList variant="for-me" />}
/> />
<Route <Route
path="process-instances" path="process-instances"

View File

@ -12,17 +12,23 @@ import {
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { useUriListForPermissions } from '../hooks/UriListForPermissions';
export default function ProcessInstanceLogList() { type OwnProps = {
variant: string;
};
export default function ProcessInstanceLogList({ variant }: OwnProps) {
const params = useParams(); const params = useParams();
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const [processInstanceLogs, setProcessInstanceLogs] = useState([]); const [processInstanceLogs, setProcessInstanceLogs] = useState([]);
const [pagination, setPagination] = useState(null); const [pagination, setPagination] = useState(null);
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
`${params.process_model_id}`
);
const { targetUris } = useUriListForPermissions(); const { targetUris } = useUriListForPermissions();
const isDetailedView = searchParams.get('detailed') === 'true'; const isDetailedView = searchParams.get('detailed') === 'true';
let processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${params.process_model_id}`;
if (variant === 'all') {
processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}`;
}
useEffect(() => { useEffect(() => {
const setProcessInstanceLogListFromResult = (result: any) => { const setProcessInstanceLogListFromResult = (result: any) => {
setProcessInstanceLogs(result.results); setProcessInstanceLogs(result.results);
@ -65,7 +71,7 @@ export default function ProcessInstanceLogList() {
<td> <td>
<Link <Link
data-qa="process-instance-show-link" data-qa="process-instance-show-link"
to={`/admin/process-instances/${modifiedProcessModelId}/${rowToUse.process_instance_id}/${rowToUse.spiff_step}`} to={`${processInstanceShowPageBaseUrl}/${rowToUse.process_instance_id}/${rowToUse.spiff_step}`}
> >
{convertSecondsToFormattedDateTime(rowToUse.timestamp)} {convertSecondsToFormattedDateTime(rowToUse.timestamp)}
</Link> </Link>
@ -111,7 +117,7 @@ export default function ProcessInstanceLogList() {
}, },
[ [
`Process Instance: ${params.process_instance_id}`, `Process Instance: ${params.process_instance_id}`,
`/admin/process-instances/${params.process_model_id}/${params.process_instance_id}`, `${processInstanceShowPageBaseUrl}/${params.process_instance_id}`,
], ],
['Logs'], ['Logs'],
]} ]}

View File

@ -116,8 +116,10 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
}; };
let processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${params.process_model_id}/${params.process_instance_id}`; let processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${params.process_model_id}/${params.process_instance_id}`;
let processInstanceLogListPageBaseUrl = `/admin/logs/for-me/${params.process_model_id}/${params.process_instance_id}`;
if (variant === 'all') { if (variant === 'all') {
processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}/${params.process_instance_id}`; processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}/${params.process_instance_id}`;
processInstanceLogListPageBaseUrl = `/admin/logs/${params.process_model_id}/${params.process_instance_id}`;
} }
useEffect(() => { useEffect(() => {
@ -459,7 +461,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
size="sm" size="sm"
className="button-white-background" className="button-white-background"
data-qa="process-instance-log-list-link" data-qa="process-instance-log-list-link"
href={`/admin/logs/${modifiedProcessModelId}/${params.process_instance_id}`} href={`${processInstanceLogListPageBaseUrl}`}
> >
Logs Logs
</Button> </Button>