Skip to content

Commit f4dd11b

Browse files
Updated PLR and TR list pages to handle All projects properly
1 parent 4f8fa7b commit f4dd11b

5 files changed

Lines changed: 62 additions & 56 deletions

File tree

frontend/packages/pipelines-plugin/src/components/pipelineruns/hooks/usePipelineRuns.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ const useRuns = <Kind extends K8sResourceCommon>(
3434
const watchOptions = React.useMemo(() => {
3535
// reset cached runs as the options have changed
3636
etcdRunsRef.current = [];
37-
return namespace
38-
? {
39-
groupVersionKind,
40-
namespace,
41-
isList,
42-
selector: optionsMemo?.selector,
43-
name: optionsMemo?.name,
44-
}
45-
: null;
37+
return {
38+
groupVersionKind,
39+
namespace: namespace || undefined,
40+
isList,
41+
selector: optionsMemo?.selector,
42+
name: optionsMemo?.name,
43+
};
4644
}, [groupVersionKind, namespace, optionsMemo, isList]);
4745

4846
const [resources, loaded, error] = useK8sWatchResource(watchOptions);

frontend/packages/pipelines-plugin/src/components/pipelineruns/hooks/useTektonResults.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,51 +52,49 @@ const useTRRuns = <Kind extends K8sResourceCommon>(
5252
// eslint-disable-next-line consistent-return
5353
React.useEffect(() => {
5454
let disposed = false;
55-
if (namespace) {
56-
(async () => {
57-
try {
58-
const tkPipelineRuns = await getRuns(namespace, options, nextPageToken, localCacheKey);
59-
if (!disposed) {
60-
const token = tkPipelineRuns[1].nextPageToken;
61-
const callInflight = !!tkPipelineRuns?.[2];
62-
const loaded = !callInflight;
63-
if (!callInflight) {
64-
setResult((cur) => [
65-
nextPageToken ? [...cur[0], ...tkPipelineRuns[0]] : tkPipelineRuns[0],
66-
loaded,
67-
undefined,
68-
token
69-
? (() => {
70-
// ensure we can only call this once
71-
let executed = false;
72-
return () => {
73-
if (!disposed && !executed) {
74-
executed = true;
75-
// trigger the update
76-
setNextPageToken(token);
77-
return true;
78-
}
79-
return false;
80-
};
81-
})()
82-
: undefined,
83-
]);
84-
}
55+
(async () => {
56+
try {
57+
const tkPipelineRuns = await getRuns(namespace, options, nextPageToken, localCacheKey);
58+
if (!disposed) {
59+
const token = tkPipelineRuns[1].nextPageToken;
60+
const callInflight = !!tkPipelineRuns?.[2];
61+
const loaded = !callInflight;
62+
if (!callInflight) {
63+
setResult((cur) => [
64+
nextPageToken ? [...cur[0], ...tkPipelineRuns[0]] : tkPipelineRuns[0],
65+
loaded,
66+
undefined,
67+
token
68+
? (() => {
69+
// ensure we can only call this once
70+
let executed = false;
71+
return () => {
72+
if (!disposed && !executed) {
73+
executed = true;
74+
// trigger the update
75+
setNextPageToken(token);
76+
return true;
77+
}
78+
return false;
79+
};
80+
})()
81+
: undefined,
82+
]);
8583
}
86-
} catch (e) {
87-
if (!disposed) {
88-
if (nextPageToken) {
89-
setResult((cur) => [cur[0], cur[1], e, undefined]);
90-
} else {
91-
setResult([[], false, e, undefined]);
92-
}
84+
}
85+
} catch (e) {
86+
if (!disposed) {
87+
if (nextPageToken) {
88+
setResult((cur) => [cur[0], cur[1], e, undefined]);
89+
} else {
90+
setResult([[], false, e, undefined]);
9391
}
9492
}
95-
})();
96-
return () => {
97-
disposed = true;
98-
};
99-
}
93+
}
94+
})();
95+
return () => {
96+
disposed = true;
97+
};
10098
}, [namespace, options, nextPageToken, localCacheKey, getRuns]);
10199
return result;
102100
};

frontend/packages/pipelines-plugin/src/components/pipelineruns/utils/tekton-results.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@console/dynamic-plugin-sdk/src';
88
import { RouteModel } from '@console/internal/models';
99
import { k8sGet } from '@console/internal/module/k8s';
10+
import { ALL_NAMESPACES_KEY } from '@console/shared/src/constants';
1011
import { consoleProxyFetch, consoleProxyFetchJSON } from '@console/shared/src/utils/proxy';
1112
import {
1213
DELETED_RESOURCE_IN_K8S_ANNOTATION,
@@ -224,7 +225,8 @@ export const createTektonResultsUrl = async (
224225
if (!tektonResultUrl) {
225226
throw new Error('route.spec.host is undefined');
226227
}
227-
const url = `https://${tektonResultUrl}/apis/results.tekton.dev/v1alpha2/parents/${namespace}/results/-/records?${new URLSearchParams(
228+
const namespaceToSearch = namespace && namespace !== ALL_NAMESPACES_KEY ? namespace : '-';
229+
const url = `https://${tektonResultUrl}/apis/results.tekton.dev/v1alpha2/parents/${namespaceToSearch}/results/-/records?${new URLSearchParams(
228230
{
229231
// default sort should always be by `create_time desc`
230232
// order_by: 'create_time desc', not supported yet

frontend/packages/pipelines-plugin/src/components/repository/RepositoryPipelineRunRow.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
ExternalLink,
1111
} from '@console/internal/components/utils';
1212
import { referenceForModel } from '@console/internal/module/k8s';
13-
import { DELETED_RESOURCE_IN_K8S_ANNOTATION } from '../../const';
13+
import {
14+
DELETED_RESOURCE_IN_K8S_ANNOTATION,
15+
RESOURCE_LOADED_FROM_RESULTS_ANNOTATION,
16+
} from '../../const';
1417
import * as SignedPipelinerunIcon from '../../images/signed-badge.svg';
1518
import { PipelineRunModel } from '../../models';
1619
import { PipelineRunKind, TaskRunKind } from '../../types';
@@ -79,7 +82,8 @@ const RepositoryPipelineRunRow: React.FC<RowFunctionArgs<PipelineRunKind>> = ({
7982
</div>
8083
</Tooltip>
8184
) : null}
82-
{obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ? (
85+
{obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ||
86+
obj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION] === 'true' ? (
8387
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
8488
<div className="opp-pipeline-run-list__results-indicator">
8589
<ArchiveIcon />

frontend/packages/pipelines-plugin/src/components/taskruns/list-page/TaskRunsRow.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { useTranslation } from 'react-i18next';
55
import { TableData, RowFunctionArgs } from '@console/internal/components/factory';
66
import { ResourceLink, Timestamp } from '@console/internal/components/utils';
77
import { referenceForModel } from '@console/internal/module/k8s';
8-
import { DELETED_RESOURCE_IN_K8S_ANNOTATION } from '../../../const';
8+
import {
9+
DELETED_RESOURCE_IN_K8S_ANNOTATION,
10+
RESOURCE_LOADED_FROM_RESULTS_ANNOTATION,
11+
} from '../../../const';
912
import { TaskRunModel, PipelineModel } from '../../../models';
1013
import { TaskRunKind } from '../../../types';
1114
import { getTaskRunKebabActions } from '../../../utils/pipeline-actions';
@@ -35,7 +38,8 @@ const TaskRunsRow: React.FC<RowFunctionArgs<TaskRunKind>> = ({ obj, customData }
3538
data-test-id={obj.metadata.name}
3639
nameSuffix={
3740
<>
38-
{obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ? (
41+
{obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ||
42+
obj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION] === 'true' ? (
3943
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
4044
<div className="opp-task-run-list__results-indicator">
4145
<ArchiveIcon />

0 commit comments

Comments
 (0)