Make websiteId optional in filter controls to enable dashboard filtering
Allows BoardControls to render filter bar and date picker without requiring a websiteId. Website-specific features (segments, cohorts, filter value autocomplete, save segment) are gracefully hidden when no websiteId is available.
This commit is contained in:
@@ -9,16 +9,9 @@ export function BoardControls() {
|
|||||||
?.flatMap(row => row.columns)
|
?.flatMap(row => row.columns)
|
||||||
.map(column => column.component?.websiteId)
|
.map(column => column.component?.websiteId)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
const fallbackWebsiteId =
|
const fallbackWebsiteId = componentWebsiteIds?.[0];
|
||||||
componentWebsiteIds && new Set(componentWebsiteIds).size === 1
|
|
||||||
? componentWebsiteIds[0]
|
|
||||||
: undefined;
|
|
||||||
const websiteId = boardWebsiteId || fallbackWebsiteId;
|
const websiteId = boardWebsiteId || fallbackWebsiteId;
|
||||||
|
|
||||||
if (!websiteId) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box marginBottom="4">
|
<Box marginBottom="4">
|
||||||
<WebsiteControls websiteId={websiteId} />
|
<WebsiteControls websiteId={websiteId} />
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function WebsiteControls({
|
|||||||
allowDownload = false,
|
allowDownload = false,
|
||||||
allowCompare = false,
|
allowCompare = false,
|
||||||
}: {
|
}: {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
allowFilter?: boolean;
|
allowFilter?: boolean;
|
||||||
allowBounceFilter?: boolean;
|
allowBounceFilter?: boolean;
|
||||||
allowDateFilter?: boolean;
|
allowDateFilter?: boolean;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { X } from '@/components/icons';
|
|||||||
import { isSearchOperator } from '@/lib/params';
|
import { isSearchOperator } from '@/lib/params';
|
||||||
|
|
||||||
export interface FilterRecordProps {
|
export interface FilterRecordProps {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
type: string;
|
type: string;
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import { type FieldGroup, useFields, useMessages, useMobile } from '@/components
|
|||||||
import { Plus } from '@/components/icons';
|
import { Plus } from '@/components/icons';
|
||||||
|
|
||||||
export interface FieldFiltersProps {
|
export interface FieldFiltersProps {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
value?: { name: string; operator: string; value: string }[];
|
value?: { name: string; operator: string; value: string }[];
|
||||||
exclude?: string[];
|
exclude?: string[];
|
||||||
match?: string;
|
match?: string;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
import { Bookmark, X } from '@/components/icons';
|
import { Bookmark, X } from '@/components/icons';
|
||||||
import { isSearchOperator } from '@/lib/params';
|
import { isSearchOperator } from '@/lib/params';
|
||||||
|
|
||||||
export function FilterBar({ websiteId }: { websiteId: string }) {
|
export function FilterBar({ websiteId }: { websiteId?: string }) {
|
||||||
const { t, labels } = useMessages();
|
const { t, labels } = useMessages();
|
||||||
const { formatValue } = useFormat();
|
const { formatValue } = useFormat();
|
||||||
const {
|
const {
|
||||||
@@ -32,7 +32,8 @@ export function FilterBar({ websiteId }: { websiteId: string }) {
|
|||||||
} = useNavigation();
|
} = useNavigation();
|
||||||
const { filters, operatorLabels } = useFilters();
|
const { filters, operatorLabels } = useFilters();
|
||||||
const { data, isLoading } = useWebsiteSegmentQuery(websiteId, segment || cohort);
|
const { data, isLoading } = useWebsiteSegmentQuery(websiteId, segment || cohort);
|
||||||
const canSaveSegment = filters.length > 0 && !segment && !cohort && !pathname.includes('/share');
|
const canSaveSegment =
|
||||||
|
!!websiteId && filters.length > 0 && !segment && !cohort && !pathname.includes('/share');
|
||||||
|
|
||||||
const handleCloseFilter = (param: string) => {
|
const handleCloseFilter = (param: string) => {
|
||||||
router.push(updateParams({ [param]: undefined }));
|
router.push(updateParams({ [param]: undefined }));
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP
|
|||||||
const [currentCohort, setCurrentCohort] = useState(cohort);
|
const [currentCohort, setCurrentCohort] = useState(cohort);
|
||||||
const [currentMatch, setCurrentMatch] = useState<string>(match || 'all');
|
const [currentMatch, setCurrentMatch] = useState<string>(match || 'all');
|
||||||
const { isMobile } = useMobile();
|
const { isMobile } = useMobile();
|
||||||
const excludeFilters = pathname.includes('/pixels') || pathname.includes('/links');
|
const excludeFilters = !websiteId || pathname.includes('/pixels') || pathname.includes('/links');
|
||||||
const excludeEvent = !pathname.endsWith('/events') && !pathname.endsWith('/replays');
|
const excludeEvent = !pathname.endsWith('/events') && !pathname.endsWith('/replays');
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useWebsiteSegmentsQuery } from '@/components/hooks';
|
|||||||
import { ChartPie, UserPlus } from '@/components/icons';
|
import { ChartPie, UserPlus } from '@/components/icons';
|
||||||
|
|
||||||
export interface SegmentFiltersProps {
|
export interface SegmentFiltersProps {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
segmentId: string;
|
segmentId: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
onChange?: (id: string, type: string) => void;
|
onChange?: (id: string, type: string) => void;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { getDateRangeValue } from '@/lib/date';
|
|||||||
import { DateFilter } from './DateFilter';
|
import { DateFilter } from './DateFilter';
|
||||||
|
|
||||||
export interface WebsiteDateFilterProps {
|
export interface WebsiteDateFilterProps {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
compare?: string;
|
compare?: string;
|
||||||
showAllTime?: boolean;
|
showAllTime?: boolean;
|
||||||
showButtons?: boolean;
|
showButtons?: boolean;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { filtersArrayToObject } from '@/lib/params';
|
|||||||
export function WebsiteFilterButton({
|
export function WebsiteFilterButton({
|
||||||
websiteId,
|
websiteId,
|
||||||
}: {
|
}: {
|
||||||
websiteId: string;
|
websiteId?: string;
|
||||||
position?: 'bottom' | 'top' | 'left' | 'right';
|
position?: 'bottom' | 'top' | 'left' | 'right';
|
||||||
alignment?: 'end' | 'center' | 'start';
|
alignment?: 'end' | 'center' | 'start';
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user