From e451cacded06b4152ddc34048c675fa8f2ffdf59 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Tue, 22 Oct 2024 12:44:23 -0400 Subject: [PATCH] DownloadImageDialog: Update Version dropdown styling to match the UI's Change-type: patch --- .../DownloadImageDialog/ImageForm.tsx | 114 ++++++++++-------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/src/components/DownloadImageDialog/ImageForm.tsx b/src/components/DownloadImageDialog/ImageForm.tsx index fa570e4..7e893ea 100644 --- a/src/components/DownloadImageDialog/ImageForm.tsx +++ b/src/components/DownloadImageDialog/ImageForm.tsx @@ -20,6 +20,8 @@ import { Typography, IconButton, Autocomplete, + useTheme, + Stack, } from '@mui/material'; import HelpIcon from '@mui/icons-material/Help'; import { memo, useCallback, useEffect, useMemo, useState } from 'react'; @@ -40,6 +42,9 @@ import { DeviceType, Dictionary, OsVersionsByDeviceType } from './models'; import { Visibility, VisibilityOff } from '@mui/icons-material'; import { FALLBACK_LOGO_UNKNOWN_DEVICE } from './utils'; import { ChipProps } from '../Chip'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'; +import { Callout } from '../Callout'; const POLL_INTERVAL_DOCS = 'https://www.balena.io/docs/reference/supervisor/bandwidth-reduction/#side-effects--warnings'; @@ -108,6 +113,8 @@ export const ImageForm: React.FC = memo( onSelectedDeviceTypeChange, onChange, }) => { + const theme = useTheme(); + const [showAdvancedSettings, setShowAdvancedSettings] = useState(false); const [showPassword, setShowPassword] = useState(false); const [version, setVersion] = useState< @@ -199,6 +206,12 @@ export const ImageForm: React.FC = memo( } }, [version, variant, onChange, versionSelectionOpts]); + const selectedOSVersion = useMemo( + () => + versionSelectionOpts.find((version) => version.value === model.version), + [model.version, versionSelectionOpts], + ); + return ( = memo( > Select version - + renderOption={(props, option) => ( + + + + )} + renderInput={({ InputProps, ...params }) => ( + + + + ), + }} + /> + )} + disableClearable + /> {showAllVersionsToggle && ( = ({ ); }; -export const VersionSelectItem = ({ option }: any) => { +// TODO: We need a better way than just copying the styling. Consider creating a component to export +export const VersionSelectItem = ({ + option, +}: { + option: { + title: string; + isRecommended?: boolean; + knownIssueList: string | null; + }; +}) => { return ( - - - {option.title} - {!!option.line && ( - - )} - {!!option.isRecommended && ( - + + + {option.title} + {option.isRecommended && ( + )} - {!!option.knownIssueList && ( - - - {option.knownIssueList} - - )} - - + + {!!option.knownIssueList && ( + + {option.knownIssueList} + + )} + ); };