From 07f42270a5dc524f23795f54804a28f990f7ed2b Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 13 Aug 2025 21:15:07 +0200 Subject: [PATCH 1/4] add connector name enum --- surfsense_web/contracts/enums/connector.ts | 15 +++++++++++++++ surfsense_web/contracts/interfaces/.gitkeep | 0 surfsense_web/contracts/types/.gitkeep | 0 3 files changed, 15 insertions(+) create mode 100644 surfsense_web/contracts/enums/connector.ts create mode 100644 surfsense_web/contracts/interfaces/.gitkeep create mode 100644 surfsense_web/contracts/types/.gitkeep diff --git a/surfsense_web/contracts/enums/connector.ts b/surfsense_web/contracts/enums/connector.ts new file mode 100644 index 0000000..2b58c6a --- /dev/null +++ b/surfsense_web/contracts/enums/connector.ts @@ -0,0 +1,15 @@ +export enum EnumConnectorName { + SERPER_API = "SERPER_API", + TAVILY_API = "TAVILY_API", + LINKUP_API = "LINKUP_API", + SLACK_CONNECTOR = "SLACK_CONNECTOR", + NOTION_CONNECTOR = "NOTION_CONNECTOR", + GITHUB_CONNECTOR = "GITHUB_CONNECTOR", + LINEAR_CONNECTOR = "LINEAR_CONNECTOR", + JIRA_CONNECTOR = "JIRA_CONNECTOR", + DISCORD_CONNECTOR = "DISCORD_CONNECTOR", + CONFLUENCE_CONNECTOR = "CONFLUENCE_CONNECTOR", + CLICKUP_CONNECTOR = "CLICKUP_CONNECTOR", + GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR", + GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR", +} diff --git a/surfsense_web/contracts/interfaces/.gitkeep b/surfsense_web/contracts/interfaces/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/surfsense_web/contracts/types/.gitkeep b/surfsense_web/contracts/types/.gitkeep new file mode 100644 index 0000000..e69de29 From d70ebf96698ca06b83863ccd167be246c5ffbba6 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 13 Aug 2025 21:17:16 +0200 Subject: [PATCH 2/4] allow future events indexing for google calendar connector --- .../connectors/(manage)/page.tsx | 32 +++++++++++++++---- surfsense_web/lib/connectors/utils.ts | 4 +++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/connectors/(manage)/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/connectors/(manage)/page.tsx index 8afe07b..244bc7d 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/connectors/(manage)/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/connectors/(manage)/page.tsx @@ -40,6 +40,7 @@ import { TableRow, } from "@/components/ui/table"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; +import { EnumConnectorName } from "@/contracts/enums/connector"; import { useSearchSourceConnectors } from "@/hooks/useSearchSourceConnectors"; import { cn } from "@/lib/utils"; @@ -61,6 +62,7 @@ export default function ConnectorsPage() { const router = useRouter(); const params = useParams(); const searchSpaceId = params.search_space_id as string; + const today = new Date(); const { connectors, isLoading, error, deleteConnector, indexConnector } = useSearchSourceConnectors(); @@ -139,6 +141,28 @@ export default function ConnectorsPage() { } }; + const getDisabledEndDates = (date: Date) => { + const connector = connectors.find((c) => c.id === selectedConnectorForIndexing); + + switch (connector?.connector_type) { + case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR: + return startDate ? date < startDate : false; + default: + return date > today || (startDate ? date < startDate : false); + } + }; + + const getDisabledStartDates = (date: Date) => { + const connector = connectors.find((c) => c.id === selectedConnectorForIndexing); + + switch (connector?.connector_type) { + case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR: + return endDate ? date > endDate : false; + default: + return date > today || (endDate ? date > endDate : false); + } + }; + return (
date > new Date() || (endDate ? date > endDate : false)} + disabled={getDisabledStartDates} initialFocus /> @@ -369,9 +393,7 @@ export default function ConnectorsPage() { mode="single" selected={endDate} onSelect={setEndDate} - disabled={(date) => - date > new Date() || (startDate ? date < startDate : false) - } + disabled={getDisabledEndDates} initialFocus /> @@ -393,7 +415,6 @@ export default function ConnectorsPage() { variant="outline" size="sm" onClick={() => { - const today = new Date(); const thirtyDaysAgo = new Date(today); thirtyDaysAgo.setDate(today.getDate() - 30); setStartDate(thirtyDaysAgo); @@ -406,7 +427,6 @@ export default function ConnectorsPage() { variant="outline" size="sm" onClick={() => { - const today = new Date(); const yearAgo = new Date(today); yearAgo.setFullYear(today.getFullYear() - 1); setStartDate(yearAgo); diff --git a/surfsense_web/lib/connectors/utils.ts b/surfsense_web/lib/connectors/utils.ts index 848c903..e01d31e 100644 --- a/surfsense_web/lib/connectors/utils.ts +++ b/surfsense_web/lib/connectors/utils.ts @@ -10,6 +10,10 @@ export const getConnectorTypeDisplay = (type: string): string => { JIRA_CONNECTOR: "Jira", DISCORD_CONNECTOR: "Discord", LINKUP_API: "Linkup", + CONFLUENCE_CONNECTOR: "Confluence", + CLICKUP_CONNECTOR: "ClickUp", + GOOGLE_CALENDAR_CONNECTOR: "Google Calendar", + GOOGLE_GMAIL_CONNECTOR: "Google Gmail", }; return typeMap[type] || type; }; From 24dff5f8754927e2c40756e4cf3deef68af08400 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 13 Aug 2025 21:18:33 +0200 Subject: [PATCH 3/4] fix linkup enum migration file --- .../alembic/versions/4_add_linkup_api_enum.py | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/surfsense_backend/alembic/versions/4_add_linkup_api_enum.py b/surfsense_backend/alembic/versions/4_add_linkup_api_enum.py index 26acec3..e11c89c 100644 --- a/surfsense_backend/alembic/versions/4_add_linkup_api_enum.py +++ b/surfsense_backend/alembic/versions/4_add_linkup_api_enum.py @@ -2,7 +2,7 @@ Revision ID: 4 Revises: 3 - +Create Date: 2025-08-13 """ from collections.abc import Sequence @@ -17,31 +17,29 @@ depends_on: str | Sequence[str] | None = None def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - - # Manually add the command to add the enum value - op.execute("ALTER TYPE searchsourceconnectortype ADD VALUE 'LINKUP_API'") - - # Pass for the rest, as autogenerate didn't run to add other schema details - pass - # ### end Alembic commands ### + # Add enum value only if it doesn't already exist. + # Postgres will no-op with a NOTICE when the value is present. + op.execute( + "ALTER TYPE searchsourceconnectortype ADD VALUE IF NOT EXISTS 'LINKUP_API'" + ) def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - - # Downgrading removal of an enum value requires recreating the type + # To "remove" an enum value in Postgres, we must recreate the type + # without that value, migrate the column, then drop the old type. op.execute( "ALTER TYPE searchsourceconnectortype RENAME TO searchsourceconnectortype_old" ) op.execute( - "CREATE TYPE searchsourceconnectortype AS ENUM('SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', 'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR')" + "CREATE TYPE searchsourceconnectortype AS ENUM(" + "'SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', " + "'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR'" + ")" ) op.execute( - "ALTER TABLE search_source_connectors ALTER COLUMN connector_type TYPE searchsourceconnectortype USING " - "connector_type::text::searchsourceconnectortype" + "ALTER TABLE search_source_connectors " + "ALTER COLUMN connector_type " + "TYPE searchsourceconnectortype " + "USING connector_type::text::searchsourceconnectortype" ) op.execute("DROP TYPE searchsourceconnectortype_old") - - pass - # ### end Alembic commands ### From 4e37a92f640e93d45e05c792e2c0b0ba794ccb13 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Sun, 17 Aug 2025 23:43:10 +0200 Subject: [PATCH 4/4] remove empty folders --- surfsense_web/contracts/interfaces/.gitkeep | 0 surfsense_web/contracts/types/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 surfsense_web/contracts/interfaces/.gitkeep delete mode 100644 surfsense_web/contracts/types/.gitkeep diff --git a/surfsense_web/contracts/interfaces/.gitkeep b/surfsense_web/contracts/interfaces/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surfsense_web/contracts/types/.gitkeep b/surfsense_web/contracts/types/.gitkeep deleted file mode 100644 index e69de29..0000000