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

feat: [M3-6150] - Add Cloud-init compatible check box to Image Upload flow #8800

Merged
merged 10 commits into from
Feb 28, 2023
3 changes: 3 additions & 0 deletions packages/manager/src/components/FileUploader/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const useStyles = makeStyles((theme: Theme) => ({
interface Props {
label: string;
description?: string;
isCloudInit?: boolean;
region: string;
dropzoneDisabled: boolean;
apiError: string | undefined;
Expand All @@ -131,6 +132,7 @@ const FileUploader: React.FC<CombinedProps> = (props) => {
const {
label,
description,
isCloudInit,
region,
dropzoneDisabled,
apiError,
Expand Down Expand Up @@ -299,6 +301,7 @@ const FileUploader: React.FC<CombinedProps> = (props) => {
uploadImage({
label,
description: description || undefined,
cloud_init: isCloudInit || undefined,
region,
})
)
Expand Down
34 changes: 33 additions & 1 deletion packages/manager/src/features/Images/ImageUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import ActionsPanel from 'src/components/ActionsPanel';
import Button from 'src/components/Button';
import CheckBox from 'src/components/CheckBox';
import ConfirmationDialog from 'src/components/ConfirmationDialog';
import Paper from 'src/components/core/Paper';
import { makeStyles, Theme } from 'src/components/core/styles';
Expand Down Expand Up @@ -55,16 +56,37 @@ const useStyles = makeStyles((theme: Theme) => ({
...theme.applyLinkStyles,
fontWeight: 700,
},
cloudInitCheckboxWrapper: {
marginTop: theme.spacing(2),
cpathipa marked this conversation as resolved.
Show resolved Hide resolved
marginLeft: '3px',
},
}));

const cloudInitTooltipMessage = (
<Typography>
Only check this box if your Custom Image that is compatible with cloud-init,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Only check this box if your Custom Image is compatible with cloud-init?

Copy link
Contributor

@mjac0bs mjac0bs Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right; that sentence doesn't make sense with "that is compatible".

Also: Noting that we are expecting a final copy update to finalize the docs links in this PR and others. (This will be a follow up PR.)

or has had cloud-init installed at some point, and the config has been
changed to use our data service. <Link to="/">Link to doc</Link>
</Typography>
);
export interface Props {
label: string;
description: string;
isCloudInit: boolean;
changeLabel: (e: React.ChangeEvent<HTMLInputElement>) => void;
changeDescription: (e: React.ChangeEvent<HTMLInputElement>) => void;
changeIsCloudInit: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

export const ImageUpload: React.FC<Props> = (props) => {
const { label, description, changeLabel, changeDescription } = props;
const {
label,
description,
changeLabel,
changeDescription,
changeIsCloudInit,
isCloudInit,
} = props;

const { data: profile } = useProfile();
const { data: grants } = useGrants();
Expand Down Expand Up @@ -213,6 +235,15 @@ export const ImageUpload: React.FC<Props> = (props) => {
errorText={errorMap.description}
disabled={!canCreateImage}
/>
<div className={classes.cloudInitCheckboxWrapper}>
<CheckBox
checked={isCloudInit}
onChange={changeIsCloudInit}
text="This image is Cloud-init compatible"
toolTipText={cloudInitTooltipMessage}
toolTipInteractive
/>
</div>

<RegionSelect
label="Region"
Expand Down Expand Up @@ -249,6 +280,7 @@ export const ImageUpload: React.FC<Props> = (props) => {
label={label}
description={description}
region={region}
isCloudInit={isCloudInit}
dropzoneDisabled={uploadingDisabled}
apiError={errorMap.none} // Any errors that aren't related to 'label', 'description', or 'region' fields
setErrors={setErrors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const ImageCreate: React.FC<CombinedProps> = (props) => {
description={description}
changeLabel={handleSetLabel}
changeDescription={handleSetDescription}
changeIsCloudInit={() => setIsCloudInit(!isCloudInit)}
isCloudInit={isCloudInit}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should already be merged into the feature branch so we wouldn't expect changes in this file. I think you just ordered the props differently here, but not a big deal.

/>
),
},
Expand Down