Skip to content

Commit 9d1af74

Browse files
committed
[MTV-1686] Simplify/update migration plan status cell (part 2)
Signed-off-by: Jeff Puzzo <[email protected]>
1 parent ce30c1a commit 9d1af74

27 files changed

+896
-136
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { FC, PropsWithChildren } from 'react';
2+
3+
import { Spinner, SpinnerProps } from '@patternfly/react-core';
4+
5+
type LoadingSpinnerProps = PropsWithChildren &
6+
SpinnerProps & {
7+
isLoading: boolean;
8+
};
9+
10+
const LoadingSpinner: FC<LoadingSpinnerProps> = ({ isLoading, children, ...spinnerProps }) =>
11+
isLoading ? <Spinner {...spinnerProps} /> : <>{children}</>;
12+
13+
export default LoadingSpinner;

packages/common/src/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './FormGroupWithHelpText';
66
export * from './HelpIconPopover';
77
export * from './Icons';
88
export * from './LoadingDots';
9+
export { default as LoadingSpinner } from './LoadingSpinner';
910
export * from './Page';
1011
export * from './QueryClientHoc';
1112
export * from './TableView';

packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json

+13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"31 days": "31 days",
5353
"404: Not Found": "404: Not Found",
5454
"7 days": "7 days",
55+
"99+ VMs": "99+ VMs",
5556
"A CA certificate to be trusted when connecting to Openshift API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to Openshift API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
5657
"A CA certificate to be trusted when connecting to the ESXi API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the ESXi API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
5758
"A CA certificate to be trusted when connecting to the OpenStack Identity (Keystone) endpoint. Ensure the CA certificate format is valid. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the OpenStack Identity (Keystone) endpoint. Ensure the CA certificate format is valid. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
@@ -75,6 +76,7 @@
7576
"All networks detected on the selected VMs require a mapping.": "All networks detected on the selected VMs require a mapping.",
7677
"All storages detected on the selected VMs require a mapping.": "All storages detected on the selected VMs require a mapping.",
7778
"All virtual machines planned for migration are selected for deletion, deleting all virtual machines from a migration plan is not allowed.": "All virtual machines planned for migration are selected for deletion, deleting all virtual machines from a migration plan is not allowed.",
79+
"All VMs were migrated": "All VMs were migrated",
7880
"Application credential ID": "Application credential ID",
7981
"Application credential name": "Application credential name",
8082
"Application credential secret": "Application credential secret",
@@ -83,6 +85,8 @@
8385
"Archive migration plan": "Archive migration plan",
8486
"Archive Plan": "Archive Plan",
8587
"Archived": "Archived",
88+
"Archived plans cannot be edited": "Archived plans cannot be edited",
89+
"Archived plans cannot be started": "Archived plans cannot be started",
8690
"Archiving": "Archiving",
8791
"Are you sure you want to delete <1>{name}</1> in namespace <3>{namespace}</3>?": "Are you sure you want to delete <1>{name}</1> in namespace <3>{namespace}</3>?",
8892
"Are you sure you want to delete <1>{name}</1>?": "Are you sure you want to delete <1>{name}</1>?",
@@ -109,6 +113,7 @@
109113
"Cancel virtual machines from migration plan": "Cancel virtual machines from migration plan",
110114
"Canceled": "Canceled",
111115
"Cannot retrieve certificate": "Cannot retrieve certificate",
116+
"Cannot start": "Cannot start",
112117
"Category": "Category",
113118
"Certificate change detected": "Certificate change detected",
114119
"choose a different mapping for your migration plan": "choose a different mapping for your migration plan",
@@ -122,6 +127,7 @@
122127
"Click to unselect.": "Click to unselect.",
123128
"Cluster": "Cluster",
124129
"Clusters": "Clusters",
130+
"Complete": "Complete",
125131
"Completed {{completed}} of {{total}} {{name}} tasks": "Completed {{completed}} of {{total}} {{name}} tasks",
126132
"Completed at": "Completed at",
127133
"Concern": "Concern",
@@ -264,6 +270,7 @@
264270
"If your VMs use static IPs, click the Mappings tab of your plan, and choose a different target network mapping.<1></1>If your VMs don't use static IPs, you can ignore this message.": "If your VMs use static IPs, click the Mappings tab of your plan, and choose a different target network mapping.<1></1>If your VMs don't use static IPs, you can ignore this message.",
265271
"Image": "Image",
266272
"In warm migration, the VM disks are copied incrementally using changed block tracking (CBT) snapshots.\n The snapshots are created at one-hour intervals by default.\n You can change the snapshot interval by updating the forklift-controller deployment.": "In warm migration, the VM disks are copied incrementally using changed block tracking (CBT) snapshots.\n The snapshots are created at one-hour intervals by default.\n You can change the snapshot interval by updating the forklift-controller deployment.",
273+
"Incomplete": "Incomplete",
267274
"Incomplete mapping": "Incomplete mapping",
268275
"Information concerns": "Information concerns",
269276
"Invalid name, name should be unique in this namespace and a valid Kubernetes name": "Invalid name, name should be unique in this namespace and a valid Kubernetes name",
@@ -467,6 +474,7 @@
467474
"PVC name template": "PVC name template",
468475
"PVC name template is a template for generating persistent volume claims (PVC) names for VM disks.": "PVC name template is a template for generating persistent volume claims (PVC) names for VM disks.",
469476
"Ready": "Ready",
477+
"Ready to start": "Ready to start",
470478
"Reason": "Reason",
471479
"Red Hat Virtualization Manager UI": "Red Hat Virtualization Manager UI",
472480
"Region": "Region",
@@ -567,6 +575,11 @@
567575
"The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.": "The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.",
568576
"The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.": "The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.",
569577
"The password for the ESXi host admin": "The password for the ESXi host admin",
578+
"The plan cannot be duplicated": "The plan cannot be duplicated",
579+
"The plan cannot be started": "The plan cannot be started",
580+
"The plan is already archived": "The plan is already archived",
581+
"The plan is being validated": "The plan is being validated",
582+
"The plan is currently in progress": "The plan is currently in progress",
570583
"The plan is not ready": "The plan is not ready",
571584
"The plan migration might not work as expected": "The plan migration might not work as expected",
572585
"The project that your migration plan will be created in. Only projects with providers in them can be selected.": "The project that your migration plan will be created in. Only projects with providers in them can be selected.",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
/* eslint-disable @cspell/spellchecker */
2+
import { PlanData } from 'src/modules/Plans/utils';
3+
import {
4+
PlanConditionCategory,
5+
PlanConditionType,
6+
} from 'src/modules/Plans/utils/types/PlanCondition';
7+
8+
import { V1beta1Migration, V1beta1MigrationStatusVms } from '@kubev2v/types';
9+
10+
export const mockFailedVm: V1beta1MigrationStatusVms = {
11+
started: '2025-01-14T06:37:20Z',
12+
pipeline: [],
13+
error: {
14+
phase: 'CopyDisks',
15+
reasons: [
16+
'Unable to process data: Unable to transfer source data to scratch space: failed to pull image: unexpected EOF',
17+
],
18+
},
19+
completed: '2025-01-14T08:38:41Z',
20+
name: 'winweb01',
21+
conditions: [
22+
{
23+
category: PlanConditionCategory.Advisory,
24+
durable: true,
25+
lastTransitionTime: '2025-01-14T08:38:38Z',
26+
message: 'The VM migration has FAILED.',
27+
status: 'True',
28+
type: PlanConditionType.Failed,
29+
},
30+
],
31+
restorePowerState: 'On',
32+
id: '616e985a-170f-471b-b538-c39f8d848559',
33+
namespace: 'vmimported',
34+
phase: 'Completed',
35+
};
36+
37+
export const mockSucceededVm: V1beta1MigrationStatusVms = {
38+
started: '2025-01-07T18:42:50Z',
39+
pipeline: [],
40+
completed: '2025-01-07T18:54:14Z',
41+
name: 'haproxy-cf5d4',
42+
luks: {},
43+
conditions: [
44+
{
45+
category: PlanConditionCategory.Advisory,
46+
durable: true,
47+
lastTransitionTime: '2025-01-07T18:54:14Z',
48+
message: 'The VM migration has SUCCEEDED.',
49+
status: 'True',
50+
type: PlanConditionType.Succeeded,
51+
},
52+
],
53+
restorePowerState: 'Off',
54+
id: 'vm-146146',
55+
phase: 'Completed',
56+
};
57+
58+
export const mockPlanData: PlanData = {
59+
obj: {
60+
kind: 'Plan',
61+
apiVersion: 'forklift.konveyor.io/v1beta1',
62+
metadata: {
63+
annotations: { populatorLabels: 'True' },
64+
creationTimestamp: '2025-01-14T15:29:38Z',
65+
generation: 2,
66+
managedFields: [],
67+
name: 'testing',
68+
namespace: 'openshift-mtv',
69+
resourceVersion: '20558300',
70+
uid: '342f3ad5-eac9-4f89-8f1e-a37bee91f16a',
71+
},
72+
spec: {
73+
map: {
74+
network: {
75+
apiVersion: 'forklift.konveyor.io/v1beta1',
76+
kind: 'NetworkMap',
77+
name: 'vmware-wd2q7',
78+
namespace: 'openshift-mtv',
79+
uid: '2fe5e6cc-3a63-4034-8828-a7d38ac8f3c2',
80+
},
81+
storage: {
82+
apiVersion: 'forklift.konveyor.io/v1beta1',
83+
kind: 'StorageMap',
84+
name: 'vmware-k2bmn',
85+
namespace: 'openshift-mtv',
86+
uid: '7cf7f014-7d5e-47a4-99a4-57c14fdceeb6',
87+
},
88+
},
89+
provider: {
90+
destination: {
91+
apiVersion: 'forklift.konveyor.io/v1beta1',
92+
kind: 'Provider',
93+
name: 'host',
94+
namespace: 'openshift-mtv',
95+
uid: 'adf42f04-b5dd-41a6-8626-642686c0145a',
96+
},
97+
source: {
98+
apiVersion: 'forklift.konveyor.io/v1beta1',
99+
kind: 'Provider',
100+
name: 'vmware',
101+
namespace: 'openshift-mtv',
102+
uid: 'a14fc19a-0332-4cf2-bd91-6ceb3a7e8f47',
103+
},
104+
},
105+
targetNamespace: 'openshift-mtv',
106+
vms: [{ id: 'vm-146147', name: 'database-cf5d4' }],
107+
warm: true,
108+
},
109+
status: {
110+
conditions: [
111+
{
112+
category: PlanConditionCategory.Critical,
113+
items: [" id:vm-146147 name:'database-cf5d4' "],
114+
lastTransitionTime: '2025-01-14T15:29:38Z',
115+
message: 'Target VM already exists.',
116+
reason: 'NotUnique',
117+
status: 'True',
118+
type: PlanConditionType.VMAlreadyExists,
119+
},
120+
],
121+
migration: {},
122+
observedGeneration: 2,
123+
},
124+
},
125+
permissions: { canCreate: true, canPatch: true, canDelete: true, canGet: true, loading: false },
126+
};
127+
128+
export const mockMigration: V1beta1Migration = {
129+
kind: 'Migration',
130+
apiVersion: 'forklift.konveyor.io/v1beta1',
131+
metadata: {
132+
generateName: 'test1-',
133+
resourceVersion: '28653414',
134+
name: 'test1-j5w4l',
135+
uid: '193b4e36-6b14-4a09-8675-6d587019a747',
136+
creationTimestamp: '2025-01-14T06:44:23Z',
137+
generation: 1,
138+
managedFields: [],
139+
namespace: 'openshift-mtv',
140+
ownerReferences: [],
141+
},
142+
spec: {
143+
plan: {
144+
name: 'test1',
145+
namespace: 'openshift-mtv',
146+
uid: 'fd4b5f8b-d28c-4b51-a663-c3e011bfb666',
147+
},
148+
},
149+
status: {
150+
conditions: [
151+
{
152+
category: PlanConditionCategory.Required,
153+
lastTransitionTime: '2025-01-14T06:44:23Z',
154+
message: 'The migration is ready.',
155+
status: 'True',
156+
type: PlanConditionType.Ready,
157+
},
158+
{
159+
category: PlanConditionCategory.Advisory,
160+
lastTransitionTime: '2025-01-14T06:44:23Z',
161+
message: 'The migration is RUNNING.',
162+
status: 'True',
163+
type: PlanConditionType.Running,
164+
},
165+
],
166+
started: '2025-01-14T06:44:23Z',
167+
vms: [
168+
{
169+
id: '637c61c3-8501-405e-a35a-873520085a6b',
170+
luks: {},
171+
name: 'database',
172+
namespace: 'vmimported',
173+
phase: 'CopyDisks',
174+
pipeline: [
175+
{
176+
completed: '2025-01-14T06:44:47Z',
177+
description: 'Initialize migration.',
178+
name: 'Initialize',
179+
phase: 'Completed',
180+
progress: {
181+
completed: 0,
182+
total: 1,
183+
},
184+
started: '2025-01-14T06:44:23Z',
185+
},
186+
{
187+
annotations: {
188+
unit: 'MB',
189+
},
190+
description: 'Transfer disks.',
191+
name: 'DiskTransfer',
192+
phase: 'Running',
193+
progress: {
194+
completed: 0,
195+
total: 16384,
196+
},
197+
started: '2025-01-14T06:44:50Z',
198+
tasks: [
199+
{
200+
annotations: {
201+
unit: 'MB',
202+
},
203+
name: 'vmimported/database',
204+
phase: 'Running',
205+
progress: {
206+
completed: 0,
207+
total: 16384,
208+
},
209+
reason:
210+
'Error; Unable to connect to http data source: expected status code 200, got 404. Status: 404 Not Found',
211+
started: '2025-01-14T06:45:26Z',
212+
},
213+
],
214+
},
215+
{
216+
description: 'Create VM.',
217+
name: 'VirtualMachineCreation',
218+
phase: 'Pending',
219+
progress: {
220+
completed: 0,
221+
total: 1,
222+
},
223+
},
224+
],
225+
restorePowerState: 'On',
226+
started: '2025-01-14T06:44:23Z',
227+
},
228+
],
229+
},
230+
};

packages/forklift-console-plugin/src/__mocks__/react-i18next.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ import React from 'react';
22

33
/**
44
* Mock translation utility
5-
*
6-
* @returns {{ t: (k: string) => string; }}
75
*/
86
export const useTranslation = () => ({
9-
t: (k: string) => k,
7+
t: (key, options) => {
8+
// Resolve interpolated strings
9+
if (options?.interpolation || options?.total || options?.count) {
10+
const interpolatedString = key.replace(/{{(\w+)}}/g, (match, variable) => {
11+
return options[variable] || options.interpolation?.[variable] || match;
12+
});
13+
14+
return interpolatedString;
15+
} else {
16+
return key;
17+
}
18+
},
1019
i18n: {
1120
resolvedLanguage: 'en',
1221
},

0 commit comments

Comments
 (0)