-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instance) add configuration of migration options and nesting on …
…instances and profiles Signed-off-by: David Edler <[email protected]>
- Loading branch information
Showing
12 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
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,54 @@ | ||
import { FC } from "react"; | ||
import { Select } from "@canonical/react-components"; | ||
import { | ||
InstanceAndProfileFormikProps, | ||
InstanceAndProfileFormValues, | ||
} from "./instanceAndProfileFormValues"; | ||
import { getConfigurationRow } from "components/ConfigurationRow"; | ||
import ScrollableConfigurationTable from "components/forms/ScrollableConfigurationTable"; | ||
import { getInstanceKey } from "util/instanceConfigFields"; | ||
import { optionRenderer } from "util/formFields"; | ||
import { optionAllowDeny } from "util/instanceOptions"; | ||
import { CreateInstanceFormValues } from "pages/instances/CreateInstance"; | ||
|
||
export interface MigrationFormValues { | ||
migration_stateful?: string; | ||
} | ||
|
||
export const migrationPayload = (values: InstanceAndProfileFormValues) => { | ||
return { | ||
[getInstanceKey("migration_stateful")]: values.migration_stateful, | ||
}; | ||
}; | ||
|
||
interface Props { | ||
formik: InstanceAndProfileFormikProps; | ||
} | ||
|
||
const MigrationForm: FC<Props> = ({ formik }) => { | ||
const isInstance = formik.values.entityType === "instance"; | ||
const isVmOnlyDisabled = | ||
isInstance && | ||
(formik.values as CreateInstanceFormValues).instanceType !== | ||
"virtual-machine"; | ||
|
||
return ( | ||
<ScrollableConfigurationTable | ||
rows={[ | ||
getConfigurationRow({ | ||
formik, | ||
label: "Stateful migration (VMs only)", | ||
name: "migration_stateful", | ||
defaultValue: "", | ||
disabled: isVmOnlyDisabled, | ||
readOnlyRenderer: (val) => optionRenderer(val, optionAllowDeny), | ||
children: ( | ||
<Select options={optionAllowDeny} disabled={isVmOnlyDisabled} /> | ||
), | ||
}), | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export default MigrationForm; |
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
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
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