Skip to content

Commit a193adc

Browse files
authored
✨ Refactor RetrieveConfigWizard to be inline with DiscoverImportWizard (#2547)
Apply the same kind of changes made to hooks and views with the `DiscoverImportWizard` to the older `RetrieveConfigWizard`. This will help keep the structure and layout the same. Needs #2545 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Retrieve Configurations wizard updated with a clearer title, description and improved flow. * Results view refined: status icons, task IDs link directly to task details, and a single “No tasks were submitted” message appears at the top when applicable. * **Style** * Wording revised to “Successful Submission(s)” and translations reorganized for clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Scott J Dickerson <[email protected]>
1 parent e3653c9 commit a193adc

File tree

4 files changed

+110
-119
lines changed

4 files changed

+110
-119
lines changed

client/public/locales/en/translation.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"reset": "Reset",
5454
"review": "Review",
5555
"retrieve": "Retrieve",
56-
"retrieveConfigurations": "Retrieve configurations",
5756
"save": "Save",
5857
"saveAndReview": "Save and review",
5958
"selectAll": "Select all",
@@ -167,7 +166,6 @@
167166
"newStakeholderGroup": "New stakeholder group",
168167
"newTag": "New Tag",
169168
"newTagCategory": "New tag category",
170-
"retrieveConfigurations": "Retrieve configurations",
171169
"update": "Update {{what}}",
172170
"updateArchetype": "Update archetype",
173171
"updateApplication": "Update application",
@@ -669,9 +667,10 @@
669667
}
670668
},
671669
"retrieveConfigWizard": {
670+
"title": "Retrieve Configurations",
671+
"description": "Retrieve configurations from the selected applications.",
672672
"selectedCount": "{{count}} of {{total}} applications selected",
673673
"noApplicationsWithSourcePlatforms": "No applications with source platforms selected.",
674-
"noTasksSubmitted": "No tasks were submitted.",
675674
"toast": {
676675
"submittedOk": "Application manifest fetches submitted",
677676
"submittedFailed": "Application manifest fetches failed"
@@ -680,10 +679,11 @@
680679
"title": "Configuration Retrieval Results",
681680
"summary": "Summary of configuration retrieval task submissions.",
682681
"noResults": "No results available.",
682+
"noTasksSubmitted": "No tasks were submitted.",
683683
"failedSubmissions_one": "Failed Submission",
684684
"failedSubmissions_other": "Failed Submissions ({{count}})",
685-
"successSubmissions_one": "Success Submission",
686-
"successSubmissions_other": "Success Submissions ({{count}})"
685+
"successSubmissions_one": "Successful Submission",
686+
"successSubmissions_other": "Successful Submissions ({{count}})"
687687
},
688688
"review": {
689689
"description_one": "This application is ready to retrieve configurations from its source platform. The application's platform coordinates will be used to connect to the platform and build the application's discovery manifest.",

client/src/app/pages/applications/retrieve-config-wizard/results.tsx

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TextVariants,
1010
Grid,
1111
GridItem,
12-
Button,
12+
Icon,
1313
} from "@patternfly/react-core";
1414
import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";
1515
import { useTranslation } from "react-i18next";
@@ -70,15 +70,30 @@ export const Results: React.FC<ResultsProps> = ({ results }) => {
7070
</TextContent>
7171

7272
<Grid hasGutter>
73+
{success.length === 0 && failure.length === 0 && (
74+
<GridItem span={12}>
75+
<Card>
76+
<CardBody>
77+
<Text>
78+
{t("retrieveConfigWizard.results.noTasksSubmitted")}
79+
</Text>
80+
</CardBody>
81+
</Card>
82+
</GridItem>
83+
)}
84+
7385
{success.length > 0 && (
7486
<GridItem span={12}>
7587
<Card>
7688
<CardHeader>
7789
<CardTitle>
78-
<CheckCircleIcon
79-
color="var(--pf-global--success-color--100)"
90+
<Icon
91+
status="success"
92+
isInline
8093
style={{ marginRight: "8px" }}
81-
/>
94+
>
95+
<CheckCircleIcon />
96+
</Icon>
8297
{t("retrieveConfigWizard.results.successSubmissions", {
8398
count: success.length,
8499
})}
@@ -90,7 +105,6 @@ export const Results: React.FC<ResultsProps> = ({ results }) => {
90105
<Tr>
91106
<Th>{t("terms.application")}</Th>
92107
<Th>{t("terms.task")}</Th>
93-
<Th>{t("actions.actions")}</Th>
94108
</Tr>
95109
</Thead>
96110
<Tbody>
@@ -108,19 +122,10 @@ export const Results: React.FC<ResultsProps> = ({ results }) => {
108122
)}
109123
</div>
110124
</Td>
111-
<Td>{result.task.id}</Td>
112125
<Td>
113-
<Button
114-
variant="link"
115-
component={(props) => (
116-
<Link
117-
{...props}
118-
to={`/tasks/${result.task.id}`}
119-
/>
120-
)}
121-
>
122-
View Task
123-
</Button>
126+
<Link to={`/tasks/${result.task.id}`}>
127+
{result.task.id}
128+
</Link>
124129
</Td>
125130
</Tr>
126131
))}
@@ -136,10 +141,9 @@ export const Results: React.FC<ResultsProps> = ({ results }) => {
136141
<Card>
137142
<CardHeader>
138143
<CardTitle>
139-
<ExclamationTriangleIcon
140-
color="var(--pf-global--danger-color--100)"
141-
style={{ marginRight: "8px" }}
142-
/>
144+
<Icon status="danger" isInline style={{ marginRight: "8px" }}>
145+
<ExclamationTriangleIcon />
146+
</Icon>
143147
{t("retrieveConfigWizard.results.failedSubmissions", {
144148
count: failure.length,
145149
})}
@@ -196,16 +200,6 @@ export const Results: React.FC<ResultsProps> = ({ results }) => {
196200
</Card>
197201
</GridItem>
198202
)}
199-
200-
{success.length === 0 && failure.length === 0 && (
201-
<GridItem span={12}>
202-
<Card>
203-
<CardBody>
204-
<Text>{t("retrieveConfigWizard.noTasksSubmitted")}</Text>
205-
</CardBody>
206-
</Card>
207-
</GridItem>
208-
)}
209203
</Grid>
210204
</>
211205
);

