- ) => {
- setSelectedDataSources((prevSelected) =>
- prevSelected.some((selected) => selected.cc_pair_id === ccPair.cc_pair_id)
- ? prevSelected.filter(
- (selected) => selected.cc_pair_id !== ccPair.cc_pair_id
+ setTempCurrentDataSources(currentDataSources);
+ const updatedGlobalDataSources = ccPairs
+ .filter(
+ (ccPair) =>
+ ccPair.public_doc &&
+ !currentDataSources.some(
+ (dataSource) => dataSource.id === ccPair.cc_pair_id
)
- : [...prevSelected, ccPair]
- );
+ )
+ .map((ccPair) => ({ id: ccPair.cc_pair_id, name: ccPair.name }));
+ setGlobalDataSources(updatedGlobalDataSources);
+ setTempGlobalDataSources(updatedGlobalDataSources);
+ }, [currentDataSources, ccPairs]);
+
+ const handleSelectDataSource = (ccPair: SimplifiedDataSource) => {
+ if (
+ tempCurrentDataSources.some((dataSource) => dataSource.id === ccPair.id)
+ ) {
+ setTempCurrentDataSources((prev) =>
+ prev.filter((dataSource) => dataSource.id !== ccPair.id)
+ );
+ setTempGlobalDataSources((prev) => [...prev, ccPair]);
+ } else {
+ setTempCurrentDataSources((prev) => [...prev, ccPair]);
+ setTempGlobalDataSources((prev) =>
+ prev.filter((dataSource) => dataSource.id !== ccPair.id)
+ );
+ }
};
const handleSaveChanges = async () => {
@@ -162,8 +148,12 @@ export const TeamspaceDataSource = ({
assistant_ids: teamspace.assistants.map(
(assistant) => assistant.id
),
- document_set_ids: teamspace.cc_pairs.map((ccPair) => ccPair.id),
- cc_pair_ids: selectedDataSources.map((ccPair) => ccPair.cc_pair_id),
+ document_set_ids: teamspace.document_sets.map(
+ (docSet) => docSet.id
+ ),
+ cc_pair_ids: tempCurrentDataSources.map(
+ (dataSource) => dataSource.id
+ ),
}),
}
);
@@ -173,29 +163,36 @@ export const TeamspaceDataSource = ({
if (!response.ok) {
toast({
title: "Update Failed",
- description: `Unable to update document sets: ${responseJson.detail || "Unknown error."}`,
+ description: `Unable to update data source: ${responseJson.detail || "Unknown error."}`,
variant: "destructive",
});
return;
- } else {
- toast({
- title: "Data Source Updated",
- description:
- "Data Source have been successfully updated in the teamspace.",
- variant: "success",
- });
- refreshTeamspaces();
- setFilteredGlobalDataSources(
- filterDataSources(ccPairs, searchTermGlobal)
- );
}
+
+ setCurrentDataSources(tempCurrentDataSources);
+ setGlobalDataSources(tempGlobalDataSources);
+ toast({
+ title: "Data Source Updated",
+ description:
+ "Data Source have been successfully updated in the teamspace.",
+ variant: "success",
+ });
+ refreshTeamspaces();
} catch (error) {
toast({
title: "Update Failed",
- description: "An error occurred while updating document sets.",
+ description: "An error occurred while updating data source.",
variant: "destructive",
});
}
+
+ handleCloseModal();
+ };
+
+ const handleCloseModal = () => {
+ setIsDataSourceModalOpen(false);
+ setTempCurrentDataSources(currentDataSources);
+ setTempGlobalDataSources(globalDataSources);
};
return (
@@ -219,7 +216,7 @@ export const TeamspaceDataSource = ({
{teamspace.cc_pairs.slice(0, 8).map((teamspaceDataSource) => (
{teamspaceDataSource.name!.charAt(0)}
@@ -231,44 +228,43 @@ export const TeamspaceDataSource = ({
)}
) : (
- There are no document sets.
+ There are no data sourceg.
)}
}
title="Data Source"
open={isDataSourceModalOpen}
- onClose={() => {
- setIsDataSourceModalOpen(false);
- setSelectedDataSources([]);
- }}
+ onClose={handleCloseModal}
>
- {teamspace.cc_pairs.length > 0 ? (
-
- ) : (
-
There are no current document sets.
- )}
+
+ dataSource.name
+ ?.toLowerCase()
+ .includes(searchTermCurrent.toLowerCase())
+ )}
+ isGlobal={false}
+ onSelect={handleSelectDataSource}
+ hasDataSource={tempCurrentDataSources.length > 0}
+ />
+ dataSource.name
+ ?.toLowerCase()
+ .includes(searchTermGlobal.toLowerCase())
+ )}
+ isGlobal={true}
onSelect={handleSelectDataSource}
- selectedDataSources={selectedDataSources}
+ hasDataSource={tempGlobalDataSources.length > 0}
/>
-
-
+
+
);
diff --git a/web/src/app/ee/admin/teams/TeamspaceDocumentSet.tsx b/web/src/app/ee/admin/teams/TeamspaceDocumentSet.tsx
index 609ccf93857..5f9a6af3181 100644
--- a/web/src/app/ee/admin/teams/TeamspaceDocumentSet.tsx
+++ b/web/src/app/ee/admin/teams/TeamspaceDocumentSet.tsx
@@ -207,21 +207,26 @@ export const TeamspaceDocumentSet = ({
-
- {currentDocumentSets.slice(0, 8).map((documentSet) => (
-
- {documentSet.name!.charAt(0)}
-
- ))}
- {currentDocumentSets.length > 8 && (
-
- +{currentDocumentSets.length - 8}
-
- )}
-
+
+ {teamspace.document_sets.length > 0 ? (
+
+ {currentDocumentSets.slice(0, 8).map((documentSet) => (
+
+ {documentSet.name!.charAt(0)}
+
+ ))}
+ {currentDocumentSets.length > 8 && (
+
+ +{currentDocumentSets.length - 8}
+
+ )}
+
+ ) : (
+ There are no document set.
+ )}
}
title="Document Sets"
diff --git a/web/src/app/ee/admin/teams/TeamspaceSidebar.tsx b/web/src/app/ee/admin/teams/TeamspaceSidebar.tsx
index 086bf51054b..571bc09839c 100644
--- a/web/src/app/ee/admin/teams/TeamspaceSidebar.tsx
+++ b/web/src/app/ee/admin/teams/TeamspaceSidebar.tsx
@@ -12,7 +12,7 @@ interface TeamspaceSidebarProps {
onClose: () => void;
isExpanded: boolean;
assistants: Assistant[];
- ccPairs: ConnectorIndexingStatus[] | undefined;
+ ccPairs: ConnectorIndexingStatus[];
documentSets: DocumentSet[];
refreshTeamspaces: () => void;
}
diff --git a/web/src/app/ee/admin/teams/TeamspaceSidebarContent.tsx b/web/src/app/ee/admin/teams/TeamspaceSidebarContent.tsx
index 03922441c28..b00690541fa 100644
--- a/web/src/app/ee/admin/teams/TeamspaceSidebarContent.tsx
+++ b/web/src/app/ee/admin/teams/TeamspaceSidebarContent.tsx
@@ -12,7 +12,7 @@ interface TeamspaceSidebarContentProps {
teamspace: Teamspace & { gradient: string };
selectedTeamspaceId?: number;
assistants: Assistant[];
- ccPairs: ConnectorIndexingStatus[] | undefined;
+ ccPairs: ConnectorIndexingStatus[];
documentSets: DocumentSet[];
refreshTeamspaces: () => void;
}
diff --git a/web/src/app/ee/admin/teams/TeamspacesCard.tsx b/web/src/app/ee/admin/teams/TeamspacesCard.tsx
index 0565f6543ef..1506f214e12 100644
--- a/web/src/app/ee/admin/teams/TeamspacesCard.tsx
+++ b/web/src/app/ee/admin/teams/TeamspacesCard.tsx
@@ -208,10 +208,7 @@ export const TeamspacesCard = ({
- {" "}
- {tokenRate
- ? `${tokenRate.token_budget} Token Rate`
- : "No Token Rate"}
+ {teamspace.cc_pairs.length} Data Source
diff --git a/web/src/components/Loading.tsx b/web/src/components/Loading.tsx
index 7cdcb5a9887..e3b449fe270 100644
--- a/web/src/components/Loading.tsx
+++ b/web/src/components/Loading.tsx
@@ -44,7 +44,7 @@ export const LoadingAnimation: React.FC = ({
export const ThreeDotsLoader = () => {
return (
-