Merge remote-tracking branch 'upstream/dev' into feat/config-connectors

This commit is contained in:
Anish Sarkar 2026-01-11 15:56:36 +05:30
commit 2037ce4ce5
65 changed files with 2636 additions and 1908 deletions

View file

@ -1,6 +1,6 @@
"use client";
import { format, subDays, subYears } from "date-fns";
import { addDays, format, subDays, subYears } from "date-fns";
import { Calendar as CalendarIcon } from "lucide-react";
import type { FC } from "react";
import { Button } from "@/components/ui/button";
@ -14,6 +14,7 @@ interface DateRangeSelectorProps {
endDate: Date | undefined;
onStartDateChange: (date: Date | undefined) => void;
onEndDateChange: (date: Date | undefined) => void;
allowFutureDates?: boolean; // Allow future dates for calendar connectors
}
export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
@ -21,6 +22,7 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
endDate,
onStartDateChange,
onEndDateChange,
allowFutureDates = false,
}) => {
const handleLast30Days = () => {
const today = new Date();
@ -28,6 +30,12 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
onEndDateChange(today);
};
const handleNext30Days = () => {
const today = new Date();
onStartDateChange(today);
onEndDateChange(addDays(today, 30));
};
const handleLastYear = () => {
const today = new Date();
onStartDateChange(subYears(today, 1));
@ -43,8 +51,9 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
<div className="rounded-xl bg-slate-400/5 dark:bg-white/5 p-3 sm:p-6">
<h3 className="font-medium text-sm sm:text-base mb-4">Select Date Range</h3>
<p className="text-xs sm:text-sm text-muted-foreground mb-6">
Choose how far back you want to sync your data. You can always re-index later with different
dates.
{allowFutureDates
? "Choose the date range to sync your data. You can select future dates to index upcoming events."
: "Choose how far back you want to sync your data. You can always re-index later with different dates."}
</p>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
@ -72,7 +81,7 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
mode="single"
selected={startDate}
onSelect={onStartDateChange}
disabled={(date) => date > new Date()}
disabled={allowFutureDates ? false : (date) => date > new Date()}
/>
</PopoverContent>
</Popover>
@ -102,7 +111,11 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
mode="single"
selected={endDate}
onSelect={onEndDateChange}
disabled={(date) => date > new Date() || (startDate ? date < startDate : false)}
disabled={
allowFutureDates
? (date) => (startDate ? date < startDate : false)
: (date) => date > new Date() || (startDate ? date < startDate : false)
}
/>
</PopoverContent>
</Popover>
@ -129,6 +142,17 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
>
Last 30 Days
</Button>
{allowFutureDates && (
<Button
type="button"
variant="outline"
size="sm"
onClick={handleNext30Days}
className="text-xs sm:text-sm bg-slate-400/5 dark:bg-slate-400/5 border-slate-400/20 hover:bg-slate-400/10 dark:hover:bg-slate-400/10"
>
Next 30 Days
</Button>
)}
<Button
type="button"
variant="outline"

View file

@ -173,6 +173,7 @@ export const LumaConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting }
endDate={endDate}
onStartDateChange={setStartDate}
onEndDateChange={setEndDate}
allowFutureDates={true}
/>
{/* Periodic Sync Config */}

View file

@ -211,6 +211,10 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
endDate={endDate}
onStartDateChange={onStartDateChange}
onEndDateChange={onEndDateChange}
allowFutureDates={
connector.connector_type === "GOOGLE_CALENDAR_CONNECTOR" ||
connector.connector_type === "LUMA_CONNECTOR"
}
/>
)}

View file

@ -159,6 +159,10 @@ export const IndexingConfigurationView: FC<IndexingConfigurationViewProps> = ({
endDate={endDate}
onStartDateChange={onStartDateChange}
onEndDateChange={onEndDateChange}
allowFutureDates={
config.connectorType === "GOOGLE_CALENDAR_CONNECTOR" ||
config.connectorType === "LUMA_CONNECTOR"
}
/>
)}

View file

@ -80,6 +80,12 @@ export const useConnectorDialog = () => {
connectorTitle: string;
} | null>(null);
// Track if we came from accounts list when entering edit mode
const [cameFromAccountsList, setCameFromAccountsList] = useState<{
connectorType: string;
connectorTitle: string;
} | null>(null);
// Helper function to get frequency label
const getFrequencyLabel = useCallback((minutes: string): string => {
switch (minutes) {
@ -960,6 +966,14 @@ export const useConnectorDialog = () => {
return;
}
// Track if we came from accounts list view
// If viewingAccountsType matches this connector type, preserve it
if (viewingAccountsType && viewingAccountsType.connectorType === connector.connector_type) {
setCameFromAccountsList(viewingAccountsType);
} else {
setCameFromAccountsList(null);
}
// Track index with date range opened event
if (connector.is_indexable) {
trackIndexWithDateRangeOpened(
@ -989,7 +1003,7 @@ export const useConnectorDialog = () => {
url.searchParams.set("connectorId", connector.id.toString());
window.history.pushState({ modal: true }, "", url.toString());
},
[searchSpaceId]
[searchSpaceId, viewingAccountsType]
);
// Handle saving connector changes
@ -1252,13 +1266,30 @@ export const useConnectorDialog = () => {
// Handle going back from edit view
const handleBackFromEdit = useCallback(() => {
const url = new URL(window.location.href);
url.searchParams.set("modal", "connectors");
url.searchParams.set("tab", "all");
url.searchParams.delete("view");
url.searchParams.delete("connectorId");
router.replace(url.pathname + url.search, { scroll: false });
}, [router]);
// If we came from accounts list view, go back there
if (cameFromAccountsList && editingConnector) {
// Restore accounts list view
setViewingAccountsType(cameFromAccountsList);
setCameFromAccountsList(null);
const url = new URL(window.location.href);
url.searchParams.set("modal", "connectors");
url.searchParams.set("view", "accounts");
url.searchParams.set("connectorType", cameFromAccountsList.connectorType);
url.searchParams.delete("connectorId");
router.replace(url.pathname + url.search, { scroll: false });
} else {
// Otherwise, go back to main connector popup
const url = new URL(window.location.href);
url.searchParams.set("modal", "connectors");
url.searchParams.set("tab", "all");
url.searchParams.delete("view");
url.searchParams.delete("connectorId");
router.replace(url.pathname + url.search, { scroll: false });
}
setEditingConnector(null);
setConnectorName(null);
setConnectorConfig(null);
}, [router, cameFromAccountsList, editingConnector]);
// Handle dialog open/close
const handleOpenChange = useCallback(
@ -1289,6 +1320,7 @@ export const useConnectorDialog = () => {
setConnectorConfig(null);
setConnectingConnectorType(null);
setViewingAccountsType(null);
setCameFromAccountsList(null);
setStartDate(undefined);
setEndDate(undefined);
setPeriodicEnabled(false);