Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[FIX] Add generic title+subtitle+edit pattern to ToolNavBar (#1882)

Chandrasekharan Me689eab8e910
diff --git a/frontend/src/components/custom-tools/header/Header.css b/frontend/src/components/custom-tools/header/Header.css
index e0f9e06f0..c94aef156 100644
--- a/frontend/src/components/custom-tools/header/Header.css
+++ b/frontend/src/components/custom-tools/header/Header.css
@@ -1,12 +1,5 @@
/* Styles for Header */
-.custom-tools-header-layout {
- padding: 8px;
- background-color: #f5f7f9;
- display: flex;
- align-items: center;
-}
-
.custom-tools-header-btns {
display: flex;
justify-content: space-between;
@@ -17,14 +10,6 @@
padding: 0px 5px;
}
-.custom-tools-name {
- padding: 0px 8px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- font-size: 16px;
-}
-
.custom-tools-header-v-divider {
border-right: 1px #d9d9d9 solid;
padding: 0;
diff --git a/frontend/src/components/custom-tools/header/Header.jsx b/frontend/src/components/custom-tools/header/Header.jsx
index 84718ee87..a514bd76b 100644
--- a/frontend/src/components/custom-tools/header/Header.jsx
+++ b/frontend/src/components/custom-tools/header/Header.jsx
@@ -1,7 +1,7 @@
import { SettingOutlined } from "@ant-design/icons";
-import { Button, Dropdown, Modal, Tooltip, Typography } from "antd";
+import { Button, Dropdown, Form, Input, Modal, Tooltip } from "antd";
import PropTypes from "prop-types";
-import { useCallback, useState } from "react";
+import { useCallback, useMemo, useState } from "react";
import { ExportToolIcon } from "../../../assets";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
@@ -10,9 +10,9 @@ import { useAlertStore } from "../../../store/alert-store";
import { useCustomToolStore } from "../../../store/custom-tool-store";
import { useSessionStore } from "../../../store/session-store";
import { CreateApiDeploymentFromPromptStudio } from "../../deployments/create-api-deployment-from-prompt-studio/CreateApiDeploymentFromPromptStudio.jsx";
+import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
import { CustomButton } from "../../widgets/custom-button/CustomButton";
import { ExportTool } from "../export-tool/ExportTool";
-import { HeaderTitle } from "../header-title/HeaderTitle.jsx";
import "./Header.css";
let SinglePassToggleSwitch;
@@ -70,6 +70,8 @@ function Header({
] = useState(false);
const [existingApiDeployments, setExistingApiDeployments] = useState([]);
const [isApiDeploymentLoading, setIsApiDeploymentLoading] = useState(false);
+ const [editModalOpen, setEditModalOpen] = useState(false);
+ const [editForm] = Form.useForm();
const handleExport = (
selectedUsers,
@@ -294,17 +296,32 @@ function Header({
setOpenCreateApiDeploymentModal(true);
}, []);
- return (
- <div className="custom-tools-header-layout">
- {isPublicSource ? (
- <div>
- <Typography.Text className="custom-tools-name" strong>
- {details?.tool_name}
- </Typography.Text>
- </div>
- ) : (
- <HeaderTitle />
- )}
+ const handleOpenEditModal = useCallback(() => {
+ editForm.setFieldsValue({
+ tool_name: details?.tool_name || "",
+ description: details?.description || "",
+ });
+ setEditModalOpen(true);
+ }, [details, editForm]);
+
+ const handleEditSubmit = useCallback(async () => {
+ try {
+ const values = await editForm.validateFields();
+ const res = await handleUpdateTool(values);
+ const updatedData = res?.data;
+ if (updatedData) {
+ useCustomToolStore.setState({ details: updatedData });
+ }
+ setEditModalOpen(false);
+ setAlertDetails({ type: "success", content: "Updated successfully" });
+ } catch (err) {
+ if (err?.errorFields) return;
+ setAlertDetails(handleException(err, "Failed to update"));
+ }
+ }, [editForm, handleUpdateTool, setAlertDetails, handleException]);
+
+ const actionButtons = useMemo(
+ () => (
<div className="custom-tools-header-btns">
{SinglePassToggleSwitch && (
<SinglePassToggleSwitch handleUpdateTool={handleUpdateTool} />
@@ -384,6 +401,60 @@ function Header({
/>
)}
</div>
+ ),
+ [
+ handleUpdateTool,
+ setOpenSettings,
+ setOpenCloneModal,
+ setOpenShareModal,
+ isPublicSource,
+ isExportLoading,
+ isApiDeploymentLoading,
+ userList,
+ openExportToolModal,
+ toolDetails,
+ details,
+ openCreateApiDeploymentModal,
+ ],
+ );
+
+ return (
+ <>
+ <ToolNavBar
+ title={details?.tool_name || ""}
+ subtitle={isPublicSource ? undefined : details?.description}
+ previousRoute={
+ isPublicSource || !sessionDetails?.orgName
+ ? undefined
+ : `/${sessionDetails.orgName}/tools`
+ }
+ onEditTitle={
+ isPublicSource || !details?.tool_id ? undefined : handleOpenEditModal
+ }
+ customButtons={actionButtons}
+ />
+ <Modal
+ title="Edit Project"
+ open={editModalOpen}
+ onOk={handleEditSubmit}
+ onCancel={() => setEditModalOpen(false)}
+ okText="Save"
+ centered
+ destroyOnClose
+ >
+ <Form form={editForm} layout="vertical">
+ <Form.Item
+ name="tool_name"
+ label="Project Name"
+ rules={[{ required: true, message: "Name is required" }]}
+ >
+ <Input />
+ </Form.Item>
+ <Form.Item name="description" label="Description">
+ <Input.TextArea rows={3} />
+ </Form.Item>
+ </Form>
+ </Modal>
<Modal
onOk={handleConfirmForceExport} // Pass the confirm action
onCancel={() => setConfirmModalVisible(false)} // Close the modal on cancel
@@ -445,7 +516,7 @@ function Header({
)}
<p>Do you want to proceed with creating the API deployment?</p>
</Modal>
- </div>
+ </>
);
}
diff --git a/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx b/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
index ae8164e37..974d01f36 100644
--- a/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
+++ b/frontend/src/components/custom-tools/list-of-tools/ListOfTools.jsx
@@ -1,7 +1,7 @@
import { ArrowDownOutlined, PlusOutlined } from "@ant-design/icons";
import { Space } from "antd";
import PropTypes from "prop-types";
-import { useCallback, useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
import { useAlertStore } from "../../../store/alert-store";
@@ -359,7 +359,7 @@ function ListOfTools() {
</div>
);
- const CustomButtonsComponent = useCallback(
+ const customButtonsElement = useMemo(
() => (
<DefaultCustomButtons
setOpenImportTool={setOpenImportTool}
@@ -378,7 +378,7 @@ function ListOfTools() {
onSearch={onSearch}
searchList={listOfTools}
setSearchList={setFilteredListOfTools}
- CustomButtons={CustomButtonsComponent}
+ customButtons={customButtonsElement}
/>
<div className="list-of-tools-layout">
<div className="list-of-tools-island">{defaultContent}</div>
diff --git a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
index 3b7fa9429..d65113f50 100644
--- a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
+++ b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx
@@ -355,14 +355,12 @@ function ToolIde() {
isExporting={isExporting}
/>
)}
- <div>
- <Header
- handleUpdateTool={handleUpdateTool}
- setOpenSettings={setOpenSettings}
- setOpenShareModal={setOpenShareModal}
- setOpenCloneModal={setOpenCloneModal}
- />
- </div>
+ <Header
+ handleUpdateTool={handleUpdateTool}
+ setOpenSettings={setOpenSettings}
+ setOpenShareModal={setOpenShareModal}
+ setOpenCloneModal={setOpenCloneModal}
+ />
<div
className={isPublicSource ? "public-tool-ide-body" : "tool-ide-body"}
>
diff --git a/frontend/src/components/deployments/header/Header.jsx b/frontend/src/components/deployments/header/Header.jsx
index fb58ecbd6..a2fcbaf62 100644
--- a/frontend/src/components/deployments/header/Header.jsx
+++ b/frontend/src/components/deployments/header/Header.jsx
@@ -21,21 +21,20 @@ function Header({ type, openAddModal, enableSearch, onSearch, setSearchList }) {
}
};
- const customButtons = () => {
- return (
- <CustomButton
- type="primary"
- icon={<PlusOutlined />}
- onClick={handleOnClick}
- >
- {deploymentsStaticContent[type].addBtn}
- </CustomButton>
- );
- };
+ const addButton = (
+ <CustomButton
+ type="primary"
+ icon={<PlusOutlined />}
+ onClick={handleOnClick}
+ >
+ {deploymentsStaticContent[type].addBtn}
+ </CustomButton>
+ );
+
return (
<ToolNavBar
title={deploymentsStaticContent[type].title}
- CustomButtons={customButtons}
+ customButtons={addButton}
enableSearch={enableSearch}
onSearch={onSearch}
setSearchList={setSearchList}
diff --git a/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx b/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
index 0f33f72c2..a9c72a0ef 100644
--- a/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
+++ b/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
@@ -164,16 +164,14 @@ function ExecutionLogs() {
}
};
- const customButtons = () => {
- return (
- <Tabs
- activeKey={activeTab}
- items={items}
- onChange={onChange}
- className="log-tab"
- />
- );
- };
+ const logTabs = (
+ <Tabs
+ activeKey={activeTab}
+ items={items}
+ onChange={onChange}
+ className="log-tab"
+ />
+ );
useEffect(() => {
if (!currentPath) {
@@ -220,7 +218,7 @@ function ExecutionLogs() {
<>
<ToolNavBar
title={"Execution Logs"}
- CustomButtons={customButtons}
+ customButtons={logTabs}
enableSearch={false}
previousRoute={backRoute}
previousRouteState={backRouteState}
diff --git a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.css b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.css
index cee99b0cd..d808e438b 100644
--- a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.css
+++ b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.css
@@ -1,31 +1,86 @@
-/* Styles for ToolNavBar */
+/* ToolNavBar — top navigation bar for pages and detail views */
-.search-navbar-dp {
- height: 25px;
- width: 25px;
+.tool-nav-bar {
display: flex;
align-items: center;
- justify-content: center;
- background-color: #184772;
- border-radius: 5px;
- cursor: pointer;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 8px 12px 8px 20px;
+ background-color: var(--page-bg-1, #f5f7f9);
+ box-shadow: 0 1px 3px 0 rgba(24, 50, 71, 0.08);
+ border-bottom: 1px solid var(--border-color-1, #dce4e4);
+}
+
+.tool-nav-bar__left {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ min-width: 0;
+ flex: 1;
}
-.api-search-input {
+.tool-nav-bar__right {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-shrink: 0;
+}
+
+.tool-nav-bar__search {
width: 250px;
- margin-right: 10px;
}
-.searchNav {
- background-color: #f5f7f9;
- padding-block: 12px;
- padding-inline-start: 20px;
- padding-inline-end: 12px;
- height: 56px;
- box-shadow: 0px 1px 3px 0px #18324714;
- border: 1px solid #dce4e4;
+.tool-nav-bar__segment {
+ background-color: rgba(0, 0, 0, 0.06);
+}
+
+/* Title area: hover reveals edit icon */
+.tool-nav-bar__title-area {
+ display: flex;
+ align-items: center;
+ min-width: 0;
+ flex: 1;
+}
+
+.tool-nav-bar__title-area:hover .tool-nav-bar__edit-icon {
+ opacity: 1;
+}
+
+/* Title + subtitle stacked, centered vertically within available height */
+.tool-nav-bar__title-group {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ min-width: 0;
+}
+
+/* Title text + edit icon inline */
+.tool-nav-bar__title-row {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+
+.tool-nav-bar__title {
+ font-size: var(--font-size-16, 16px);
+}
+
+.tool-nav-bar .tool-nav-bar__subtitle {
+ font-size: var(--font-size-12, 12px);
+ line-height: 18px;
+ margin-bottom: 0;
+ max-width: min(600px, 45vw);
+}
+
+/* Edit button: hidden by default, appears on title-area hover */
+.tool-nav-bar__edit-icon.ant-btn {
+ opacity: 0;
+ color: var(--ant-color-text-secondary, #8c8c8c);
+ transition:
+ opacity 0.15s,
+ color 0.15s;
}
-.tool-bar-segment {
- background-color: #0000000f;
+.tool-nav-bar__edit-icon.ant-btn:hover {
+ color: var(--ant-color-primary, #1677ff);
}
diff --git a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
index 6e4804909..999630d59 100644
--- a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
+++ b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
@@ -1,18 +1,22 @@
-import { Button, Col, Row, Segmented, Typography } from "antd";
-import "./ToolNavBar.css";
-import { ArrowLeftOutlined } from "@ant-design/icons";
+import { ArrowLeftOutlined, EditOutlined } from "@ant-design/icons";
+import { Button, Segmented, Typography } from "antd";
import Search from "antd/es/input/Search";
import { debounce } from "lodash";
import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom";
+import "./ToolNavBar.css";
+
function ToolNavBar({
title,
+ subtitle,
+ onEditTitle,
enableSearch,
- CustomButtons,
+ customButtons,
setSearchList,
previousRoute,
previousRouteState,
+ onNavigateBack,
segmentFilter,
segmentOptions,
onSearch,
@@ -23,62 +27,89 @@ function ToolNavBar({
onSearch(value, setSearchList);
}, 600);
+ const handleBack = () => {
+ if (onNavigateBack) {
+ onNavigateBack();
+ } else if (previousRoute) {
+ navigate(previousRoute, { state: previousRouteState });
+ }
+ };
+
return (
- <Row align="middle" justify="space-between" className="searchNav">
- <Col>
- {previousRoute && (
+ <div className="tool-nav-bar">
+ <div className="tool-nav-bar__left">
+ {(previousRoute || onNavigateBack) && (
<Button
type="text"
shape="circle"
icon={<ArrowLeftOutlined />}
- onClick={() =>
- navigate(previousRoute, { state: previousRouteState })
- }
+ onClick={handleBack}
/>
)}
{title && (
- <Typography
- style={{
- fontWeight: 600,
- fontSize: "16px",
- display: "inline",
- lineHeight: "24px",
- }}
- >
- {title}
- </Typography>
+ <div className="tool-nav-bar__title-area">
+ <div className="tool-nav-bar__title-group">
+ <div className="tool-nav-bar__title-row">
+ <Typography.Text strong className="tool-nav-bar__title">
+ {title}
+ </Typography.Text>
+ {onEditTitle && (
+ <Button
+ type="text"
+ size="small"
+ icon={<EditOutlined />}
+ className="tool-nav-bar__edit-icon"
+ onClick={onEditTitle}
+ aria-label="Edit title"
+ />
+ )}
+ </div>
+ {subtitle && (
+ <Typography.Paragraph
+ type="secondary"
+ ellipsis={{ rows: 1, tooltip: true }}
+ className="tool-nav-bar__subtitle"
+ >
+ {subtitle}
+ </Typography.Paragraph>
+ )}
+ </div>
+ </div>
)}
{segmentFilter && segmentOptions && (
<Segmented
options={segmentOptions}
onChange={segmentFilter}
- className="tool-bar-segment"
+ className="tool-nav-bar__segment"
/>
)}
- </Col>
- <Col>
+ </div>
+ <div className="tool-nav-bar__right">
{enableSearch && (
<Search
key={searchKey}
- className="api-search-input"
+ className="tool-nav-bar__search"
placeholder="Search by name"
onChange={onSearchDebounce}
allowClear
/>
)}
- {CustomButtons && <CustomButtons />}
- </Col>
- </Row>
+ {customButtons}
+ </div>
+ </div>
);
}
ToolNavBar.propTypes = {
title: PropTypes.string,
+ subtitle: PropTypes.string,
+ onEditTitle: PropTypes.func,
enableSearch: PropTypes.bool,
- CustomButtons: PropTypes.func,
+ customButtons: PropTypes.node,
setSearchList: PropTypes.func,
previousRoute: PropTypes.string,
previousRouteState: PropTypes.object,
+ onNavigateBack: PropTypes.func,
segmentOptions: PropTypes.array,
segmentFilter: PropTypes.func,
onSearch: PropTypes.func,
diff --git a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
index 9bf7c0f2c..26f287d22 100644
--- a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
+++ b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
@@ -224,17 +224,15 @@ function ToolSettings({ type }) {
searchKey={type}
setSearchList={setDisplayList}
onSearch={onSearch}
- CustomButtons={() => {
- return (
- <CustomButton
- type="primary"
- onClick={handleOpenAddSourceModal}
- icon={<PlusOutlined />}
- >
- {btnText[type]}
- </CustomButton>
- );
- }}
+ customButtons={
+ <CustomButton
+ type="primary"
+ onClick={handleOpenAddSourceModal}
+ icon={<PlusOutlined />}
+ >
+ {btnText[type]}
+ </CustomButton>
+ }
/>
<IslandLayout>
<div className="plt-tool-settings-layout-2">
diff --git a/frontend/src/components/widgets/list-view/ListView.css b/frontend/src/components/widgets/list-view/ListView.css
index 171e7377d..33406ba22 100644
--- a/frontend/src/components/widgets/list-view/ListView.css
+++ b/frontend/src/components/widgets/list-view/ListView.css
@@ -45,12 +45,10 @@
align-self: center !important;
}
-.cur-pointer .ant-list-item-meta-description {
- -webkit-line-clamp: 2;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
+.list-view-description {
+ font-size: 13px;
+ margin-bottom: 0;
+ max-width: 40%;
}
.list-view-divider {
diff --git a/frontend/src/components/widgets/list-view/ListView.jsx b/frontend/src/components/widgets/list-view/ListView.jsx
index d019ec9f6..9362d1bdc 100644
--- a/frontend/src/components/widgets/list-view/ListView.jsx
+++ b/frontend/src/components/widgets/list-view/ListView.jsx
@@ -185,11 +185,15 @@ function ListView({
className="list-item-desc"
title={renderTitle(item)}
description={
- <Typography.Text type="secondary" ellipsis>
- <Tooltip title={item[descriptionProp]}>
+ item[descriptionProp] ? (
+ <Typography.Paragraph
+ type="secondary"
+ ellipsis={{ rows: 1, tooltip: true }}
+ className="list-view-description"
+ >
{item[descriptionProp]}
- </Tooltip>
- </Typography.Text>
+ </Typography.Paragraph>
+ ) : null
}
></List.Item.Meta>
</List.Item>
diff --git a/frontend/src/components/workflows/workflow/Workflows.jsx b/frontend/src/components/workflows/workflow/Workflows.jsx
index 73da9ec98..6c4c77ea6 100644
--- a/frontend/src/components/workflows/workflow/Workflows.jsx
+++ b/frontend/src/components/workflows/workflow/Workflows.jsx
@@ -26,11 +26,6 @@ import { ViewTools } from "../../custom-tools/view-tools/ViewTools.jsx";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar.jsx";
import { workflowService } from "./workflow-service";
-const PROJECT_FILTER_OPTIONS = [
- { label: "My Workflows", value: "mine" },
- { label: "Organization Workflows", value: "all" },
-];
-
const { Text } = Typography;
function Workflows() {
@@ -52,7 +47,6 @@ function Workflows() {
const [loading, setLoading] = useState(false);
const [openModal, toggleModal] = useState(true);
const projectListRef = useRef();
- const filterViewRef = useRef(PROJECT_FILTER_OPTIONS[0].value);
const [backendErrors, setBackendErrors] = useState(null);
const [shareOpen, setShareOpen] = useState(false);
const [selectedWorkflow, setSelectedWorkflow] = useState();
@@ -73,7 +67,7 @@ function Workflows() {
function getProjectList() {
projectApiService
- .getProjectList(filterViewRef.current === PROJECT_FILTER_OPTIONS[0].value)
+ .getProjectList()
.then((res) => {
projectListRef.current = res.data;
setProjectList(res.data);
@@ -94,13 +88,6 @@ function Workflows() {
setSearchList(filteredList);
}
- function applyFilter(value) {
- filterViewRef.current = value;
- projectListRef.current = "";
- setProjectList("");
- getProjectList();
- }
-
function editProject(name, description) {
setLoading(true);
projectApiService
@@ -302,17 +289,15 @@ function Workflows() {
}
};
- const CustomButtons = () => {
- return (
- <CustomButton
- type="primary"
- icon={<PlusOutlined />}
- onClick={handleNewWorkflowBtnClick}
- >
- New Workflow
- </CustomButton>
- );
- };
+ const newWorkflowButton = (
+ <CustomButton
+ type="primary"
+ icon={<PlusOutlined />}
+ onClick={handleNewWorkflowBtnClick}
+ >
+ New Workflow
+ </CustomButton>
+ );
// Using the custom hook to manage modal state
const { showModal, handleModalClose } = usePromptStudioModal(
@@ -327,12 +312,11 @@ function Workflows() {
<PromptStudioModal onClose={handleModalClose} showModal={showModal} />
)}
<ToolNavBar
+ title="Workflows"
enableSearch
searchList={projectList}
setSearchList={setProjectList}
- CustomButtons={CustomButtons}
- segmentFilter={applyFilter}
- segmentOptions={PROJECT_FILTER_OPTIONS}
+ customButtons={newWorkflowButton}
onSearch={onSearch}
/>
<div className="workflows-pg-layout">
diff --git a/frontend/src/layouts/menu-layout/MenuLayout.jsx b/frontend/src/layouts/menu-layout/MenuLayout.jsx
index 52844ef10..9a35b7a9d 100644
--- a/frontend/src/layouts/menu-layout/MenuLayout.jsx
+++ b/frontend/src/layouts/menu-layout/MenuLayout.jsx
@@ -1,12 +1,16 @@
-import { ArrowLeftOutlined, QuestionCircleOutlined } from "@ant-design/icons";
-import { Button, Space, Typography } from "antd";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import { Button, Form, Input, Modal, Space } from "antd";
import PropTypes from "prop-types";
-import { useEffect, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
-import "./MenuLayout.css";
+import { ToolNavBar } from "../../components/navigations/tool-nav-bar/ToolNavBar";
+import { workflowService } from "../../components/workflows/workflow/workflow-service";
+import { useExceptionHandler } from "../../hooks/useExceptionHandler";
+import { useAlertStore } from "../../store/alert-store";
import { useSessionStore } from "../../store/session-store";
import { useWorkflowStore } from "../../store/workflow-store";
+import "./MenuLayout.css";
function MenuLayout({ children }) {
const navigate = useNavigate();
@@ -14,7 +18,13 @@ function MenuLayout({ children }) {
const currentMenu = useRef();
const [activeTab, setActiveTab] = useState("");
const { sessionDetails } = useSessionStore();
- const { projectName } = useWorkflowStore();
+ const { projectName, projectId, details } = useWorkflowStore();
+ const { setAlertDetails } = useAlertStore();
+ const handleException = useExceptionHandler();
+ const wfService = workflowService();
+
+ const [editModalOpen, setEditModalOpen] = useState(false);
+ const [editForm] = Form.useForm();
useEffect(() => {
currentMenu.current = location.pathname;
@@ -28,56 +38,109 @@ function MenuLayout({ children }) {
setActiveTab(value);
}, []);
+ const handleNavigateBack = useCallback(() => {
+ if (location.state?.from) {
+ const from = location.state.from;
+ const fromState =
+ typeof from === "object" && from.state ? from.state : {};
+ const mergedState = {
+ ...fromState,
+ ...(location.state?.scrollToCardId && {
+ scrollToCardId: location.state.scrollToCardId,
+ }),
+ };
+ const nextState = Object.keys(mergedState).length
+ ? mergedState
+ : undefined;
+ if (typeof from === "object") {
+ navigate({ ...from, state: nextState });
+ } else {
+ navigate(from, { state: nextState });
+ }
+ } else if (sessionDetails?.orgName) {
+ navigate(`/${sessionDetails.orgName}/workflows`);
+ }
+ }, [location.state, sessionDetails.orgName, navigate]);
+
+ const handleOpenEditModal = useCallback(() => {
+ editForm.setFieldsValue({
+ workflow_name: projectName || "",
+ description: details?.description || "",
+ });
+ setEditModalOpen(true);
+ }, [projectName, details, editForm]);
+
+ const handleEditSubmit = useCallback(async () => {
+ try {
+ const values = await editForm.validateFields();
+ await wfService.editProject(
+ values.workflow_name,
+ values.description,
+ projectId,
+ );
+ // Use Zustand's setState directly for correct shallow merge
+ useWorkflowStore.setState({
+ projectName: values.workflow_name,
+ details: { ...details, description: values.description },
+ });
+ setEditModalOpen(false);
+ setAlertDetails({ type: "success", content: "Updated successfully" });
+ } catch (err) {
+ if (err?.errorFields) {
+ return;
+ }
+ setAlertDetails(handleException(err, "Failed to update workflow"));
+ }
+ }, [editForm, projectId, details, setAlertDetails, handleException]);
+
+ const rightButtons = useMemo(
+ () => (
+ <Space>
+ <Button
+ key="help"
+ icon={<QuestionCircleOutlined />}
+ disabled={true}
+ type={activeTab === "help" ? "primary" : "default"}
+ >
+ Help
+ </Button>
+ </Space>
+ ),
+ [activeTab],
+ );
+
return (
<>
- <div className="appHeader">
- <div className="project_detail">
- <Button
- size="small"
- type="text"
- onClick={() => {
- if (location.state?.from) {
- const from = location.state.from;
- const fromState =
- typeof from === "object" && from.state ? from.state : {};
- const mergedState = {
- ...fromState,
- ...(location.state?.scrollToCardId && {
- scrollToCardId: location.state.scrollToCardId,
- }),
- };
- const nextState = Object.keys(mergedState).length
- ? mergedState
- : undefined;
- if (typeof from === "object") {
- navigate({ ...from, state: nextState });
- } else {
- navigate(from, { state: nextState });
- }
- } else {
- navigate(`/${sessionDetails.orgName}/workflows`);
- }
- }}
+ <ToolNavBar
+ title={projectName || "Name of the project"}
+ subtitle={details?.description}
+ onNavigateBack={handleNavigateBack}
+ onEditTitle={projectId ? handleOpenEditModal : undefined}
+ customButtons={rightButtons}
+ />
+ <Modal
+ title="Edit Workflow"
+ open={editModalOpen}
+ onOk={handleEditSubmit}
+ okButtonProps={{ disabled: !projectId }}
+ onCancel={() => setEditModalOpen(false)}
+ okText="Save"
+ centered
+ destroyOnClose
+ >
+ <Form form={editForm} layout="vertical">
+ <Form.Item
+ name="workflow_name"
+ label="Workflow Name"
+ rules={[{ required: true, message: "Name is required" }]}
>
- <ArrowLeftOutlined />
- </Button>
- <Typography className="proj_name">
- {projectName || "Name of the project"}
- </Typography>
- </div>
- <div>
- <Space>
- <Button
- key="help"
- icon={<QuestionCircleOutlined />}
- disabled={true}
- type={activeTab === "help" ? "primary" : "default"}
- >
- Help
- </Button>
- </Space>
- </div>
- </div>
+ <Input />
+ </Form.Item>
+ <Form.Item name="description" label="Description">
+ <Input.TextArea rows={3} />
+ </Form.Item>
+ </Form>
+ </Modal>
<div className="appBody">
<div className="appBody2">{children}</div>
</div>
diff --git a/frontend/src/pages/ConnectorsPage.jsx b/frontend/src/pages/ConnectorsPage.jsx
index a2ad4bfa9..017411107 100644
--- a/frontend/src/pages/ConnectorsPage.jsx
+++ b/frontend/src/pages/ConnectorsPage.jsx
@@ -1,6 +1,6 @@
import { PlusOutlined } from "@ant-design/icons";
import { Button } from "antd";
-import { useCallback, useEffect, useState } from "react";
+import { useEffect, useState } from "react";
import { useAxiosPrivate } from "../hooks/useAxiosPrivate";
import { useExceptionHandler } from "../hooks/useExceptionHandler";
@@ -140,17 +140,14 @@ function ConnectorsPage() {
});
};
- const renderCreateConnectorButtons = useCallback(
- () => (
- <Button
- type="primary"
- icon={<PlusOutlined />}
- onClick={handleCreateConnector}
- >
- New Connector
- </Button>
- ),
- [],
+ const newConnectorButton = (
+ <Button
+ type="primary"
+ icon={<PlusOutlined />}
+ onClick={handleCreateConnector}
+ >
+ New Connector
+ </Button>
);
return (
@@ -160,7 +157,7 @@ function ConnectorsPage() {
enableSearch
setSearchList={setDisplayList}
onSearch={onSearch}
- CustomButtons={renderCreateConnectorButtons}
+ customButtons={newConnectorButton}
/>
<div className="connectors-pg-layout">
<div className="connectors-pg-body">