-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a fast Create Plan page - step 1
Changes: 1. transfer data from VM List screen to Create Plan page via console.context-provider 2. add immer library to keep data in the reducer immutable 3. add uuid library to generate random suffixes 4. use forms for the Create Plan page - similar to Create Provider Signed-off-by: Radoslaw Szwajkowski <[email protected]>
- Loading branch information
Showing
15 changed files
with
622 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,4 @@ multiqueue | |
filesystems | ||
bootloader | ||
typeahead | ||
immer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/forklift-console-plugin/src/modules/Providers/views/create/templates/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// @index(['./*', /style/g], f => `export * from '${f.path}';`) | ||
export * from './planTemplate'; | ||
export * from './providerTemplate'; | ||
export * from './secretTemplate'; | ||
// @endindex |
14 changes: 14 additions & 0 deletions
14
...ages/forklift-console-plugin/src/modules/Providers/views/create/templates/planTemplate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { V1beta1Plan } from '@kubev2v/types'; | ||
|
||
export const planTemplate: V1beta1Plan = { | ||
apiVersion: 'forklift.konveyor.io/v1beta1', | ||
kind: 'Plan', | ||
metadata: { | ||
name: undefined, | ||
namespace: undefined, | ||
}, | ||
spec: { | ||
map: {}, | ||
targetNamespace: '', | ||
}, | ||
}; |
39 changes: 39 additions & 0 deletions
39
...n/src/modules/Providers/views/details/tabs/VirtualMachines/components/MigrationAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { FC } from 'react'; | ||
import { useHistory } from 'react-router'; | ||
import { getResourceUrl } from 'src/modules/Providers/utils'; | ||
import { useCreateVmMigrationData } from 'src/modules/Providers/views/migrate'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { PlanModelRef, V1beta1Provider } from '@kubev2v/types'; | ||
import { Button, ToolbarItem } from '@patternfly/react-core'; | ||
|
||
import { VmData } from './VMCellProps'; | ||
|
||
export const MigrationAction: FC<{ | ||
selectedVms: VmData[]; | ||
provider: V1beta1Provider; | ||
}> = ({ selectedVms, provider }) => { | ||
const { t } = useForkliftTranslation(); | ||
const history = useHistory(); | ||
const namespace = provider?.metadata?.namespace; | ||
const planListURL = getResourceUrl({ | ||
reference: PlanModelRef, | ||
namespace, | ||
namespaced: namespace !== undefined, | ||
}); | ||
const { setData } = useCreateVmMigrationData(); | ||
return ( | ||
<ToolbarItem> | ||
<Button | ||
variant="secondary" | ||
onClick={() => { | ||
setData({ selectedVms, provider }); | ||
history.push(`${planListURL}/~new`); | ||
}} | ||
isDisabled={!selectedVms?.length} | ||
> | ||
{t('Migrate')} | ||
</Button> | ||
</ToolbarItem> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/forklift-console-plugin/src/modules/Providers/views/migrate/PlansCreateForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useState } from 'react'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { ProviderModelGroupVersionKind } from '@kubev2v/types'; | ||
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { DescriptionList, Form, FormGroup, TextInput } from '@patternfly/react-core'; | ||
|
||
import { DetailsItem } from '../../utils'; | ||
|
||
import { PageAction, setPlanName } from './actions'; | ||
import { CreateVmMigrationPageState } from './reducer'; | ||
|
||
export const PlansCreateForm = ({ | ||
state: { newPlan: plan, validation }, | ||
dispatch, | ||
}: { | ||
state: CreateVmMigrationPageState; | ||
dispatch: (action: PageAction<unknown, unknown>) => void; | ||
}) => { | ||
const { t } = useForkliftTranslation(); | ||
const [isNameEdited, setIsNameEdited] = useState(false); | ||
return ( | ||
<DescriptionList | ||
className="forklift-create-provider-edit-section" | ||
columnModifier={{ | ||
default: '1Col', | ||
}} | ||
> | ||
{isNameEdited ? ( | ||
<Form> | ||
<FormGroup | ||
label={t('Plan name')} | ||
isRequired | ||
fieldId="planName" | ||
validated={validation.name} | ||
> | ||
<TextInput | ||
isRequired | ||
type="text" | ||
id="planName" | ||
value={plan.metadata.name} | ||
validated={validation.name} | ||
onChange={(value) => dispatch(setPlanName(value?.trim() ?? '', []))} | ||
/> | ||
</FormGroup> | ||
</Form> | ||
) : ( | ||
<DetailsItem | ||
title={t('Plan name')} | ||
content={plan.metadata.name} | ||
onEdit={() => setIsNameEdited(true)} | ||
/> | ||
)} | ||
<DetailsItem | ||
title={t('Source provider')} | ||
content={ | ||
<ResourceLink | ||
name={plan?.spec?.provider?.source?.name} | ||
namespace={plan?.spec?.provider?.source?.namespace} | ||
groupVersionKind={ProviderModelGroupVersionKind} | ||
/> | ||
} | ||
/> | ||
<DetailsItem | ||
title={t('{{vmCount}} VMs selected ', { vmCount: plan.spec.vms.length })} | ||
content={''} | ||
/> | ||
</DescriptionList> | ||
); | ||
}; |
Oops, something went wrong.