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

CNV-43038: Improve sysprep section in quick and customize mode #2191

Merged
Merged
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
3 changes: 0 additions & 3 deletions locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
"Automatic updates": "Automatic updates",
"Automatically apply this key to any new VirtualMachine you create in this project.": "Automatically apply this key to any new VirtualMachine you create in this project.",
"Automatically pull updates from the RHEL repository. Activation key and Organization ID are mandatory to enable this.": "Automatically pull updates from the RHEL repository. Activation key and Organization ID are mandatory to enable this.",
"Autounattend.xml": "Autounattend.xml",
"Autounattend.xml answer file": "Autounattend.xml answer file",
"Available": "Available",
"Available only on Nodes with labels": "Available only on Nodes with labels",
Expand Down Expand Up @@ -1079,7 +1078,6 @@
"Select workloads that must have all the following expressions.": "Select workloads that must have all the following expressions.",
"Selected columns will appear in the table.": "Selected columns will appear in the table.",
"Selected StorageClass is different from StorageClass of the source": "Selected StorageClass is different from StorageClass of the source",
"Selected sysprep": "Selected sysprep",
"Selector": "Selector",
"selector key": "selector key",
"selector value": "selector value",
Expand Down Expand Up @@ -1280,7 +1278,6 @@
"U series": "U series",
"UEFI": "UEFI",
"UEFI (secure)": "UEFI (secure)",
"Unattend.xml": "Unattend.xml",
"Unattend.xml answer file": "Unattend.xml answer file",
"Unavailable": "Unavailable",
"Unique name of the MigrationPolicy": "Unique name of the MigrationPolicy",
Expand Down
32 changes: 11 additions & 21 deletions src/utils/components/SysprepModal/SysprepDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC } from 'react';
import { ConfigMapModel, modelToGroupVersionKind } from '@kubevirt-ui/kubevirt-api/console';
import SysprepInfo from '@kubevirt-utils/components/SysprepModal/SysprepInfo';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { isEmpty } from '@kubevirt-utils/utils/utils';
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk';
import { Alert, AlertVariant, DescriptionList, Stack, StackItem } from '@patternfly/react-core';

Expand All @@ -11,11 +12,9 @@ import VirtualMachineDescriptionItem from '../VirtualMachineDescriptionItem/Virt

