Skip to content

Commit e7bec8e

Browse files
committed
Merge branch 'main' into kiahna-tucker/ux-tweaks/priority-alerting
2 parents f311a9a + bf28a55 commit e7bec8e

File tree

5 files changed

+64
-139
lines changed

5 files changed

+64
-139
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { AutocompleteRenderInputParams, Box, Input } from '@mui/material';
2+
import { ReactNode } from 'react';
3+
4+
interface Props {
5+
textFieldProps: AutocompleteRenderInputParams;
6+
startAdornment: ReactNode | null;
7+
}
8+
9+
function AutoCompleteInputWithStartAdornment({
10+
startAdornment: icon,
11+
textFieldProps,
12+
}: Props) {
13+
if (icon) {
14+
textFieldProps.InputProps.startAdornment = (
15+
<Box style={{ paddingRight: 5 }}>{icon}</Box>
16+
);
17+
}
18+
19+
return (
20+
<Input
21+
{...textFieldProps.InputProps}
22+
inputProps={textFieldProps.inputProps}
23+
fullWidth={textFieldProps.fullWidth}
24+
disabled={textFieldProps.disabled}
25+
/>
26+
);
27+
}
28+
29+
export default AutoCompleteInputWithStartAdornment;

src/forms/renderers/ConnectorSelect/AutoComplete.tsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import {
3131
AutocompleteRenderOptionState,
3232
FilterOptionsState,
3333
} from '@mui/material';
34-
import ConnectorInput from 'forms/renderers/ConnectorSelect/Input';
34+
import ConnectorIcon from 'components/connectors/ConnectorIcon';
3535
import ConnectorOption from 'forms/renderers/ConnectorSelect/Option';
36-
import merge from 'lodash/merge';
3736
import React, { ReactNode, useMemo } from 'react';
37+
import AutoCompleteInputWithStartAdornment from '../AutoCompleteInputWithStartAdornment';
3838

3939
export interface WithOptionLabel {
4040
getOptionLabel?(option: EnumOption): string;
@@ -61,22 +61,19 @@ export const ConnectorAutoComplete = (
6161
className,
6262
id,
6363
enabled,
64-
uischema,
6564
path,
6665
options,
67-
config,
6866
handleChange,
6967
getOptionLabel,
7068
filterOptions,
7169
} = props;
7270

73-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
7471
const [inputValue, setInputValue] = React.useState('');
7572
const currentOption = useMemo(
7673
() =>
7774
options?.find((option) => {
7875
return areOptionsEqual(option.value, data);
79-
}) ?? null,
76+
}) ?? undefined,
8077
[data, options]
8178
);
8279

@@ -87,6 +84,7 @@ export const ConnectorAutoComplete = (
8784
className={className}
8885
id={id}
8986
disabled={!enabled}
87+
disableClearable
9088
value={currentOption}
9189
inputValue={inputValue}
9290
onChange={(_event: any, newValue: EnumOption | null) => {
@@ -103,17 +101,18 @@ export const ConnectorAutoComplete = (
103101
marginTop: 2,
104102
}}
105103
filterOptions={filterOptions}
106-
renderInput={({ inputProps, InputProps }) => {
107-
return (
108-
<ConnectorInput
109-
inputProps={inputProps}
110-
InputProps={InputProps}
111-
appliedUiSchemaOptions={appliedUiSchemaOptions}
112-
enabled={enabled}
113-
currentOption={currentOption}
114-
/>
115-
);
116-
}}
104+
renderInput={(textFieldProps) => (
105+
<AutoCompleteInputWithStartAdornment
106+
textFieldProps={textFieldProps}
107+
startAdornment={
108+
currentOption ? (
109+
<ConnectorIcon
110+
iconPath={currentOption.value.iconPath}
111+
/>
112+
) : null
113+
}
114+
/>
115+
)}
117116
renderOption={(renderOptionProps, option) => {
118117
return (
119118
<ConnectorOption

src/forms/renderers/ConnectorSelect/Input.tsx

-52
This file was deleted.

src/forms/renderers/DataPlaneSelector/AutoComplete.tsx

+19-17
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333
MenuList,
3434
Typography,
3535
} from '@mui/material';
36-
import merge from 'lodash/merge';
36+
import DataPlaneIcon from 'components/shared/Entity/DataPlaneIcon';
3737
import React, { ReactNode, useMemo } from 'react';
3838
import { useIntl } from 'react-intl';
39-
import DataPlaneInput from './Input';
39+
import AutoCompleteInputWithStartAdornment from '../AutoCompleteInputWithStartAdornment';
4040
import Option from './Option';
4141

4242
export interface WithOptionLabel {
@@ -61,23 +61,20 @@ export const DataPlaneAutoComplete = ({
6161
className,
6262
id,
6363
enabled,
64-
uischema,
6564
path,
6665
options,
67-
config,
6866
handleChange,
6967
getOptionLabel,
7068
filterOptions,
7169
}: EnumCellProps & WithClassname & WithOptionLabel) => {
7270
const intl = useIntl();
7371

74-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
7572
const [inputValue, setInputValue] = React.useState('');
7673
const currentOption = useMemo(
7774
() =>
7875
options?.find((option) => {
7976
return areOptionsEqual(option.value, data);
80-
}) ?? null,
77+
}) ?? undefined,
8178
[data, options]
8279
);
8380

@@ -87,6 +84,7 @@ export const DataPlaneAutoComplete = ({
8784
className={className}
8885
clearOnBlur
8986
disabled={!enabled}
87+
disableClearable
9088
filterOptions={filterOptions}
9189
fullWidth
9290
getOptionLabel={getOptionLabel ?? ((option) => option.label)}
@@ -118,17 +116,21 @@ export const DataPlaneAutoComplete = ({
118116
<MenuList style={{ padding: 0 }}>{children}</MenuList>
119117
</li>
120118
)}
121-
renderInput={({ inputProps, InputProps }) => {
122-
return (
123-
<DataPlaneInput
124-
inputProps={inputProps}
125-
InputProps={InputProps}
126-
appliedUiSchemaOptions={appliedUiSchemaOptions}
127-
enabled={enabled}
128-
currentOption={currentOption}
129-
/>
130-
);
131-
}}
119+
renderInput={(textFieldProps) => (
120+
<AutoCompleteInputWithStartAdornment
121+
textFieldProps={textFieldProps}
122+
startAdornment={
123+
currentOption ? (
124+
<DataPlaneIcon
125+
provider={
126+
currentOption.value.dataPlaneName.provider
127+
}
128+
scope={currentOption.value.scope}
129+
/>
130+
) : null
131+
}
132+
/>
133+
)}
132134
renderOption={(renderOptionProps, option) => {
133135
return (
134136
<Option

src/forms/renderers/DataPlaneSelector/Input.tsx

-53
This file was deleted.

0 commit comments

Comments
 (0)