Skip to content

Commit

Permalink
Merge branch 'main' into kiahna-tucker/ux-tweaks/priority-alerting
Browse files Browse the repository at this point in the history
  • Loading branch information
kiahna-tucker committed Feb 21, 2025
2 parents f311a9a + bf28a55 commit e7bec8e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 139 deletions.
29 changes: 29 additions & 0 deletions src/forms/renderers/AutoCompleteInputWithStartAdornment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { AutocompleteRenderInputParams, Box, Input } from '@mui/material';
import { ReactNode } from 'react';

interface Props {
textFieldProps: AutocompleteRenderInputParams;
startAdornment: ReactNode | null;
}

function AutoCompleteInputWithStartAdornment({
startAdornment: icon,
textFieldProps,
}: Props) {
if (icon) {
textFieldProps.InputProps.startAdornment = (
<Box style={{ paddingRight: 5 }}>{icon}</Box>
);
}

return (
<Input
{...textFieldProps.InputProps}
inputProps={textFieldProps.inputProps}
fullWidth={textFieldProps.fullWidth}
disabled={textFieldProps.disabled}
/>
);
}

export default AutoCompleteInputWithStartAdornment;
33 changes: 16 additions & 17 deletions src/forms/renderers/ConnectorSelect/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import {
AutocompleteRenderOptionState,
FilterOptionsState,
} from '@mui/material';
import ConnectorInput from 'forms/renderers/ConnectorSelect/Input';
import ConnectorIcon from 'components/connectors/ConnectorIcon';
import ConnectorOption from 'forms/renderers/ConnectorSelect/Option';
import merge from 'lodash/merge';
import React, { ReactNode, useMemo } from 'react';
import AutoCompleteInputWithStartAdornment from '../AutoCompleteInputWithStartAdornment';

export interface WithOptionLabel {
getOptionLabel?(option: EnumOption): string;
Expand All @@ -61,22 +61,19 @@ export const ConnectorAutoComplete = (
className,
id,
enabled,
uischema,
path,
options,
config,
handleChange,
getOptionLabel,
filterOptions,
} = props;

const appliedUiSchemaOptions = merge({}, config, uischema.options);
const [inputValue, setInputValue] = React.useState('');
const currentOption = useMemo(
() =>
options?.find((option) => {
return areOptionsEqual(option.value, data);
}) ?? null,
}) ?? undefined,
[data, options]
);

Expand All @@ -87,6 +84,7 @@ export const ConnectorAutoComplete = (
className={className}
id={id}
disabled={!enabled}
disableClearable
value={currentOption}
inputValue={inputValue}
onChange={(_event: any, newValue: EnumOption | null) => {
Expand All @@ -103,17 +101,18 @@ export const ConnectorAutoComplete = (
marginTop: 2,
}}
filterOptions={filterOptions}
renderInput={({ inputProps, InputProps }) => {
return (
<ConnectorInput
inputProps={inputProps}
InputProps={InputProps}
appliedUiSchemaOptions={appliedUiSchemaOptions}
enabled={enabled}
currentOption={currentOption}
/>
);
}}
renderInput={(textFieldProps) => (
<AutoCompleteInputWithStartAdornment
textFieldProps={textFieldProps}
startAdornment={
currentOption ? (
<ConnectorIcon
iconPath={currentOption.value.iconPath}
/>
) : null
}
/>
)}
renderOption={(renderOptionProps, option) => {
return (
<ConnectorOption
Expand Down
52 changes: 0 additions & 52 deletions src/forms/renderers/ConnectorSelect/Input.tsx

This file was deleted.

36 changes: 19 additions & 17 deletions src/forms/renderers/DataPlaneSelector/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import {
MenuList,
Typography,
} from '@mui/material';
import merge from 'lodash/merge';
import DataPlaneIcon from 'components/shared/Entity/DataPlaneIcon';
import React, { ReactNode, useMemo } from 'react';
import { useIntl } from 'react-intl';
import DataPlaneInput from './Input';
import AutoCompleteInputWithStartAdornment from '../AutoCompleteInputWithStartAdornment';
import Option from './Option';

export interface WithOptionLabel {
Expand All @@ -61,23 +61,20 @@ export const DataPlaneAutoComplete = ({
className,
id,
enabled,
uischema,
path,
options,
config,
handleChange,
getOptionLabel,
filterOptions,
}: EnumCellProps & WithClassname & WithOptionLabel) => {
const intl = useIntl();

const appliedUiSchemaOptions = merge({}, config, uischema.options);
const [inputValue, setInputValue] = React.useState('');
const currentOption = useMemo(
() =>
options?.find((option) => {
return areOptionsEqual(option.value, data);
}) ?? null,
}) ?? undefined,
[data, options]
);

Expand All @@ -87,6 +84,7 @@ export const DataPlaneAutoComplete = ({
className={className}
clearOnBlur
disabled={!enabled}
disableClearable
filterOptions={filterOptions}
fullWidth
getOptionLabel={getOptionLabel ?? ((option) => option.label)}
Expand Down Expand Up @@ -118,17 +116,21 @@ export const DataPlaneAutoComplete = ({
<MenuList style={{ padding: 0 }}>{children}</MenuList>
</li>
)}
renderInput={({ inputProps, InputProps }) => {
return (
<DataPlaneInput
inputProps={inputProps}
InputProps={InputProps}
appliedUiSchemaOptions={appliedUiSchemaOptions}
enabled={enabled}
currentOption={currentOption}
/>
);
}}
renderInput={(textFieldProps) => (
<AutoCompleteInputWithStartAdornment
textFieldProps={textFieldProps}
startAdornment={
currentOption ? (
<DataPlaneIcon
provider={
currentOption.value.dataPlaneName.provider
}
scope={currentOption.value.scope}
/>
) : null
}
/>
)}
renderOption={(renderOptionProps, option) => {
return (
<Option
Expand Down
53 changes: 0 additions & 53 deletions src/forms/renderers/DataPlaneSelector/Input.tsx

This file was deleted.

0 comments on commit e7bec8e

Please sign in to comment.