diff --git a/src/components/Section.tsx b/src/components/Section.tsx index d9af7f8cc..afe1ed985 100644 --- a/src/components/Section.tsx +++ b/src/components/Section.tsx @@ -55,10 +55,11 @@ interface Props { children?: React.ReactNode noPaddingTop?: boolean noMarginTop?: boolean + sx?: object } export default function Section(props: Props) { - const { title, description, collapsable, children, noPaddingTop, noMarginTop } = props + const { title, description, collapsable, children, noPaddingTop, noMarginTop, sx } = props const [expanded, setExpanded] = useState(true) const handleAccordionChange = () => { @@ -67,7 +68,7 @@ export default function Section(props: Props) { if (collapsable) { return ( - + @@ -89,7 +90,7 @@ export default function Section(props: Props) { } return ( - + {title && {title}} {description && {description}} {children} diff --git a/src/components/Workloads.tsx b/src/components/Workloads.tsx index dd55448a1..eb82d2d35 100644 --- a/src/components/Workloads.tsx +++ b/src/components/Workloads.tsx @@ -3,12 +3,11 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { Link } from 'react-router-dom' import { GetAllWorkloadsApiResponse } from 'redux/otomiApi' -import { CircularProgress } from '@mui/material' +import { Status, getStatus } from 'utils/status' import { useSocket } from 'providers/Socket' import { HeadCell } from './EnhancedTable' import RLink from './Link' import ListTable from './ListTable' -import Iconify from './Iconify' interface Row { teamId: string @@ -38,22 +37,6 @@ const getArgocdApplicationLink = (row: Row, domainSuffix: string) => { ) } -type Status = 'Unknown' | 'Pending' | 'Succeeded' | 'NotFound' - -export const getStatus = (status: Status) => { - if (!status || status === 'NotFound') return - switch (status) { - case 'Unknown': - return - case 'Pending': - return - case 'Succeeded': - return - default: - return - } -} - interface Props { workloads: GetAllWorkloadsApiResponse teamId?: string @@ -89,7 +72,7 @@ export default function ({ workloads, teamId }: Props): React.ReactElement { { id: 'Status', label: 'Status', - renderer: (row: Row) => getStatus(statuses?.workloads?.[row.name]), + renderer: (row: Row) => getStatus((statuses?.workloads?.[row.name] as Status) || 'NotFound'), }, ] diff --git a/src/components/forms/Autocomplete.tsx b/src/components/forms/Autocomplete.tsx index 4bf97f4f4..454e5d828 100644 --- a/src/components/forms/Autocomplete.tsx +++ b/src/components/forms/Autocomplete.tsx @@ -36,7 +36,9 @@ export interface EnhancedAutocompleteProps< /** Removes the "select all" option for multiselect */ disableSelectAll?: boolean textFieldProps?: Partial - width?: 'small' | 'medium' | 'large' + width?: 'small' | 'medium' | 'large' | 'fullwidth' + /** Hide placeholder and minimize input width when values are selected (for cleaner multi-select UX) */ + compactMultiSelect?: boolean } export function Autocomplete< @@ -58,6 +60,7 @@ export function Autocomplete< loadingText, multiple, disableSelectAll = false, + noMarginTop = false, noOptionsText, onBlur, options, @@ -68,11 +71,15 @@ export function Autocomplete< value, onChange, width = 'medium', + compactMultiSelect = false, ...rest } = props const [inPlaceholder, setInPlaceholder] = useState('') + // Check if there are selected values (for hiding placeholder when values exist) + const hasValues = multiple ? Array.isArray(value) && value.length > 0 : !!value + // --- select-all logic --- const isSelectAllActive = multiple && Array.isArray(value) && value.length === options.length @@ -121,8 +128,10 @@ export function Autocomplete< label={label} width={width} loading={loading} - placeholder={inPlaceholder || placeholder || 'Select an option'} + noMarginTop={noMarginTop} + placeholder={compactMultiSelect && hasValues ? '' : inPlaceholder || placeholder || 'Select an option'} {...params} + {...textFieldProps} error={!!errorText} helperText={helperText} InputProps={{ @@ -133,6 +142,10 @@ export function Autocomplete< flexWrap: 'wrap', gap: 1, paddingRight: '44px', + '& input': { + minWidth: compactMultiSelect && hasValues && multiple ? '30px !important' : undefined, + width: compactMultiSelect && hasValues && multiple ? '30px !important' : undefined, + }, }, }} InputLabelProps={{ diff --git a/src/components/forms/TextArea.tsx b/src/components/forms/TextArea.tsx index 854cadbf3..3dc7073a0 100644 --- a/src/components/forms/TextArea.tsx +++ b/src/components/forms/TextArea.tsx @@ -175,23 +175,27 @@ export function AutoResizableTextarea({ return ( - - {label} - + {label && ( + + {label} + + )}