export const SysprepDescription: FC<{
error?: Error;
hasAutoUnattend: boolean;
hasUnattend: boolean;
loaded?: boolean;
selectedSysprepName?: string;
}> = ({ error, hasAutoUnattend, hasUnattend, loaded, selectedSysprepName }) => {
}> = ({ error, loaded, selectedSysprepName }) => {
const { t } = useKubevirtTranslation();

if (error) {
Expand All @@ -29,6 +28,7 @@ export const SysprepDescription: FC<{
if (!loaded) {
return <Loading />;
}

return (
<Stack hasGutter>
<StackItem>
Expand All @@ -40,29 +40,19 @@ export const SysprepDescription: FC<{
columnModifier={{ lg: '1Col', xl: '2Col' }}
isCompact
>
{selectedSysprepName ? (
<VirtualMachineDescriptionItem
descriptionData={
<VirtualMachineDescriptionItem
descriptionData={
isEmpty(selectedSysprepName) ? (
t('Not available')
) : (
<ResourceLink
groupVersionKind={modelToGroupVersionKind(ConfigMapModel)}
linkTo={false}
name={selectedSysprepName}
/>
}
descriptionHeader={t('Selected sysprep')}
/>
) : (
<>
<VirtualMachineDescriptionItem
descriptionData={hasAutoUnattend ? t('Available') : t('Not available')}
descriptionHeader={t('Autounattend.xml answer file')}
/>
<VirtualMachineDescriptionItem
descriptionData={hasUnattend ? t('Available') : t('Not available')}
descriptionHeader={t('Unattend.xml answer file')}
/>
</>
)}
)
}
/>
</DescriptionList>
</StackItem>
</Stack>
Expand Down
4 changes: 3 additions & 1 deletion src/utils/components/SysprepModal/SysprepModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const SysprepModal: FC<{
onClose: () => void;
onSysprepCreation?: (unattended: string, autoUnattend: string) => Promise<void> | void;
onSysprepSelected?: (sysprepName: string) => Promise<void> | void;
shouldCreateConfigMap?: boolean;
sysprepSelected?: string;
unattend: string;
}> = ({
Expand All @@ -26,13 +27,14 @@ export const SysprepModal: FC<{
onClose,
onSysprepCreation,
onSysprepSelected,
shouldCreateConfigMap = true,
sysprepSelected,
unattend: initialUnattend,
}) => {
const { t } = useKubevirtTranslation();
const [autoUnattend, setAutoUnattend] = useState(initialAutoUnattend);
const [unattend, setUnattend] = useState(initialUnattend);
const [creationSectionOpen, setCreationSection] = useState(!sysprepSelected);
const [creationSectionOpen, setCreationSection] = useState(shouldCreateConfigMap);
const [selectedSysprepName, setSelectedSysprepName] = useState(sysprepSelected);

const submitHandler = async () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
import { SysprepModal } from '@kubevirt-utils/components/SysprepModal/SysprepModal';
import VirtualMachineDescriptionItem from '@kubevirt-utils/components/VirtualMachineDescriptionItem/VirtualMachineDescriptionItem';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { ConfigMapModel, modelToGroupVersionKind } from '@kubevirt-utils/models';
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk';
import { Loading } from '@patternfly/quickstarts';

import SimplifiedSysprepDescription from './SimplifiedSysprepDescription';

const SysprepDescriptionItem: FC = () => {
const { t } = useKubevirtTranslation();
const { createModal } = useModal();
Expand Down Expand Up @@ -90,11 +90,10 @@ const SysprepDescriptionItem: FC = () => {

const sysprepDescription =
autounattend || unattended ? (
<SimplifiedSysprepDescription
hasAutoUnattend={!!autounattend}
hasUnattend={!!unattended}
selectedSysprepName={currentSysprepName}
shouldCreateNewConfigMap={shouldCreateNewConfigMap}
<ResourceLink
groupVersionKind={modelToGroupVersionKind(ConfigMapModel)}
linkTo={false}
name={currentSysprepName}
/>
) : (
t('Not configured')
Expand All @@ -110,6 +109,7 @@ const SysprepDescriptionItem: FC = () => {
namespace={vmNamespaceTarget}
onSysprepCreation={onSysprepCreation}
onSysprepSelected={onSysprepSelected}
shouldCreateConfigMap={shouldCreateNewConfigMap}
sysprepSelected={currentSysprepName}
unattend={unattended}
/>
Expand Down
9 changes: 1 addition & 8 deletions src/views/catalog/wizard/tabs/scripts/components/Sysprep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ const Sysprep: FC = () => {

return (
<WizardDescriptionItem
description={
<SysprepDescription
hasAutoUnattend={!!autoUnattend}
hasUnattend={!!unattend}
loaded
selectedSysprepName={selectedSysprep}
/>
}
onEditClick={() =>
createModal((modalProps) => (
<SysprepModal
Expand All @@ -105,6 +97,7 @@ const Sysprep: FC = () => {
/>
))
}
description={<SysprepDescription loaded selectedSysprepName={currentVMSysprepName} />}
isDisabled={tabsData?.overview?.templateMetadata?.osType !== WINDOWS}
isEdit
label={<WindowsLabel />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ const SysPrepItem: FC<SysPrepItemProps> = ({ template }) => {

return (
<VirtualMachineDescriptionItem
descriptionData={
<SysprepDescription
error={sysprepLoadError}
hasAutoUnattend={!!autoUnattend}
hasUnattend={!!unattend}
loaded={sysprepLoaded}
/>
}
descriptionHeader={
<Flex className="vm-description-item__title">
<FlexItem>
Expand Down Expand Up @@ -125,6 +117,7 @@ const SysPrepItem: FC<SysPrepItemProps> = ({ template }) => {
</FlexItem>
</Flex>
}
descriptionData={<SysprepDescription error={sysprepLoadError} loaded={sysprepLoaded} />}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const InitialRunTabSysprep: FC<InitialRunTabSysprepProps> = ({ canUpdateVM, onSu
descriptionData={
<SysprepDescription
error={sysprepLoadError}
hasAutoUnattend={!!autoUnattend}
hasUnattend={!!unattend}
loaded={sysprepLoaded}
selectedSysprepName={currentVMSysprepName}
/>
Expand Down
Loading