client/src/app/pages/applications/retrieve-config-wizard/retrieve-config-wizard.tsx

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import { yupResolver } from "@hookform/resolvers/yup";
1414
import * as yup from "yup";
1515
import { group } from "radash";
1616

17-
import { ApplicationManifestTask, EmptyObject, New } from "@app/api/models";
1817
import { NotificationsContext } from "@app/components/NotificationsContext";
19-
import { useCreateTaskMutation } from "@app/queries/tasks";
2018
import { DecoratedApplication } from "../useDecoratedApplications";
2119
import { Review } from "./review";
2220
import { Results, ResultsData } from "./results";
21+
import { useStartFetchApplicationManifest } from "./useStartFetchApplicationManifest";
2322

2423
export const RetrieveConfigWizard: React.FC<IRetrieveConfigWizard> = ({
2524
isOpen,
@@ -38,17 +37,12 @@ export const RetrieveConfigWizard: React.FC<IRetrieveConfigWizard> = ({
3837
);
3938
};
4039

41-
interface IRetrieveConfigWizard {
40+
export interface IRetrieveConfigWizard {
4241
applications?: DecoratedApplication[];
4342
onClose: () => void;
4443
isOpen: boolean;
4544
}
4645

47-
enum StepId {
48-
Review = 1,
49-
Results = 2,
50-
}
51-
5246
export interface FormValues {
5347
ready: DecoratedApplication[];
5448
notReady: DecoratedApplication[];
@@ -125,7 +119,7 @@ const RetrieveConfigWizardInner: React.FC<IRetrieveConfigWizard> = ({
125119
return (
126120
<Modal
127121
variant={ModalVariant.medium}
128-
title={t("dialog.title.retrieveConfigurations")}
122+
title={t("retrieveConfigWizard.title")}
129123
isOpen={isOpen}
130124
onClose={handleCancel}
131125
footer={
@@ -146,7 +140,7 @@ const RetrieveConfigWizardInner: React.FC<IRetrieveConfigWizard> = ({
146140
<FormProvider {...methods}>
147141
<Modal
148142
variant={ModalVariant.large}
149-
aria-label={t("dialog.title.retrieveConfigurations")}
143+
aria-label={t("retrieveConfigWizard.title")}
150144
isOpen={isOpen}
151145
showClose={false}
152146
hasNoBodyWrapper
@@ -157,13 +151,13 @@ const RetrieveConfigWizardInner: React.FC<IRetrieveConfigWizard> = ({
157151
header={
158152
<WizardHeader
159153
onClose={handleCancel}
160-
title={t("dialog.title.retrieveConfigurations")}
161-
description={t("dialog.message.retrieveConfigurations")}
154+
title={t("retrieveConfigWizard.title")}
155+
description={t("retrieveConfigWizard.description")}
162156
/>
163157
}
164158
>
165159
<WizardStep
166-
id={StepId.Review}
160+
id="review"
167161
name="Review"
168162
footer={{
169163
nextButtonText: showResults
@@ -185,73 +179,3 @@ const RetrieveConfigWizardInner: React.FC<IRetrieveConfigWizard> = ({
185179
</FormProvider>
186180
);
187181
};
188-
189-
const useStartFetchApplicationManifest = () => {
190-
const { mutateAsync: createTask } = useCreateTaskMutation<
191-
EmptyObject,
192-
ApplicationManifestTask
193-
>();
194-
195-
const createAndSubmitTask = async (
196-
application: DecoratedApplication
197-
): Promise<{
198-
success?: {
199-
task: ApplicationManifestTask;
200-
application: DecoratedApplication;
201-
};
202-
failure?: {
203-
message: string;
204-
cause: Error;
205-
application: DecoratedApplication;
206-
newTask: New<ApplicationManifestTask>;
207-
};
208-
}> => {
209-
const newTask: New<ApplicationManifestTask> = {
210-
name: `${application.name}.${application.id}.application-manifest`,
211-
kind: "application-manifest",
212-
application: { id: application.id, name: application.name },
213-
state: "Ready",
214-
data: {},
215-
};
216-
217-
try {
218-
const task = await createTask(newTask);
219-
return { success: { task, application } };
220-
} catch (error) {
221-
return {
222-
failure: {
223-
message: "Failed to submit the application manifest fetch task",
224-
cause: error as Error,
225-
application,
226-
newTask,
227-
},
228-
};
229-
}
230-
};
231-
232-
const submitTasks = async (applications: DecoratedApplication[]) => {
233-
const results = await Promise.allSettled(
234-
applications.map(createAndSubmitTask)
235-
);
236-
237-
const success = [];
238-
const failure = [];
239-
240-
for (const result of results) {
241-
if (result.status === "fulfilled") {
242-
if (result.value.success) {
243-
success.push(result.value.success);
244-
}
245-
if (result.value.failure) {
246-
failure.push(result.value.failure);
247-
}
248-
}
249-
}
250-
251-
return { success, failure };
252-
};
253-
254-
return {
255-
submitTasks,
256-
};
257-
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { EmptyObject, ApplicationManifestTask, New } from "@app/api/models";
2+
import { useCreateTaskMutation } from "@app/queries/tasks";
3+
import { DecoratedApplication } from "../useDecoratedApplications";
4+
5+
export const useStartFetchApplicationManifest = () => {
6+
const { mutateAsync: createTask } = useCreateTaskMutation<
7+
EmptyObject,
8+
ApplicationManifestTask
9+
>();
10+
11+
const createAndSubmitTask = async (
12+
application: DecoratedApplication
13+
): Promise<{
14+
success?: {
15+
task: ApplicationManifestTask;
16+
application: DecoratedApplication;
17+
};
18+
failure?: {
19+
message: string;
20+
cause: Error;
21+
application: DecoratedApplication;
22+
newTask: New<ApplicationManifestTask>;
23+
};
24+
}> => {
25+
const newTask: New<ApplicationManifestTask> = {
26+
name: `${application.name}.${application.id}.application-manifest`,
27+
kind: "application-manifest",
28+
application: { id: application.id, name: application.name },
29+
state: "Ready",
30+
data: {},
31+
};
32+
33+
try {
34+
const task = await createTask(newTask);
35+
return { success: { task, application } };
36+
} catch (error) {
37+
return {
38+
failure: {
39+
message: "Failed to submit the application manifest fetch task",
40+
cause: error as Error,
41+
application,
42+
newTask,
43+
},
44+
};
45+
}
46+
};
47+
48+
const submitTasks = async (applications: DecoratedApplication[]) => {
49+
const results = await Promise.allSettled(
50+
applications.map(createAndSubmitTask)
51+
);
52+
53+
const success = [];
54+
const failure = [];
55+
56+
for (const result of results) {
57+
if (result.status === "fulfilled") {
58+
if (result.value.success) {
59+
success.push(result.value.success);
60+
}
61+
if (result.value.failure) {
62+
failure.push(result.value.failure);
63+
}
64+
}
65+
}
66+
67+
return { success, failure };
68+
};
69+
70+
return {
71+
submitTasks,
72+
};
73+
};

0 commit comments

Comments
 (0)