Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MTV-1686] Simplify/update migration plan status cell (part 2) #1442

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/common/src/components/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC, PropsWithChildren } from 'react';

import { Spinner, SpinnerProps } from '@patternfly/react-core';

type LoadingSpinnerProps = PropsWithChildren &
SpinnerProps & {
isLoading: boolean;
};

const LoadingSpinner: FC<LoadingSpinnerProps> = ({ isLoading, children, ...spinnerProps }) =>
isLoading ? <Spinner {...spinnerProps} /> : <>{children}</>;

export default LoadingSpinner;
1 change: 1 addition & 0 deletions packages/common/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './FormGroupWithHelpText';
export * from './HelpIconPopover';
export * from './Icons';
export * from './LoadingDots';
export { default as LoadingSpinner } from './LoadingSpinner';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add it to index file, we are going to remove those index's completely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it looks like we cannot import components without linting/compliation errors with the following from @kubev2v/common:

import LoadingSpinner from '@kubev2v/common/src/components/LoadingSpinner';
import LoadingSpinner from '@kubev2v/common/dist/components/LoadingSpinner';

Both of these lead to issues, and to solve this issue is to solve a much broader one which would deal with the exporting of components collectively from that repo within this monorepo.

So unless there's something else we can do in the meantime for this, I think adding this export to the existing index is the least invasive change without changing the scope of this issue right now.

export * from './Page';
export * from './QueryClientHoc';
export * from './TableView';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"31 days": "31 days",
"404: Not Found": "404: Not Found",
"7 days": "7 days",
"99+ VMs": "99+ VMs",
"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.",
"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.",
"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.",
Expand All @@ -40,6 +41,7 @@
"All networks detected on the selected VMs require a mapping.": "All networks detected on the selected VMs require a mapping.",
"All storages detected on the selected VMs require a mapping.": "All storages detected on the selected VMs require a mapping.",
"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.",
"All VMs were migrated": "All VMs were migrated",
"Application credential ID": "Application credential ID",
"Application credential name": "Application credential name",
"Application credential secret": "Application credential secret",
Expand All @@ -48,6 +50,8 @@
"Archive migration plan": "Archive migration plan",
"Archive Plan": "Archive Plan",
"Archived": "Archived",
"Archived plans cannot be edited": "Archived plans cannot be edited",
"Archived plans cannot be started": "Archived plans cannot be started",
"Archiving": "Archiving",
"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?",
"Assessment": "Assessment",
Expand All @@ -72,6 +76,7 @@
"Cancel virtual machines from migration plan": "Cancel virtual machines from migration plan",
"Canceled": "Canceled",
"Cannot retrieve certificate": "Cannot retrieve certificate",
"Cannot start": "Cannot start",
"Category": "Category",
"Certificate change detected": "Certificate change detected",
"choose a different mapping for your migration plan": "choose a different mapping for your migration plan",
Expand All @@ -85,6 +90,7 @@
"Click to unselect.": "Click to unselect.",
"Cluster": "Cluster",
"Clusters": "Clusters",
"Complete": "Complete",
"Completed {{completed}} of {{total}} {{name}} tasks": "Completed {{completed}} of {{total}} {{name}} tasks",
"Completed at": "Completed at",
"Concern": "Concern",
Expand Down Expand Up @@ -216,6 +222,7 @@
"If true, the provider's TLS certificate won't be validated.": "If true, the provider's TLS certificate won't be validated.",
"Image": "Image",
"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.",
"Incomplete": "Incomplete",
"Incomplete mapping": "Incomplete mapping",
"Information concerns": "Information concerns",
"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",
Expand Down Expand Up @@ -397,6 +404,7 @@
"Providers default": "Providers default",
"Providers for virtualization": "Providers for virtualization",
"Ready": "Ready",
"Ready to start": "Ready to start",
"Reason": "Reason",
"Red Hat Virtualization Manager UI": "Red Hat Virtualization Manager UI",
"Region": "Region",
Expand Down Expand Up @@ -494,6 +502,11 @@
"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.",
"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.",
"The password for the ESXi host admin": "The password for the ESXi host admin",
"The plan cannot be duplicated": "The plan cannot be duplicated",
"The plan cannot be started": "The plan cannot be started",
"The plan is already archived": "The plan is already archived",
"The plan is being validated": "The plan is being validated",
"The plan is currently in progress": "The plan is currently in progress",
"The plan is not ready": "The plan is not ready",
"The plan migration might not work as expected": "The plan migration might not work as expected",
"The provider is not ready": "The provider is not ready",
Expand Down
230 changes: 230 additions & 0 deletions packages/forklift-console-plugin/src/__mocks__/plans.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/* eslint-disable @cspell/spellchecker */
import { PlanData } from 'src/modules/Plans/utils';
import {
PlanConditionCategory,
PlanConditionType,
} from 'src/modules/Plans/utils/types/PlanCondition';

import { V1beta1Migration, V1beta1MigrationStatusVms } from '@kubev2v/types';

export const mockFailedVm: V1beta1MigrationStatusVms = {
started: '2025-01-14T06:37:20Z',
pipeline: [],
error: {
phase: 'CopyDisks',
reasons: [
'Unable to process data: Unable to transfer source data to scratch space: failed to pull image: unexpected EOF',
],
},
completed: '2025-01-14T08:38:41Z',
name: 'winweb01',
conditions: [
{
category: PlanConditionCategory.Advisory,
durable: true,
lastTransitionTime: '2025-01-14T08:38:38Z',
message: 'The VM migration has FAILED.',
status: 'True',
type: PlanConditionType.Failed,
},
],
restorePowerState: 'On',
id: '616e985a-170f-471b-b538-c39f8d848559',
namespace: 'vmimported',
phase: 'Completed',
};

