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-1801] [RFE] Non informative message #1462

Open
wants to merge 1 commit 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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
export * from './PlanCriticalConditions';
export * from './PlansAddButton';
export * from './PlansEmptyState';
// @endindex
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Reference: https://github.com/kubev2v/forklift/blob/3113e867374c560ffbdcd34ef1627cb867893ba5/pkg/controller/plan/validation.go

export enum PlanConditionType {
Ready = 'Ready',
NotReady = 'NotReady',
WarmMigrationNotReady = 'WarmMigrationNotReady',
NamespaceNotValid = 'NamespaceNotValid',
TransferNetNotValid = 'TransferNetworkNotValid',
NetRefNotValid = 'NetworkMapRefNotValid',
NetMapNotReady = 'NetworkMapNotReady',
DsMapNotReady = 'StorageMapNotReady',
DsRefNotValid = 'StorageRefNotValid',
VMRefNotValid = 'VMRefNotValid',
VMNotFound = 'VMNotFound',
VMAlreadyExists = 'VMAlreadyExists',
VMNetworksNotMapped = 'VMNetworksNotMapped',
VMStorageNotMapped = 'VMStorageNotMapped',
VMStorageNotSupported = 'VMStorageNotSupported',
VMMultiplePodNetworkMappings = 'VMMultiplePodNetworkMappings',
VMMissingGuestIPs = 'VMMissingGuestIPs',
VMMissingChangedBlockTracking = 'VMMissingChangedBlockTracking',
HostNotReady = 'HostNotReady',
DuplicateVM = 'DuplicateVM',
NameNotValid = 'TargetNameNotValid',
HookNotValid = 'HookNotValid',
HookNotReady = 'HookNotReady',
HookStepNotValid = 'HookStepNotValid',
Executing = 'Executing',
Succeeded = 'Succeeded',
Failed = 'Failed',
Canceled = 'Canceled',
Deleted = 'Deleted',
Paused = 'Paused',
Pending = 'Pending',
Running = 'Running',
Blocked = 'Blocked',
Archived = 'Archived',
unsupportedVersion = 'UnsupportedVersion',
VDDKInvalid = 'VDDKInvalid',
ValidatingVDDK = 'ValidatingVDDK',
VDDKInitImageNotReady = 'VDDKInitImageNotReady',
VDDKInitImageUnavailable = 'VDDKInitImageUnavailable',
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
import React from 'react';
import React, { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import Linkify from 'react-linkify';
import { useHistory } from 'react-router';
import { PlanConditionType } from 'src/modules/Plans/utils/types/PlanCondition';
import { getResourceUrl } from 'src/modules/Providers';
import { ForkliftTrans } from 'src/utils';
import { EMPTY_MSG } from 'src/utils/constants';

import { Alert, AlertVariant, Text, TextContent, TextVariants } from '@patternfly/react-core';
import { PlanModelRef, V1beta1Plan, V1beta1PlanStatusConditions } from '@kubev2v/types';
import {
Alert,
AlertVariant,
Button,
Text,
TextContent,
TextVariants,
} from '@patternfly/react-core';

const PlanCriticalCondition: React.FC<{ type: string; message: string }> = ({ type, message }) => {
type PlanCriticalConditionProps = {
plan: V1beta1Plan;
condition: V1beta1PlanStatusConditions;
};

const PlanCriticalCondition: React.FC<PlanCriticalConditionProps> = ({ plan, condition }) => {
const { t } = useTranslation();
const history = useHistory();

const { type, message: conditionMessage } = condition;
let troubleshootMessage: ReactNode = t(
'To troubleshoot, check the Forklift controller pod logs.',
);

if (
type === PlanConditionType.VMNetworksNotMapped ||
type === PlanConditionType.VMStorageNotMapped ||
type === PlanConditionType.VMMultiplePodNetworkMappings
) {
const planURL = getResourceUrl({
reference: PlanModelRef,
name: plan?.metadata?.name,
namespace: plan?.metadata?.namespace,
});

troubleshootMessage = (
<ForkliftTrans>
To troubleshoot, please check and edit your plan{' '}
<Button isInline variant="link" onClick={() => history.push(`${planURL}/mappings`)}>
mappings
</Button>
.
</ForkliftTrans>
);
}

return (
<Alert title={t('The plan is not ready') + ' - ' + type} variant={AlertVariant.danger}>
<TextContent className="forklift-providers-list-header__alert">
<Text component={TextVariants.p}>
<Linkify>{message || EMPTY_MSG}</Linkify>
{'. '}
{t('To troubleshoot, check the Forklift controller pod logs.')}
<Linkify>{conditionMessage || EMPTY_MSG}</Linkify>
{`${!conditionMessage.endsWith('.') ? '.' : ''} `}
{troubleshootMessage}
</Text>
</TextContent>
</Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = (
if (criticalCondition) {
alerts.push(
<PlanCriticalCondition
type={criticalCondition?.type}
message={criticalCondition?.message}
plan={plan}
condition={criticalCondition}
key={'providerCriticalCondition'}
/>,
);
Expand Down
Loading