core-components: deprecate checkbox-tree
Signed-off-by: Ainhoa Larumbe <ainhoal@spotify.com>
This commit is contained in:
@@ -225,6 +225,10 @@ const indexer = (
|
||||
};
|
||||
}, {});
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated CheckboxTree is no longer used in Table filters
|
||||
*/
|
||||
export function CheckboxTree(props: CheckboxTreeProps) {
|
||||
const { subCategories, label, selected, onChange, triggerReset } = props;
|
||||
const classes = useStyles();
|
||||
|
||||
@@ -53,7 +53,7 @@ const useSubvalueCellStyles = makeStyles<BackstageTheme>(theme => ({
|
||||
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type Filter = {
|
||||
type: 'select' | 'checkbox-tree' | 'multiple-select';
|
||||
type: 'select' | /** @deprecated */ 'checkbox-tree' | 'multiple-select';
|
||||
element:
|
||||
| Without<CheckboxTreeProps, 'onChange'>
|
||||
| Without<SelectProps, 'onChange'>;
|
||||
|
||||
@@ -191,7 +191,7 @@ export interface TableColumn<T extends object = {}> extends Column<T> {
|
||||
|
||||
export type TableFilter = {
|
||||
column: string;
|
||||
type: 'select' | 'multiple-select' | 'checkbox-tree';
|
||||
type: 'select' | 'multiple-select' | /** @deprecated */ 'checkbox-tree';
|
||||
};
|
||||
|
||||
export type TableState = {
|
||||
@@ -419,12 +419,22 @@ export function Table<T extends object = {}>(props: TableProps<T>) {
|
||||
};
|
||||
};
|
||||
|
||||
const constructFilterElement = (
|
||||
filter: TableFilter,
|
||||
):
|
||||
| Without<CheckboxTreeProps, 'onChange'>
|
||||
| Without<SelectProps, 'onChange'> => {
|
||||
if (filter.type === 'checkbox-tree') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('"checkbox-tree" filter type is deprecated');
|
||||
return constructCheckboxTree(filter);
|
||||
}
|
||||
return constructSelect(filter);
|
||||
};
|
||||
|
||||
return filterConfig.map(filter => ({
|
||||
type: filter.type,
|
||||
element:
|
||||
filter.type === 'checkbox-tree'
|
||||
? constructCheckboxTree(filter)
|
||||
: constructSelect(filter),
|
||||
element: constructFilterElement(filter),
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user