diff --git a/backend/danswer/db/document_set.py b/backend/danswer/db/document_set.py index 3cc7646fa..29227fbcb 100644 --- a/backend/danswer/db/document_set.py +++ b/backend/danswer/db/document_set.py @@ -468,26 +468,6 @@ def fetch_all_document_sets_for_user( return db_session.scalars(stmt).all() -def fetch_user_document_sets( - user_id: UUID | None, db_session: Session -) -> list[tuple[DocumentSetDBModel, list[ConnectorCredentialPair]]]: - # If Auth is turned off, all document sets become visible - # document sets are not permission enforced, only for organizational purposes - # the documents themselves are permission enforced - if user_id is None: - return fetch_document_sets( - user_id=user_id, db_session=db_session, include_outdated=True - ) - - versioned_fetch_doc_sets_fn = fetch_versioned_implementation( - "danswer.db.document_set", "fetch_document_sets" - ) - - return versioned_fetch_doc_sets_fn( - user_id=user_id, db_session=db_session, include_outdated=True - ) - - def fetch_documents_for_document_set_paginated( document_set_id: int, db_session: Session, diff --git a/backend/danswer/server/features/document_set/api.py b/backend/danswer/server/features/document_set/api.py index b3f01fb0a..d1eff0828 100644 --- a/backend/danswer/server/features/document_set/api.py +++ b/backend/danswer/server/features/document_set/api.py @@ -9,16 +9,12 @@ from danswer.auth.users import current_user from danswer.auth.users import validate_curator_request from danswer.db.document_set import check_document_sets_are_public from danswer.db.document_set import fetch_all_document_sets_for_user -from danswer.db.document_set import fetch_user_document_sets from danswer.db.document_set import insert_document_set from danswer.db.document_set import mark_document_set_as_to_be_deleted from danswer.db.document_set import update_document_set from danswer.db.engine import get_session from danswer.db.models import User from danswer.db.models import UserRole -from danswer.server.documents.models import ConnectorCredentialPairDescriptor -from danswer.server.documents.models import ConnectorSnapshot -from danswer.server.documents.models import CredentialSnapshot from danswer.server.features.document_set.models import CheckDocSetPublicRequest from danswer.server.features.document_set.models import CheckDocSetPublicResponse from danswer.server.features.document_set.models import DocumentSet @@ -88,9 +84,12 @@ def delete_document_set( raise HTTPException(status_code=400, detail=str(e)) -@router.get("/admin/document-set") -def list_document_sets_admin( - user: User | None = Depends(current_curator_or_admin_user), +"""Endpoints for non-admins""" + + +@router.get("/document-set") +def list_document_sets_for_user( + user: User | None = Depends(current_user), db_session: Session = Depends(get_session), get_editable: bool = Query( False, description="If true, return editable document sets" @@ -104,45 +103,6 @@ def list_document_sets_admin( ] -"""Endpoints for non-admins""" - - -@router.get("/document-set") -def list_document_sets( - user: User | None = Depends(current_user), - db_session: Session = Depends(get_session), -) -> list[DocumentSet]: - document_set_info = fetch_user_document_sets( - user_id=user.id if user else None, db_session=db_session - ) - return [ - DocumentSet( - id=document_set_db_model.id, - name=document_set_db_model.name, - description=document_set_db_model.description, - contains_non_public=any([not cc_pair.is_public for cc_pair in cc_pairs]), - cc_pair_descriptors=[ - ConnectorCredentialPairDescriptor( - id=cc_pair.id, - name=cc_pair.name, - connector=ConnectorSnapshot.from_connector_db_model( - cc_pair.connector - ), - credential=CredentialSnapshot.from_credential_db_model( - cc_pair.credential - ), - ) - for cc_pair in cc_pairs - ], - is_up_to_date=document_set_db_model.is_up_to_date, - is_public=document_set_db_model.is_public, - users=[user.id for user in document_set_db_model.users], - groups=[group.id for group in document_set_db_model.groups], - ) - for document_set_db_model, cc_pairs in document_set_info - ] - - @router.get("/document-set-public") def document_set_public( check_public_request: CheckDocSetPublicRequest, diff --git a/backend/tests/integration/common_utils/document_sets.py b/backend/tests/integration/common_utils/document_sets.py index 9b250afb7..9805107be 100644 --- a/backend/tests/integration/common_utils/document_sets.py +++ b/backend/tests/integration/common_utils/document_sets.py @@ -21,7 +21,7 @@ class DocumentSetClient: @staticmethod def fetch_document_sets() -> list[DocumentSet]: - response = requests.get(f"{API_SERVER_URL}/manage/admin/document-set") + response = requests.get(f"{API_SERVER_URL}/manage/document-set") response.raise_for_status() document_sets = [ diff --git a/web/src/app/admin/documents/sets/hooks.tsx b/web/src/app/admin/documents/sets/hooks.tsx index 4e0c2acbf..1362cfda2 100644 --- a/web/src/app/admin/documents/sets/hooks.tsx +++ b/web/src/app/admin/documents/sets/hooks.tsx @@ -2,9 +2,9 @@ import { errorHandlingFetcher } from "@/lib/fetcher"; import { DocumentSet } from "@/lib/types"; import useSWR, { mutate } from "swr"; -const DOCUMENT_SETS_URL = "/api/manage/admin/document-set"; +const DOCUMENT_SETS_URL = "/api/manage/document-set"; const GET_EDITABLE_DOCUMENT_SETS_URL = - "/api/manage/admin/document-set?get_editable=true"; + "/api/manage/document-set?get_editable=true"; export function refreshDocumentSets() { mutate(DOCUMENT_SETS_URL); diff --git a/web/src/lib/assistants/fetchPersonaEditorInfoSS.ts b/web/src/lib/assistants/fetchPersonaEditorInfoSS.ts index 4f424a70e..f779b2ed6 100644 --- a/web/src/lib/assistants/fetchPersonaEditorInfoSS.ts +++ b/web/src/lib/assistants/fetchPersonaEditorInfoSS.ts @@ -5,7 +5,6 @@ import { fetchSS } from "../utilsSS"; import { FullLLMProvider } from "@/app/admin/configuration/llm/interfaces"; import { ToolSnapshot } from "../tools/interfaces"; import { fetchToolsSS } from "../tools/fetchTools"; -import { IconManifestType } from "react-icons/lib"; import { OpenAIIcon, AnthropicIcon,