Skip to content

Commit ba019b8

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

File tree

20 files changed

+811
-97
lines changed

20 files changed

+811
-97
lines changed

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

Lines changed: 5 additions & 0 deletions
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.",
@@ -72,6 +73,7 @@
7273
"Cancel virtual machines from migration plan": "Cancel virtual machines from migration plan",
7374
"Canceled": "Canceled",
7475
"Cannot retrieve certificate": "Cannot retrieve certificate",
76+
"Cannot start": "Cannot start",
7577
"Category": "Category",
7678
"Certificate change detected": "Certificate change detected",
7779
"choose a different mapping for your migration plan": "choose a different mapping for your migration plan",
@@ -85,6 +87,7 @@
8587
"Click to unselect.": "Click to unselect.",
8688
"Cluster": "Cluster",
8789
"Clusters": "Clusters",
90+
"Complete": "Complete",
8891
"Completed {{completed}} of {{total}} {{name}} tasks": "Completed {{completed}} of {{total}} {{name}} tasks",
8992
"Completed at": "Completed at",
9093
"Concern": "Concern",
@@ -217,6 +220,7 @@
217220
"If true, the provider's TLS certificate won't be validated.": "If true, the provider's TLS certificate won't be validated.",
218221
"Image": "Image",
219222
"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.",
223+
"Incomplete": "Incomplete",
220224
"Incomplete mapping": "Incomplete mapping",
221225
"Information concerns": "Information concerns",
222226
"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 +400,7 @@
396400
"Providers default": "Providers default",
397401
"Providers for virtualization": "Providers for virtualization",
398402
"Ready": "Ready",
403+
"Ready to start": "Ready to start",
399404
"Reason": "Reason",
400405
"Red Hat Virtualization Manager UI": "Red Hat Virtualization Manager UI",
401406
"Region": "Region",
Lines changed: 230 additions & 0 deletions
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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@ import React from 'react';
33
/**
44
* Mock translation utility
55
*
6-
* @returns {{ t: (k: string) => string; }}
6+
* @returns {{ t: (k: string): string; }}
77
*/
88
export const useTranslation = () => ({
9-
t: (k: string) => k,
9+
t: (key, options) => {
10+
// Resolve interpolated strings
11+
if (options?.interpolation || options?.total || options?.count) {
12+
const interpolatedString = key.replace(/{{(\w+)}}/g, (match, variable) => {
13+
return options[variable] || options.interpolation?.[variable] || match;
14+
});
15+
16+
return interpolatedString;
17+
} else {
18+
return key;
19+
}
20+
},
1021
i18n: {
1122
resolvedLanguage: 'en',
1223
},

0 commit comments

Comments
 (0)