Skip to content

Commit

Permalink
refactor: Unify column and type values with metadata separator.
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodallacqua-hpe committed Oct 22, 2024
1 parent f9adaa3 commit 659cf98
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions webui/react/src/components/FilterForm/components/FilterField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const debounceFunc = debounce(1000, (func: () => void) => {
func();
});

export const METADATA_SEPARATOR = '\u241F' as const; // TODO: unify after merging PR 10052

const COLUMN_TYPE = {
NormalColumnType: 'NormalColumnType',
SpecialColumnType: 'SpecialColumnType',
Expand Down Expand Up @@ -101,7 +103,7 @@ const FilterField = ({

const onChangeColumnName = (value: SelectValue) => {
const prevType = field.type;
const [newColName, type] = (value?.toString() ?? '').split(' ');
const [type, newColName] = (value?.toString() ?? '').split(METADATA_SEPARATOR, 2);
const newCol = columns.find((c) => c.column === newColName && type === c.type);
if (newCol) {
Observable.batch(() => {
Expand Down Expand Up @@ -245,12 +247,12 @@ const FilterField = ({
autoFocus
data-test="columnName"
dropdownMatchSelectWidth={300}
options={columns.map((col, idx) => ({
key: `${col.column} ${idx}`,
options={columns.map((col) => ({
key: `${col.type}${METADATA_SEPARATOR}${col.column}`,
label: getColDisplayName(col),
value: `${col.column} ${col.type}`,
value: `${col.type}${METADATA_SEPARATOR}${col.column}`,
}))}
value={`${field.columnName} ${field.type}`}
value={`${field.type}${METADATA_SEPARATOR}${field.columnName}`}
width={'100%'}
onChange={onChangeColumnName}
/>
Expand Down

0 comments on commit 659cf98

Please sign in to comment.