Skip to content

Commit

Permalink
feat: object title change to string
Browse files Browse the repository at this point in the history
  • Loading branch information
gee05053 committed Dec 8, 2023
1 parent 82957cd commit eb42d1a
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions react/src/components/TableColumnsSettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,35 @@ const TableColumnsSettingModal: React.FC<TableColumnsSettingProps> = ({
const { t } = useTranslation();
const { token } = theme.useToken();

const columnOptions = columns.map((column) => ({
label: _.toString(column.title),
value: _.toString(column.key),
}));
const onChangeTitleToString: any = (element: any) => {
const text = React.Children.map(element.props.children, (child) => {
if (typeof child === 'string') {
return child;
} else if ('props' in child) {
return onChangeTitleToString(child);
}
});
return text;
};

const columnOptions = columns.map((column) => {
if (typeof column.title === 'string') {
return {
label: column.title,
value: _.toString(column.key),
};
} else if (typeof column.title === 'object' && 'props' in column.title!) {
return {
label: onChangeTitleToString(column.title),
value: _.toString(column.key),
};
} else {
return {
label: undefined,
value: _.toString(column.key),
};
}
});

return (
<BAIModal
Expand Down

0 comments on commit eb42d1a

Please sign in to comment.