-
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.
[MTV-1769] Add Project field to migration plan/provider wizards
Signed-off-by: Jeff Puzzo <[email protected]>
- Loading branch information
Showing
18 changed files
with
742 additions
and
106 deletions.
There are no files selected for viewing
425 changes: 425 additions & 0 deletions
425
packages/common/src/components/TypeaheadSelect/TypeaheadSelect.tsx
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @index(['./*', /__/g], f => `export * from '${f.path}';`) | ||
export * from './TypeaheadSelect'; | ||
// @endindex |
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
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
55 changes: 55 additions & 0 deletions
55
...s/forklift-console-plugin/src/modules/Plans/views/create/components/PlanNameTextField.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,55 @@ | ||
import React from 'react'; | ||
import { Validation } from 'src/modules/Providers'; | ||
import { ForkliftTrans, useForkliftTranslation } from 'src/utils'; | ||
|
||
import { FormGroupWithHelpText } from '@kubev2v/common'; | ||
import { TextInput } from '@patternfly/react-core'; | ||
|
||
interface PlanNameTextFieldProps { | ||
value: string; | ||
validated: Validation; | ||
onChange: (event: React.FormEvent<HTMLInputElement>, value: string) => void; | ||
isRequired?: boolean; | ||
isDisabled?: boolean; | ||
} | ||
|
||
export const PlanNameTextField: React.FC<PlanNameTextFieldProps> = ({ | ||
value, | ||
validated, | ||
isDisabled, | ||
isRequired, | ||
onChange, | ||
}) => { | ||
const { t } = useForkliftTranslation(); | ||
const [isUpdated, setIsUpdated] = React.useState(false); | ||
|
||
return ( | ||
<FormGroupWithHelpText | ||
label={t('Plan name')} | ||
isRequired={isRequired} | ||
fieldId="planName" | ||
{...(isUpdated && { | ||
validated: validated, | ||
helperTextInvalid: ( | ||
<ForkliftTrans> | ||
Name is required and must be a unique within a namespace and valid Kubernetes name. | ||
</ForkliftTrans> | ||
), | ||
})} | ||
> | ||
<TextInput | ||
spellCheck="false" | ||
isRequired={isRequired} | ||
type="text" | ||
id="planName" | ||
value={value} | ||
validated={isUpdated ? validated : 'default'} | ||
isDisabled={isDisabled} | ||
onChange={(event, value) => { | ||
onChange(event, value); | ||
setIsUpdated(true); | ||
}} | ||
/> | ||
</FormGroupWithHelpText> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
...s/forklift-console-plugin/src/modules/Plans/views/create/components/ProjectNameSelect.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,48 @@ | ||
import React from 'react'; | ||
import { useForkliftTranslation } from 'src/utils'; | ||
|
||
import { FormGroupWithHelpText, TypeaheadSelect, TypeaheadSelectOption } from '@kubev2v/common'; | ||
import { Popover } from '@patternfly/react-core'; | ||
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; | ||
|
||
interface ProjectNameSelectProps { | ||
value: string | undefined; | ||
options: TypeaheadSelectOption[]; | ||
onSelect: (value: string) => void; | ||
isDisabled?: boolean; | ||
popoverHelpContent?: React.ReactNode; | ||
} | ||
|
||
export const ProjectNameSelect: React.FC<ProjectNameSelectProps> = ({ | ||
value, | ||
options, | ||
isDisabled, | ||
popoverHelpContent, | ||
onSelect, | ||
}) => { | ||
const { t } = useForkliftTranslation(); | ||
|
||
return ( | ||
<FormGroupWithHelpText | ||
label={t('Project')} | ||
isRequired | ||
fieldId="project" | ||
labelIcon={ | ||
<Popover position="right" alertSeverityVariant="info" bodyContent={popoverHelpContent}> | ||
<button type="button" className="pf-c-form__group-label-help"> | ||
<HelpIcon /> | ||
</button> | ||
</Popover> | ||
} | ||
> | ||
<TypeaheadSelect | ||
id="project-name-select" | ||
selectOptions={options} | ||
selected={value} | ||
onSelect={(_, value) => onSelect(String(value))} | ||
onClearSelection={() => onSelect('')} | ||
isDisabled={isDisabled} | ||
/> | ||
</FormGroupWithHelpText> | ||
); | ||
}; |
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
Oops, something went wrong.