Skip to content

Commit acb6a1c

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

20 files changed

+818
-98
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"31 days": "31 days",
2121
"404: Not Found": "404: Not Found",
2222
"7 days": "7 days",
23+
"99+ VMs": "99+ VMs",
2324
"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.",
2425
"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.",
2526
"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.",
@@ -40,6 +41,7 @@
4041
"All networks detected on the selected VMs require a mapping.": "All networks detected on the selected VMs require a mapping.",
4142
"All storages detected on the selected VMs require a mapping.": "All storages detected on the selected VMs require a mapping.",
4243
"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.",
44+
"All VMs were migrated": "All VMs were migrated",
4345
"Application credential ID": "Application credential ID",
4446
"Application credential name": "Application credential name",
4547
"Application credential secret": "Application credential secret",
@@ -48,6 +50,8 @@
4850
"Archive migration plan": "Archive migration plan",
4951
"Archive Plan": "Archive Plan",
5052
"Archived": "Archived",
53+
"Archived plans cannot be edited": "Archived plans cannot be edited",
54+
"Archived plans cannot be started": "Archived plans cannot be started",
5155
"Archiving": "Archiving",
5256
"Are you sure you want to delete this virtual machines from the migration plan?": "Are you sure you want to delete this virtual machines from the migration plan?",
5357
"Assessment": "Assessment",
@@ -72,6 +76,7 @@
7276
"Cancel virtual machines from migration plan": "Cancel virtual machines from migration plan",
7377
"Canceled": "Canceled",
7478
"Cannot retrieve certificate": "Cannot retrieve certificate",
79+
"Cannot start": "Cannot start",
7580
"Category": "Category",
7681
"Certificate change detected": "Certificate change detected",
7782
"choose a different mapping for your migration plan": "choose a different mapping for your migration plan",
@@ -85,6 +90,7 @@
8590
"Click to unselect.": "Click to unselect.",
8691
"Cluster": "Cluster",
8792
"Clusters": "Clusters",
93+
"Complete": "Complete",
8894
"Completed {{completed}} of {{total}} {{name}} tasks": "Completed {{completed}} of {{total}} {{name}} tasks",
8995
"Completed at": "Completed at",
9096
"Concern": "Concern",
@@ -217,6 +223,7 @@
217223
"If true, the provider's TLS certificate won't be validated.": "If true, the provider's TLS certificate won't be validated.",
218224
"Image": "Image",
219225
"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.",
226+
"Incomplete": "Incomplete",
220227
"Incomplete mapping": "Incomplete mapping",
221228
"Information concerns": "Information concerns",
222229
"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",
@@ -396,6 +403,7 @@
396403
"Providers default": "Providers default",
397404
"Providers for virtualization": "Providers for virtualization",
398405
"Ready": "Ready",
406+
"Ready to start": "Ready to start",
399407
"Reason": "Reason",
400408
"Red Hat Virtualization Manager UI": "Red Hat Virtualization Manager UI",
401409
"Region": "Region",
@@ -494,6 +502,11 @@
494502
"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.",
495503
"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.",
496504
"The password for the ESXi host admin": "The password for the ESXi host admin",
505+
"The plan cannot be duplicated": "The plan cannot be duplicated",
506+
"The plan cannot be started": "The plan cannot be started",
507+
"The plan is already archived": "The plan is already archived",
508+
"The plan is being validated": "The plan is being validated",
509+
"The plan is currently in progress": "The plan is currently in progress",
497510
"The plan is not ready": "The plan is not ready",
498511
"The plan migration might not work as expected": "The plan migration might not work as expected",
499512
"The provider is not ready": "The provider is not ready",
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)