Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ function CustomDataSettings() {
setIsLoading(true);
axiosPrivate(requestOptions)
.then((res) => {
setAlertDetails({
type: "success",
content: "Custom data saved successfully",
});
setHasChanges(false);
// Update the store with the new details
const updatedDetails = res?.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,10 @@ function CustomSynonyms() {
promptGrammar[item.word] = item.synonyms || [];
});

let successMsg = "";
let failureMsg = "";
if (actionType === actionTypes.save) {
successMsg = "Saved synonyms successfully";
failureMsg = "Failed to save synonyms";
} else {
successMsg = "Deleted synonyms successfully";
failureMsg = "Failed to delete synonyms";
}
const failureMsg =
actionType === actionTypes.save
? "Failed to save synonyms"
: "Failed to delete synonyms";

const body = {
prompt_grammer: promptGrammar,
Expand All @@ -193,10 +188,6 @@ function CustomSynonyms() {
if (actionType === actionTypes.delete) {
setSynonyms(listOfSynonyms);
}
setAlertDetails({
type: "success",
content: successMsg,
});
})
.catch((err) => {
setAlertDetails(handleException(err, failureMsg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ function DocumentParser({
);
modifiedDetails["prompts"] = modifiedPrompts;
updateCustomTool({ details: modifiedDetails });
setAlertDetails({
type: "success",
content: "Deleted successfully",
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to delete"));
Expand Down
119 changes: 67 additions & 52 deletions frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ArrowDownOutlined, PlusOutlined } from "@ant-design/icons";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { Space } from "antd";
import PropTypes from "prop-types";

import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
import { useAlertStore } from "../../../store/alert-store";
Expand All @@ -15,6 +16,38 @@ import { SharePermission } from "../../widgets/share-permission/SharePermission"
import usePostHogEvents from "../../../hooks/usePostHogEvents.js";
import { ImportTool } from "../import-tool/ImportTool";

const DefaultCustomButtons = ({
setOpenImportTool,
isImportLoading,
handleNewProjectBtnClick,
}) => {
return (
<Space gap={16}>
<CustomButton
type="default"
icon={<ArrowDownOutlined />}
onClick={() => setOpenImportTool(true)}
loading={isImportLoading}
>
Import Project
</CustomButton>
<CustomButton
type="primary"
icon={<PlusOutlined />}
onClick={handleNewProjectBtnClick}
>
New Project
</CustomButton>
</Space>
);
};

DefaultCustomButtons.propTypes = {
setOpenImportTool: PropTypes.func.isRequired,
isImportLoading: PropTypes.bool.isRequired,
handleNewProjectBtnClick: PropTypes.func.isRequired,
};

function ListOfTools() {
const [isListLoading, setIsListLoading] = useState(false);
const [openAddTool, setOpenAddTool] = useState(false);
Expand All @@ -23,13 +56,12 @@ function ListOfTools() {
const [editItem, setEditItem] = useState(null);
const { sessionDetails } = useSessionStore();
const { setPostHogCustomEvent } = usePostHogEvents();

const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();

const [listOfTools, setListOfTools] = useState([]);
const [filteredListOfTools, setFilteredListOfTools] = useState([]);
const handleException = useExceptionHandler();
const [isEdit, setIsEdit] = useState(false);
const [promptDetails, setPromptDetails] = useState(null);
const [openSharePermissionModal, setOpenSharePermissionModal] =
Expand Down Expand Up @@ -145,10 +177,6 @@ function ListOfTools() {
(filterToll) => filterToll?.tool_id !== tool.tool_id
);
setListOfTools(tools);
setAlertDetails({
type: "success",
content: `${tool?.tool_name} - Deleted successfully`,
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to Delete"));
Expand Down Expand Up @@ -242,28 +270,6 @@ function ListOfTools() {
});
};

const CustomButtons = () => {
return (
<Space gap={16}>
<CustomButton
type="default"
icon={<ArrowDownOutlined />}
onClick={() => setOpenImportTool(true)}
loading={isImportLoading}
>
Import Project
</CustomButton>
<CustomButton
type="primary"
icon={<PlusOutlined />}
onClick={handleNewProjectBtnClick}
>
New Project
</CustomButton>
</Space>
);
};

const handleShare = (_event, promptProject, isEdit) => {
const requestOptions = {
method: "GET",
Expand Down Expand Up @@ -328,16 +334,42 @@ function ListOfTools() {
axiosPrivate(requestOptions)
.then((response) => {
setOpenSharePermissionModal(false);
setAlertDetails({
type: "success",
content: "Sharing settings updated successfully",
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to load"));
});
};

const defaultContent = (
<div className="list-of-tools-body">
<ViewTools
isLoading={isListLoading}
isEmpty={!listOfTools?.length}
listOfTools={filteredListOfTools}
setOpenAddTool={setOpenAddTool}
handleEdit={handleEdit}
handleDelete={handleDelete}
titleProp="tool_name"
descriptionProp="description"
iconProp="icon"
idProp="tool_id"
type="Prompt Project"
handleShare={handleShare}
/>
</div>
);

const CustomButtonsComponent = useCallback(
() => (
<DefaultCustomButtons
setOpenImportTool={setOpenImportTool}
isImportLoading={isImportLoading}
handleNewProjectBtnClick={handleNewProjectBtnClick}
/>
),
[isImportLoading]
);

return (
<>
<ToolNavBar
Expand All @@ -346,27 +378,10 @@ function ListOfTools() {
onSearch={onSearch}
searchList={listOfTools}
setSearchList={setFilteredListOfTools}
CustomButtons={CustomButtons}
CustomButtons={CustomButtonsComponent}
/>
<div className="list-of-tools-layout">
<div className="list-of-tools-island">
<div className="list-of-tools-body">
<ViewTools
isLoading={isListLoading}
isEmpty={!listOfTools?.length}
listOfTools={filteredListOfTools}
setOpenAddTool={setOpenAddTool}
handleEdit={handleEdit}
handleDelete={handleDelete}
titleProp="tool_name"
descriptionProp="description"
iconProp="icon"
idProp="tool_id"
type="Prompt Project"
handleShare={handleShare}
/>
</div>
</div>
<div className="list-of-tools-island">{defaultContent}</div>
</div>
{openAddTool && (
<AddCustomToolFormModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ function ManageLlmProfiles() {
defaultLlmProfile: data?.default_profile,
};
updateCustomTool(updatedState);
setAlertDetails({
type: "success",
content: "Default LLM Profile updated successfully",
});
})
.catch((err) => {
handleException(err, "Failed to set default LLM Profile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ function PreAndPostAmbleModal({ type, handleUpdateTool }) {
};
const updatedDetails = { ...details, ...updatedData };
updateCustomTool({ details: updatedDetails });
setAlertDetails({
type: "success",
content: "Saved successfully",
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to update."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,7 @@ function ApiDeployment() {
record.is_active = !record?.is_active;
apiDeploymentsApiService
.updateApiDeployment(record)
.then((res) => {
setAlertDetails({
type: "success",
content: "Status updated successfully",
});
})
.then(() => {})
.catch((err) => {
setAlertDetails(handleException(err));
})
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/components/input-output/configure-ds/ConfigureDs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ function ConfigureDs({
type: "error",
content: "Test connection failed",
});
} else {
setAlertDetails({
type: "success",
content: "Test connection successful",
});
}
})
.catch((err) => {
Expand Down Expand Up @@ -323,12 +318,6 @@ function ConfigureDs({
if (data) {
addNewItem(data, !!editItemId);
}
setAlertDetails({
type: "success",
content: `Successfully ${
method === "POST" ? "added" : "updated"
} connector`,
});
if (!isConnector && method === "POST") {
updateSession(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ const FileHistoryModal = ({ open, setOpen, workflowId, workflowName }) => {
const handleDeleteSingle = async (fileHistoryId) => {
try {
await workflowApiService.deleteFileHistory(workflowId, fileHistoryId);
setAlertDetails({
type: "success",
message: "File history deleted successfully",
});
// Refresh data
fetchFileHistories(pagination.current, pagination.pageSize);
setSelectedRowKeys([]);
Expand All @@ -262,18 +258,11 @@ const FileHistoryModal = ({ open, setOpen, workflowId, workflowName }) => {

setLoading(true);
try {
const response = await workflowApiService.bulkDeleteFileHistoriesByIds(
await workflowApiService.bulkDeleteFileHistoriesByIds(
workflowId,
selectedRowKeys
);

setAlertDetails({
type: "success",
message:
response?.data?.message ||
`${selectedRowKeys.length} file histories deleted successfully`,
});

// Refresh data
fetchFileHistories(pagination.current, pagination.pageSize);
setSelectedRowKeys([]);
Expand Down Expand Up @@ -358,17 +347,7 @@ const FileHistoryModal = ({ open, setOpen, workflowId, workflowName }) => {
filters.file_path = appliedFilters.filePath;
}

const response = await workflowApiService.bulkClearFileHistories(
workflowId,
filters
);

setAlertDetails({
type: "success",
message:
response?.data?.message ||
`${response?.data?.deleted_count} file histories cleared`,
});
await workflowApiService.bulkClearFileHistories(workflowId, filters);

// Refresh data
fetchFileHistories(1, pagination.pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ function Pipelines({ type }) {
const data = res?.data?.pipeline;
fieldsToUpdate.last_run_status = data?.last_run_status;
fieldsToUpdate.last_run_time = data?.last_run_time;
setAlertDetails({
type: "success",
content: "Pipeline Sync Initiated",
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to sync."));
Expand Down Expand Up @@ -232,12 +228,6 @@ function Pipelines({ type }) {
axiosPrivate(requestOptions)
.then(() => {
getPipelineList();
setAlertDetails({
type: "success",
content: value
? "Pipeline Enabled Successfully"
: "Pipeline Disabled Successfully",
});
})
.catch((err) => {
setAlertDetails(handleException(err));
Expand Down Expand Up @@ -284,10 +274,7 @@ function Pipelines({ type }) {

const clearFileMarkers = async () => {
const workflowId = selectedPorD?.workflow_id;
const success = await clearFileHistory(
workflowId,
"Pipeline File History Cleared Successfully"
);
const success = await clearFileHistory(workflowId);
if (success && openDeleteModal) {
setOpenDeleteModal(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ function DefaultTriad() {
};
axiosPrivate(requestOptions)
.then((res) => {
setAlertDetails({
type: "success",
content: "Default triad setting saved successfully",
});
fetchData();
setIsSubmitEnabled(false);
})
Expand Down
Loading