Skip to content

Commit 5124621

Browse files
committed
refactor
1 parent ee0c5a8 commit 5124621

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/components/ControlPlane/FluxList.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function FluxList() {
3737
isReady: boolean;
3838
statusUpdateTime?: string;
3939
item: unknown;
40-
readyStatus: undefined | { message?: string };
40+
readyStatus: string;
4141
};
4242

4343
const gitReposColumns: AnalyticalTableColumnDefinition[] = useMemo(
@@ -70,7 +70,7 @@ export default function FluxList() {
7070
transitionTime={
7171
cellData.cell.row.original?.statusUpdateTime ? cellData.cell.row.original?.statusUpdateTime : ''
7272
}
73-
message={cellData.cell.row.original?.readyStatus?.message}
73+
message={cellData.cell.row.original?.readyStatus}
7474
/>
7575
) : null,
7676
},
@@ -115,7 +115,7 @@ export default function FluxList() {
115115
transitionTime={
116116
cellData.cell.row.original?.statusUpdateTime ? cellData.cell.row.original?.statusUpdateTime : ''
117117
}
118-
message={cellData.cell.row.original?.readyStatus?.message}
118+
message={cellData.cell.row.original?.readyStatus}
119119
/>
120120
</span>
121121
) : null,
@@ -144,26 +144,28 @@ export default function FluxList() {
144144

145145
const gitReposRows: FluxRow[] =
146146
gitReposData?.items?.map((item) => {
147+
const readyObject = item.status?.conditions?.find((x) => x.type === 'Ready');
147148
return {
148149
name: item.metadata.name,
149-
isReady: item?.status?.conditions?.find((x) => x.type === 'Ready')?.status === 'True',
150-
statusUpdateTime: item.status?.conditions?.find((x) => x.type === 'Ready')?.lastTransitionTime,
150+
isReady: readyObject?.status === 'True',
151+
statusUpdateTime: readyObject?.lastTransitionTime,
151152
revision: shortenCommitHash(item.status.artifact?.revision ?? '-'),
152153
created: timeAgo.format(new Date(item.metadata.creationTimestamp)),
153154
item: item,
154-
readyStatus: item.status?.conditions?.find((x) => x.type === 'Ready'),
155+
readyStatus: readyObject?.message ?? readyObject?.reason ?? '',
155156
};
156157
}) ?? [];
157158

158159
const kustomizationsRows: FluxRow[] =
159160
kustmizationData?.items?.map((item) => {
161+
const readyObject = item.status?.conditions?.find((x) => x.type === 'Ready');
160162
return {
161163
name: item.metadata.name,
162-
isReady: item.status?.conditions?.find((x) => x.type === 'Ready')?.status === 'True',
163-
statusUpdateTime: item.status?.conditions?.find((x) => x.type === 'Ready')?.lastTransitionTime,
164+
isReady: readyObject?.status === 'True',
165+
statusUpdateTime: readyObject?.lastTransitionTime,
164166
created: timeAgo.format(new Date(item.metadata.creationTimestamp)),
165167
item: item,
166-
readyStatus: item.status?.conditions?.find((x) => x.type === 'Ready'),
168+
readyStatus: readyObject?.message ?? '',
167169
};
168170
}) ?? [];
169171

src/lib/api/types/crossplane/listManagedResources.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type ManagedResourcesResponse = [
1515
type: 'Ready' | 'Synced' | unknown;
1616
status: 'True' | 'False';
1717
lastTransitionTime: string;
18+
message?: string;
19+
reason?: string;
1820
},
1921
];
2022
};

src/lib/api/types/crossplane/listProviders.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export type ProvidersListResponse = {
1717
type: 'Healthy' | 'Installed' | unknown;
1818
status: 'True' | 'False';
1919
lastTransitionTime: string;
20+
message?: string;
21+
reason?: string;
2022
},
2123
];
2224
};

src/lib/api/types/flux/listGitRepo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export type GitReposResponse = {
2020
status: string;
2121
type: string;
2222
lastTransitionTime: string;
23+
message?: string;
24+
reason?: string;
2325
},
2426
];
2527
};

0 commit comments

Comments
 (0)