From 3719037c160a0ef1107130db7d66f358c42b7a44 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 6 Jul 2026 10:16:21 +0530 Subject: [PATCH] refactor(workspace): standardize component props to use workspaceId - Updated component props across multiple files to replace searchSpaceId with workspaceId for consistency. - Adjusted internal logic to maintain functionality while aligning with the new terminology. --- .../components/builder/automation-builder-form.tsx | 5 +---- .../components/builder/mention-task-input.tsx | 5 ++++- .../components/delete-automation-dialog.tsx | 2 +- .../[workspace_id]/new-chat/[[...chat_id]]/page.tsx | 10 +++++----- .../dashboard/[workspace_id]/team/team-content.tsx | 12 ++++++------ surfsense_web/atoms/members/members-query.atoms.ts | 3 ++- .../public-chat-snapshots-manager.tsx | 4 ++-- .../components/settings/general-settings-manager.tsx | 5 +++-- .../settings/model-connections-settings.tsx | 3 ++- .../components/settings/prompt-config-manager.tsx | 5 +++-- surfsense_web/components/settings/roles-manager.tsx | 3 ++- .../tool-ui/automation/create-automation.tsx | 2 +- .../artifacts-library/ui/artifacts-library.tsx | 3 ++- 13 files changed, 34 insertions(+), 28 deletions(-) diff --git a/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/automation-builder-form.tsx b/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/automation-builder-form.tsx index e6fb96605..7d24c20e7 100644 --- a/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/automation-builder-form.tsx +++ b/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/automation-builder-form.tsx @@ -156,10 +156,7 @@ export function AutomationBuilderForm({ if (mode === "edit" && automation) { return { ...buildUpdatePayload(formForPayload), status: automation.status }; } - const { workspace_id: _ignored, ...rest } = buildCreatePayload( - formForPayload, - workspaceId - ); + const { search_space_id: _ignored, ...rest } = buildCreatePayload(formForPayload, workspaceId); return rest; } diff --git a/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/mention-task-input.tsx b/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/mention-task-input.tsx index 614cfd7eb..1814af6b7 100644 --- a/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/mention-task-input.tsx +++ b/surfsense_web/app/dashboard/[workspace_id]/automations/components/builder/mention-task-input.tsx @@ -73,6 +73,9 @@ function toChipInput(mention: MentionedDocumentInfo): MentionChipInput { if (mention.kind === "folder") { return { id: mention.id, title: mention.title, kind: "folder" }; } + if (mention.kind === "thread") { + return { id: mention.id, title: mention.title, kind: "thread" }; + } return { id: mention.id, title: mention.title, @@ -232,7 +235,7 @@ export function MentionTaskInput({ => { const request: DeleteInviteRequest = { - workspace_id: workspaceId, + search_space_id: workspaceId, invite_id: inviteId, }; await revokeInvite(request); @@ -151,7 +151,7 @@ export function TeamContent({ workspaceId }: TeamContentProps) { const handleCreateInvite = useCallback( async (inviteData: CreateInviteRequest["data"]) => { const request: CreateInviteRequest = { - workspace_id: workspaceId, + search_space_id: workspaceId, data: inviteData, }; return await createInvite(request); @@ -162,7 +162,7 @@ export function TeamContent({ workspaceId }: TeamContentProps) { const handleUpdateMember = useCallback( async (membershipId: number, roleId: number | null): Promise => { const request: UpdateMembershipRequest = { - workspace_id: workspaceId, + search_space_id: workspaceId, membership_id: membershipId, data: { role_id: roleId }, }; @@ -174,7 +174,7 @@ export function TeamContent({ workspaceId }: TeamContentProps) { const handleRemoveMember = useCallback( async (membershipId: number) => { const request: DeleteMembershipRequest = { - workspace_id: workspaceId, + search_space_id: workspaceId, membership_id: membershipId, }; await deleteMember(request); @@ -185,13 +185,13 @@ export function TeamContent({ workspaceId }: TeamContentProps) { const { data: roles = [], isLoading: rolesLoading } = useQuery({ queryKey: cacheKeys.roles.all(workspaceId.toString()), - queryFn: () => rolesApiService.getRoles({ workspace_id: workspaceId }), + queryFn: () => rolesApiService.getRoles({ search_space_id: workspaceId }), enabled: !!workspaceId, }); const { data: invites = [], isLoading: invitesLoading } = useQuery({ queryKey: cacheKeys.invites.all(workspaceId.toString()), - queryFn: () => invitesApiService.getInvites({ workspace_id: workspaceId }), + queryFn: () => invitesApiService.getInvites({ search_space_id: workspaceId }), staleTime: 5 * 60 * 1000, }); diff --git a/surfsense_web/atoms/members/members-query.atoms.ts b/surfsense_web/atoms/members/members-query.atoms.ts index c1f507ff5..65ea4671d 100644 --- a/surfsense_web/atoms/members/members-query.atoms.ts +++ b/surfsense_web/atoms/members/members-query.atoms.ts @@ -1,3 +1,4 @@ +import { useAtomValue } from "jotai"; import { atomWithQuery } from "jotai-tanstack-query"; import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms"; import { membersApiService } from "@/lib/apis/members-api.service"; @@ -71,6 +72,6 @@ export function canPerform( * const canManageMembers = usePermissionGate('manage_members'); */ export function usePermissionGate(permission: string): boolean { - const access = useAtomValue(myAccessAtom); + const { data: access } = useAtomValue(myAccessAtom); return canPerform(access, permission); } diff --git a/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-manager.tsx b/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-manager.tsx index 2e759accb..5a53a8d87 100644 --- a/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-manager.tsx +++ b/surfsense_web/components/public-chat-snapshots/public-chat-snapshots-manager.tsx @@ -14,11 +14,11 @@ import type { PublicChatSnapshotDetail } from "@/contracts/types/chat-threads.ty import { PublicChatSnapshotsList } from "./public-chat-snapshots-list"; interface PublicChatSnapshotsManagerProps { - searchSpaceId: number; + workspaceId: number; } export function PublicChatSnapshotsManager({ - searchSpaceId: _searchSpaceId, + workspaceId: _workspaceId, }: PublicChatSnapshotsManagerProps) { const [deletingId, setDeletingId] = useState(); diff --git a/surfsense_web/components/settings/general-settings-manager.tsx b/surfsense_web/components/settings/general-settings-manager.tsx index d0c08d881..1f463147f 100644 --- a/surfsense_web/components/settings/general-settings-manager.tsx +++ b/surfsense_web/components/settings/general-settings-manager.tsx @@ -21,10 +21,11 @@ import { cacheKeys } from "@/lib/query-client/cache-keys"; import { Spinner } from "../ui/spinner"; interface GeneralSettingsManagerProps { - searchSpaceId: number; + workspaceId: number; } -export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManagerProps) { +export function GeneralSettingsManager({ workspaceId }: GeneralSettingsManagerProps) { + const searchSpaceId = workspaceId; const t = useTranslations("searchSpaceSettings"); const tCommon = useTranslations("common"); const { diff --git a/surfsense_web/components/settings/model-connections-settings.tsx b/surfsense_web/components/settings/model-connections-settings.tsx index 3b30b1558..dc4b19a1a 100644 --- a/surfsense_web/components/settings/model-connections-settings.tsx +++ b/surfsense_web/components/settings/model-connections-settings.tsx @@ -50,7 +50,8 @@ function renderAutoModeOption() { ); } -export function ModelConnectionsSettings({ searchSpaceId }: { searchSpaceId: number }) { +export function ModelConnectionsSettings({ workspaceId }: { workspaceId: number }) { + const searchSpaceId = workspaceId; const [{ data: globalConnections = [] }] = useAtom(globalModelConnectionsAtom); const [{ data: connections = [] }] = useAtom(modelConnectionsAtom); const [{ data: roles }] = useAtom(modelRolesAtom); diff --git a/surfsense_web/components/settings/prompt-config-manager.tsx b/surfsense_web/components/settings/prompt-config-manager.tsx index 997749a2a..132abf8a0 100644 --- a/surfsense_web/components/settings/prompt-config-manager.tsx +++ b/surfsense_web/components/settings/prompt-config-manager.tsx @@ -16,10 +16,11 @@ import { cacheKeys } from "@/lib/query-client/cache-keys"; import { Spinner } from "../ui/spinner"; interface PromptConfigManagerProps { - searchSpaceId: number; + workspaceId: number; } -export function PromptConfigManager({ searchSpaceId }: PromptConfigManagerProps) { +export function PromptConfigManager({ workspaceId }: PromptConfigManagerProps) { + const searchSpaceId = workspaceId; const { data: searchSpace, isLoading: loading } = useQuery({ queryKey: cacheKeys.searchSpaces.detail(searchSpaceId.toString()), queryFn: () => searchSpacesApiService.getSearchSpace({ id: searchSpaceId }), diff --git a/surfsense_web/components/settings/roles-manager.tsx b/surfsense_web/components/settings/roles-manager.tsx index 5c034470d..43a4dc658 100644 --- a/surfsense_web/components/settings/roles-manager.tsx +++ b/surfsense_web/components/settings/roles-manager.tsx @@ -269,7 +269,8 @@ type PermissionWithDescription = PermissionInfo; // ============ Roles Manager (for Settings page) ============ -export function RolesManager({ searchSpaceId }: { searchSpaceId: number }) { +export function RolesManager({ workspaceId }: { workspaceId: number }) { + const searchSpaceId = workspaceId; const { data: access = null } = useAtomValue(myAccessAtom); const hasPermission = useCallback( diff --git a/surfsense_web/components/tool-ui/automation/create-automation.tsx b/surfsense_web/components/tool-ui/automation/create-automation.tsx index 92607beed..41c2419ff 100644 --- a/surfsense_web/components/tool-ui/automation/create-automation.tsx +++ b/surfsense_web/components/tool-ui/automation/create-automation.tsx @@ -284,7 +284,7 @@ function ApprovalCard({ args, interruptData, onDecision }: ApprovalCardProps) {

Models

setModelSelection((prev) => ({ ...prev, ...patch }))} /> diff --git a/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx b/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx index 3441f626e..2e264c8f5 100644 --- a/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx +++ b/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx @@ -60,7 +60,8 @@ function EmptyState() { ); } -export function ArtifactsLibrary({ searchSpaceId }: { searchSpaceId: number }) { +export function ArtifactsLibrary({ workspaceId }: { workspaceId: number }) { + const searchSpaceId = workspaceId; const { artifacts, loading, error, refresh } = useLibraryArtifacts(searchSpaceId); const openReportPanel = useSetAtom(openReportPanelAtom); const [selectedMedia, setSelectedMedia] = useState(null);