mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-17 21:32:36 +01:00
Improve document set page UX
This commit is contained in:
parent
05bc6b1c65
commit
7928ea2fff
@ -283,6 +283,10 @@ class ConnectorCredentialPair(Base):
|
||||
document_sets: Mapped[list["DocumentSet"]] = relationship(
|
||||
"DocumentSet",
|
||||
secondary=DocumentSet__ConnectorCredentialPair.__table__,
|
||||
primaryjoin=(
|
||||
(DocumentSet__ConnectorCredentialPair.connector_credential_pair_id == id)
|
||||
& (DocumentSet__ConnectorCredentialPair.is_current.is_(True))
|
||||
),
|
||||
back_populates="connector_credential_pairs",
|
||||
overlaps="document_set",
|
||||
)
|
||||
@ -825,6 +829,14 @@ class DocumentSet(Base):
|
||||
connector_credential_pairs: Mapped[list[ConnectorCredentialPair]] = relationship(
|
||||
"ConnectorCredentialPair",
|
||||
secondary=DocumentSet__ConnectorCredentialPair.__table__,
|
||||
primaryjoin=(
|
||||
(DocumentSet__ConnectorCredentialPair.document_set_id == id)
|
||||
& (DocumentSet__ConnectorCredentialPair.is_current.is_(True))
|
||||
),
|
||||
secondaryjoin=(
|
||||
DocumentSet__ConnectorCredentialPair.connector_credential_pair_id
|
||||
== ConnectorCredentialPair.id
|
||||
),
|
||||
back_populates="document_sets",
|
||||
overlaps="document_set",
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { ErrorCallout } from "@/components/ErrorCallout";
|
||||
import { useDocumentSets } from "../hooks";
|
||||
import { refreshDocumentSets, useDocumentSets } from "../hooks";
|
||||
import {
|
||||
useConnectorCredentialIndexingStatus,
|
||||
useUserGroups,
|
||||
@ -82,7 +82,8 @@ function Main({ documentSetId }: { documentSetId: number }) {
|
||||
ccPairs={ccPairs}
|
||||
userGroups={userGroups}
|
||||
onClose={() => {
|
||||
router.push(`/admin/documents/sets?u=${Date.now()}`);
|
||||
refreshDocumentSets();
|
||||
router.push("/admin/documents/sets");
|
||||
}}
|
||||
setPopup={setPopup}
|
||||
existingDocumentSet={documentSet}
|
||||
|
@ -2,14 +2,23 @@ import { errorHandlingFetcher } from "@/lib/fetcher";
|
||||
import { DocumentSet } from "@/lib/types";
|
||||
import useSWR, { mutate } from "swr";
|
||||
|
||||
const DOCUMENT_SETS_URL = "/api/manage/admin/document-set";
|
||||
|
||||
export function refreshDocumentSets() {
|
||||
mutate(DOCUMENT_SETS_URL);
|
||||
}
|
||||
|
||||
export function useDocumentSets() {
|
||||
const url = "/api/manage/admin/document-set";
|
||||
const swrResponse = useSWR<DocumentSet[]>(url, errorHandlingFetcher, {
|
||||
refreshInterval: 5000, // 5 seconds
|
||||
});
|
||||
const swrResponse = useSWR<DocumentSet[]>(
|
||||
DOCUMENT_SETS_URL,
|
||||
errorHandlingFetcher,
|
||||
{
|
||||
refreshInterval: 5000, // 5 seconds
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
...swrResponse,
|
||||
refreshDocumentSets: () => mutate(url),
|
||||
refreshDocumentSets: refreshDocumentSets,
|
||||
};
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import { BackButton } from "@/components/BackButton";
|
||||
import { ErrorCallout } from "@/components/ErrorCallout";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { UserGroup } from "@/lib/types";
|
||||
import { refreshDocumentSets } from "../hooks";
|
||||
|
||||
function Main() {
|
||||
const { popup, setPopup } = usePopup();
|
||||
@ -50,7 +51,8 @@ function Main() {
|
||||
ccPairs={ccPairs}
|
||||
userGroups={userGroups}
|
||||
onClose={() => {
|
||||
router.push(`/admin/documents/sets?u=${Date.now()}`);
|
||||
refreshDocumentSets();
|
||||
router.push("/admin/documents/sets");
|
||||
}}
|
||||
setPopup={setPopup}
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user