export const mockSucceededVm: V1beta1MigrationStatusVms = {
started: '2025-01-07T18:42:50Z',
pipeline: [],
completed: '2025-01-07T18:54:14Z',
name: 'haproxy-cf5d4',
luks: {},
conditions: [
{
category: PlanConditionCategory.Advisory,
durable: true,
lastTransitionTime: '2025-01-07T18:54:14Z',
message: 'The VM migration has SUCCEEDED.',
status: 'True',
type: PlanConditionType.Succeeded,
},
],
restorePowerState: 'Off',
id: 'vm-146146',
phase: 'Completed',
};

export const mockPlanData: PlanData = {
obj: {
kind: 'Plan',
apiVersion: 'forklift.konveyor.io/v1beta1',
metadata: {
annotations: { populatorLabels: 'True' },
creationTimestamp: '2025-01-14T15:29:38Z',
generation: 2,
managedFields: [],
name: 'testing',
namespace: 'openshift-mtv',
resourceVersion: '20558300',
uid: '342f3ad5-eac9-4f89-8f1e-a37bee91f16a',
},
spec: {
map: {
network: {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'NetworkMap',
name: 'vmware-wd2q7',
namespace: 'openshift-mtv',
uid: '2fe5e6cc-3a63-4034-8828-a7d38ac8f3c2',
},
storage: {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'StorageMap',
name: 'vmware-k2bmn',
namespace: 'openshift-mtv',
uid: '7cf7f014-7d5e-47a4-99a4-57c14fdceeb6',
},
},
provider: {
destination: {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'Provider',
name: 'host',
namespace: 'openshift-mtv',
uid: 'adf42f04-b5dd-41a6-8626-642686c0145a',
},
source: {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'Provider',
name: 'vmware',
namespace: 'openshift-mtv',
uid: 'a14fc19a-0332-4cf2-bd91-6ceb3a7e8f47',
},
},
targetNamespace: 'openshift-mtv',
vms: [{ id: 'vm-146147', name: 'database-cf5d4' }],
warm: true,
},
status: {
conditions: [
{
category: PlanConditionCategory.Critical,
items: [" id:vm-146147 name:'database-cf5d4' "],
lastTransitionTime: '2025-01-14T15:29:38Z',
message: 'Target VM already exists.',
reason: 'NotUnique',
status: 'True',
type: PlanConditionType.VMAlreadyExists,
},
],
migration: {},
observedGeneration: 2,
},
},
permissions: { canCreate: true, canPatch: true, canDelete: true, canGet: true, loading: false },
};

export const mockMigration: V1beta1Migration = {
kind: 'Migration',
apiVersion: 'forklift.konveyor.io/v1beta1',
metadata: {
generateName: 'test1-',
resourceVersion: '28653414',
name: 'test1-j5w4l',
uid: '193b4e36-6b14-4a09-8675-6d587019a747',
creationTimestamp: '2025-01-14T06:44:23Z',
generation: 1,
managedFields: [],
namespace: 'openshift-mtv',
ownerReferences: [],
},
spec: {
plan: {
name: 'test1',
namespace: 'openshift-mtv',
uid: 'fd4b5f8b-d28c-4b51-a663-c3e011bfb666',
},
},
status: {
conditions: [
{
category: PlanConditionCategory.Required,
lastTransitionTime: '2025-01-14T06:44:23Z',
message: 'The migration is ready.',
status: 'True',
type: PlanConditionType.Ready,
},
{
category: PlanConditionCategory.Advisory,
lastTransitionTime: '2025-01-14T06:44:23Z',
message: 'The migration is RUNNING.',
status: 'True',
type: PlanConditionType.Running,
},
],
started: '2025-01-14T06:44:23Z',
vms: [
{
id: '637c61c3-8501-405e-a35a-873520085a6b',
luks: {},
name: 'database',
namespace: 'vmimported',
phase: 'CopyDisks',
pipeline: [
{
completed: '2025-01-14T06:44:47Z',
description: 'Initialize migration.',
name: 'Initialize',
phase: 'Completed',
progress: {
completed: 0,
total: 1,
},
started: '2025-01-14T06:44:23Z',
},
{
annotations: {
unit: 'MB',
},
description: 'Transfer disks.',
name: 'DiskTransfer',
phase: 'Running',
progress: {
completed: 0,
total: 16384,
},
started: '2025-01-14T06:44:50Z',
tasks: [
{
annotations: {
unit: 'MB',
},
name: 'vmimported/database',
phase: 'Running',
progress: {
completed: 0,
total: 16384,
},
reason:
'Error; Unable to connect to http data source: expected status code 200, got 404. Status: 404 Not Found',
started: '2025-01-14T06:45:26Z',
},
],
},
{
description: 'Create VM.',
name: 'VirtualMachineCreation',
phase: 'Pending',
progress: {
completed: 0,
total: 1,
},
},
],
restorePowerState: 'On',
started: '2025-01-14T06:44:23Z',
},
],
},
};
15 changes: 12 additions & 3 deletions packages/forklift-console-plugin/src/__mocks__/react-i18next.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ import React from 'react';

/**
* Mock translation utility
*
* @returns {{ t: (k: string) => string; }}
*/
export const useTranslation = () => ({
t: (k: string) => k,
t: (key, options) => {
// Resolve interpolated strings
if (options?.interpolation || options?.total || options?.count) {
const interpolatedString = key.replace(/{{(\w+)}}/g, (match, variable) => {
return options[variable] || options.interpolation?.[variable] || match;
});

return interpolatedString;
} else {
return key;
}
},
i18n: {
resolvedLanguage: 'en',
},
Expand Down
Loading
Loading