Skip to content

Commit 5ce2ab0

Browse files
committed
NCL-8675 Extend Group Build detail page Builds list with latest Brew Push status
1 parent 458a4ce commit 5ce2ab0

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

src/components/GroupBuildDetailPage/GroupBuildDetailPage.tsx

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { useCallback, useEffect, useState } from 'react';
1+
import { useCallback, useEffect, useMemo, useState } from 'react';
22

33
import { Build, GroupBuild } from 'pnc-api-types-ts';
44

55
import { breadcrumbData } from 'common/breadcrumbData';
6+
import { buildEntityAttributes } from 'common/buildEntityAttributes';
67
import { groupBuildEntityAttributes } from 'common/groupBuildEntityAttributes';
78

89
import { useComponentQueryParams } from 'hooks/useComponentQueryParams';
910
import { useParamsRequired } from 'hooks/useParamsRequired';
1011
import {
12+
hasBrewPushFinished,
1113
hasBuildStarted,
1214
hasBuildStatusChanged,
1315
hasGroupBuildStatusChanged,
@@ -39,7 +41,18 @@ import * as groupBuildApi from 'services/groupBuildApi';
3941

4042
import { refreshPage } from 'utils/refreshHelper';
4143
import { generatePageTitle } from 'utils/titleHelper';
42-
import { createDateTime } from 'utils/utils';
44+
import { createDateTime, debounce } from 'utils/utils';
45+
46+
const buildsListColumns = [
47+
buildEntityAttributes.status.id,
48+
buildEntityAttributes.name.id,
49+
buildEntityAttributes.buildConfigName.id,
50+
buildEntityAttributes.submitTime.id,
51+
buildEntityAttributes.startTime.id,
52+
buildEntityAttributes.endTime.id,
53+
buildEntityAttributes['user.username'].id,
54+
buildEntityAttributes.brewPush.id,
55+
];
4356

4457
interface IGroupBuildDetailPageProps {
4558
componentId?: string;
@@ -56,10 +69,15 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
5669
const serviceContainerGroupBuildRunner = serviceContainerGroupBuild.run;
5770
const serviceContainerGroupBuildSetter = serviceContainerGroupBuild.setData;
5871

59-
const serviceContainerGroupBuildBuilds = useServiceContainer(groupBuildApi.getBuilds);
72+
const serviceContainerGroupBuildBuilds = useServiceContainer(groupBuildApi.getBuildsWithBrewPush);
6073
const serviceContainerGroupBuildBuildsRunner = serviceContainerGroupBuildBuilds.run;
6174
const serviceContainerGroupBuildBuildsSetter = serviceContainerGroupBuildBuilds.setData;
6275

76+
const serviceContainerGroupBuildBuildsRunnerDebounced = useMemo(
77+
() => debounce(serviceContainerGroupBuildBuildsRunner),
78+
[serviceContainerGroupBuildBuildsRunner]
79+
);
80+
6381
const serviceContainerDependencyGraph = useServiceContainer(groupBuildApi.getDependencyGraph);
6482
const serviceContainerDependencyGraphRunner = serviceContainerDependencyGraph.run;
6583
const serviceContainerDependencyGraphSetter = serviceContainerDependencyGraph.setData;
@@ -83,7 +101,7 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
83101
serviceContainerGroupBuildSetter(wsGroupBuild);
84102
} else if (hasBuildStarted(wsData, { groupBuildId })) {
85103
// very exceptional use case, mostly it means backend issues
86-
serviceContainerGroupBuildBuildsRunner({
104+
serviceContainerGroupBuildBuildsRunnerDebounced({
87105
serviceData: { id: groupBuildId },
88106
requestConfig: { params: groupBuildBuildsComponentQueryParamsObject },
89107
});
@@ -102,15 +120,25 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
102120
vertices: { ...serviceContainerDependencyGraph.data.vertices, [wsBuild.id]: updatedVertex },
103121
});
104122
}
123+
} else if (
124+
hasBrewPushFinished(wsData, {
125+
buildIds: serviceContainerGroupBuildBuilds.data?.content?.map((build) => build.id) ?? [],
126+
})
127+
) {
128+
serviceContainerGroupBuildBuildsRunnerDebounced({
129+
serviceData: { id: groupBuildId },
130+
requestConfig: { params: groupBuildBuildsComponentQueryParamsObject },
131+
});
105132
}
106133
},
107134
[
108135
serviceContainerGroupBuildSetter,
109136
groupBuildId,
110-
serviceContainerGroupBuildBuildsRunner,
137+
serviceContainerGroupBuildBuildsRunnerDebounced,
111138
serviceContainerGroupBuildBuildsSetter,
112139
serviceContainerDependencyGraphSetter,
113140
serviceContainerDependencyGraph.data,
141+
serviceContainerGroupBuildBuilds.data,
114142
groupBuildBuildsComponentQueryParamsObject,
115143
]
116144
)
@@ -187,6 +215,7 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
187215
{...{
188216
serviceContainerBuilds: serviceContainerGroupBuildBuilds,
189217
componentId,
218+
columns: buildsListColumns,
190219
}}
191220
/>
192221
</ContentBox>

0 commit comments

Comments
 (0)