fix: separate Filter Segment implementation from DataTableProvider (#20587)
* fix: separate Filter Segment implementation from DataTableProvider * disable components * early return * fix type error * add missing export
This commit is contained in:
1 parent
70eff63529
commit
5935cf7f1b
14 files changed
+123
-68
No files matched your search
@@ -23,7 +23,7 @@ import {
|
||||
} from "@calcom/ui/components/table";
|
||||
|
||||
import { useColumnSizingVars } from "../hooks";
|
||||
import { usePersistentColumnResizing } from "../lib/resizing";
|
||||
import { useColumnResizing } from "../hooks/useColumnResizing";
|
||||
|
||||
export type DataTablePropsFromWrapper<TData> = {
|
||||
table: ReactTableType<TData>;
|
||||
@@ -96,7 +96,7 @@ export function DataTable<TData>({
|
||||
|
||||
const columnSizingVars = useColumnSizingVars({ table });
|
||||
|
||||
usePersistentColumnResizing({
|
||||
useColumnResizing({
|
||||
enabled: Boolean(enableColumnResizing),
|
||||
table,
|
||||
tableContainerRef,
|
||||
|
||||
@@ -31,7 +31,7 @@ type SubmenuItem = {
|
||||
|
||||
export function FilterSegmentSelect() {
|
||||
const { t } = useLocale();
|
||||
const { segments, selectedSegment, segmentId, setSegmentId } = useDataTable();
|
||||
const { segments, selectedSegment, segmentId, setSegmentId, isSegmentEnabled } = useDataTable();
|
||||
const [segmentToRename, setSegmentToRename] = useState<FilterSegmentOutput | undefined>();
|
||||
const [segmentToDuplicate, setSegmentToDuplicate] = useState<FilterSegmentOutput | undefined>();
|
||||
const [segmentToDelete, setSegmentToDelete] = useState<FilterSegmentOutput | undefined>();
|
||||
@@ -99,6 +99,14 @@ export function FilterSegmentSelect() {
|
||||
];
|
||||
}, [segments, t]);
|
||||
|
||||
if (!isSegmentEnabled) {
|
||||
return (
|
||||
<Button color="secondary" StartIcon="list-filter" EndIcon="chevron-down" disabled>
|
||||
{t("segment")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dropdown>
|
||||
|
||||
@@ -50,6 +50,7 @@ export function SaveFilterSegmentButton() {
|
||||
columnSizing,
|
||||
selectedSegment,
|
||||
canSaveSegment,
|
||||
isSegmentEnabled,
|
||||
setSegmentId,
|
||||
pageSize,
|
||||
searchTerm,
|
||||
@@ -161,6 +162,14 @@ export function SaveFilterSegmentButton() {
|
||||
setIsOpen(open);
|
||||
};
|
||||
|
||||
if (!isSegmentEnabled) {
|
||||
return (
|
||||
<Button StartIcon="bookmark" color="secondary" disabled>
|
||||
{t("save")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={handleOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
|
||||
Reference in new issue
Block a user