mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-08 22:22:17 +02:00
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.
This commit is contained in:
parent
ec617c1c6b
commit
3719037c16
13 changed files with 34 additions and 28 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
|||
<ComposerSuggestionPopoverContent side="bottom">
|
||||
<DocumentMentionPicker
|
||||
ref={pickerRef}
|
||||
workspaceId={workspaceId}
|
||||
searchSpaceId={workspaceId}
|
||||
onSelectionChange={handleSelection}
|
||||
onDone={closePopover}
|
||||
initialSelectedDocuments={mentions}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export function DeleteAutomationDialog({
|
|||
async function handleConfirm() {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
await deleteAutomation({ automationId, workspaceId });
|
||||
await deleteAutomation({ automationId, searchSpaceId: workspaceId });
|
||||
onDeleted?.();
|
||||
onOpenChange(false);
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ export default function NewChatPage() {
|
|||
error,
|
||||
flow,
|
||||
context: {
|
||||
workspaceId,
|
||||
searchSpaceId: workspaceId,
|
||||
threadId,
|
||||
},
|
||||
});
|
||||
|
|
@ -754,8 +754,8 @@ export default function NewChatPage() {
|
|||
syncChatTab({
|
||||
chatId: thread.id,
|
||||
title: thread.title,
|
||||
chatUrl: `/dashboard/${thread.workspace_id ?? workspaceId}/new-chat/${thread.id}`,
|
||||
workspaceId: thread.workspace_id ?? workspaceId,
|
||||
chatUrl: `/dashboard/${thread.search_space_id ?? workspaceId}/new-chat/${thread.id}`,
|
||||
searchSpaceId: thread.search_space_id ?? workspaceId,
|
||||
visibility: thread.visibility,
|
||||
hasComments: thread.has_comments ?? false,
|
||||
});
|
||||
|
|
@ -892,7 +892,7 @@ export default function NewChatPage() {
|
|||
}
|
||||
setCurrentThreadMetadata({
|
||||
id: null,
|
||||
workspaceId: null,
|
||||
searchSpaceId: null,
|
||||
visibility: null,
|
||||
hasComments: false,
|
||||
});
|
||||
|
|
@ -906,7 +906,7 @@ export default function NewChatPage() {
|
|||
|
||||
setCurrentThreadMetadata({
|
||||
id: currentThread.id,
|
||||
workspaceId: currentThread.workspace_id ?? workspaceId,
|
||||
searchSpaceId: currentThread.search_space_id ?? workspaceId,
|
||||
visibility,
|
||||
hasComments: currentThread.has_comments ?? false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export function TeamContent({ workspaceId }: TeamContentProps) {
|
|||
const handleRevokeInvite = useCallback(
|
||||
async (inviteId: number): Promise<boolean> => {
|
||||
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<Membership> => {
|
||||
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,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<number | undefined>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ function ApprovalCard({ args, interruptData, onDecision }: ApprovalCardProps) {
|
|||
<div className="px-5 py-4">
|
||||
<p className="mb-3 text-xs font-medium text-foreground">Models</p>
|
||||
<AutomationModelFields
|
||||
searchSpaceId={Number(searchSpaceId)}
|
||||
workspaceId={Number(searchSpaceId)}
|
||||
value={resolvedModels}
|
||||
onChange={(patch) => setModelSelection((prev) => ({ ...prev, ...patch }))}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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<LibraryArtifact | null>(null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue