Skip to content

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

[FIX] Restore HITL sidebar navigation removed by sidebar refactor (#1810)

vishnuszipstack8984395b1a48
diff --git a/frontend/src/components/navigations/side-nav-bar/SideNavBar.css b/frontend/src/components/navigations/side-nav-bar/SideNavBar.css
index 41f00a2e8..1c3a50007 100644
--- a/frontend/src/components/navigations/side-nav-bar/SideNavBar.css
+++ b/frontend/src/components/navigations/side-nav-bar/SideNavBar.css
@@ -160,3 +160,17 @@
background-color: rgba(255, 255, 255, 0.3);
margin: 10px 0;
}
+
+.sidebar-antd-icon {
+ font-size: 22px;
+ color: #b4c2cf;
+ width: 25px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.space-styles-active .sidebar-antd-icon,
+.space-styles:hover .sidebar-antd-icon {
+ color: white;
+}
diff --git a/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx b/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
index 428c7d215..d0783633d 100644
--- a/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
+++ b/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
@@ -1,4 +1,8 @@
-import { BranchesOutlined, DoubleRightOutlined } from "@ant-design/icons";
+import {
+ BranchesOutlined,
+ DoubleRightOutlined,
+ FileProtectOutlined,
+} from "@ant-design/icons";
import {
Button,
Divider,
@@ -168,10 +172,83 @@ SettingsPopoverContent.propTypes = {
navigate: PropTypes.func.isRequired,
};
+const HITL_MENU_ITEMS = [
+ { key: "review", label: "Review", subPath: "/review" },
+ {
+ key: "approve",
+ label: "Approve",
+ subPath: "/review/approve",
+ supervisorOnly: true,
+ },
+ {
+ key: "download",
+ label: "Download & Sync",
+ subPath: "/review/download_and_sync",
+ supervisorOnly: true,
+ },
+];
+
+const getHITLMenuItems = (orgName, role) => {
+ const isSupervisorOrAdmin = [
+ "unstract_supervisor",
+ "unstract_admin",
+ ].includes(role);
+ return HITL_MENU_ITEMS.filter(
+ (item) => !item.supervisorOnly || isSupervisorOrAdmin,
+ ).map((item) => ({
+ key: item.key,
+ label: item.label,
+ path: `/${orgName}${item.subPath}`,
+ }));
+};
+
+const getActiveHITLKey = (orgName) => {
+ const currentPath = globalThis.location.pathname;
+ const base = `/${orgName}/review`;
+ if (currentPath.startsWith(`${base}/approve`)) {
+ return "approve";
+ }
+ if (currentPath.startsWith(`${base}/download_and_sync`)) {
+ return "download";
+ }
+ if (currentPath.startsWith(base)) {
+ return "review";
+ }
+ return "review";
+};
+
+const HITLPopoverContent = ({ orgName, role, navigate }) => {
+ const hitlMenuItems = getHITLMenuItems(orgName, role);
+ const currentActiveKey = getActiveHITLKey(orgName);
+
+ return (
+ <nav className="settings-sidebar-popover">
+ {hitlMenuItems.map((menuItem) => (
+ <button
+ key={menuItem.key}
+ type="button"
+ className={`settings-menu-item ${
+ currentActiveKey === menuItem.key ? "active" : ""
+ }`}
+ onClick={() => navigate(menuItem.path)}
+ >
+ {menuItem.label}
+ </button>
+ ))}
+ </nav>
+ );
+};
+
+HITLPopoverContent.propTypes = {
+ orgName: PropTypes.string.isRequired,
+ role: PropTypes.string.isRequired,
+ navigate: PropTypes.func.isRequired,
+};
+
const SideNavBar = ({ collapsed, setCollapsed }) => {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
- const { orgName, flags } = sessionDetails;
+ const { orgName, flags, role } = sessionDetails;
const [isPinned, setIsPinned] = useState(() =>
getLocalStorageValue("sidebarPinned", false),
@@ -407,6 +484,37 @@ const SideNavBar = ({ collapsed, setCollapsed }) => {
});
}
+ // Add HITL Review section if plugin is available and user has HITL role
+ const isHITLRole = [
+ "unstract_reviewer",
+ "unstract_supervisor",
+ "unstract_admin",
+ ].includes(role);
+ if (manualReviewSettingsEnabled && isHITLRole && isUnstract) {
+ const hasReviewSection = data.some((item) => item.mainTitle === "REVIEW");
+ const settingsIndex = data.findIndex(
+ (item) => item.mainTitle === "SETTINGS",
+ );
+ if (!hasReviewSection && settingsIndex !== -1) {
+ data.splice(settingsIndex, 0, {
+ id: 2.5,
+ mainTitle: "REVIEW",
+ subMenu: [
+ {
+ id: 2.51,
+ title: "HITL",
+ description: "Human-in-the-loop document review",
+ isHITL: true,
+ path: `/${orgName}/review`,
+ active: globalThis.location.pathname.startsWith(
+ `/${orgName}/review`,
+ ),
+ },
+ ],
+ });
+ }
+ }
+
const shouldDisableAll = useMemo(() => {
if (
!unstractSubscriptionPlan ||
@@ -448,6 +556,64 @@ const SideNavBar = ({ collapsed, setCollapsed }) => {
)}
<Space direction="vertical" className="menu-item-body">
{item?.subMenu?.map((el) => {
+ // HITL item has a hover menu
+ if (el.isHITL) {
+ const handleHITLClick = () => {
+ if (!el.disable) {
+ navigate(el.path);
+ }
+ };
+
+ const hitlContent = (
+ <Tooltip title={collapsed ? el.title : ""}>
+ <Space
+ className={`space-styles ${
+ el.active ? "space-styles-active" : ""
+ } ${el.disable ? "space-styles-disable" : ""}`}
+ onClick={handleHITLClick}
+ data-testid={`sidebar-${el.title
+ ?.toLowerCase()
+ ?.replaceAll(/\s+/g, "-")}`}
+ >
+ <FileProtectOutlined className="sidebar-antd-icon" />
+ {!collapsed && (
+ <div>
+ <Typography className="sidebar-item-text fs-14">
+ {el.title}
+ </Typography>
+ <Typography className="sidebar-item-text fs-11">
+ {el.description}
+ </Typography>
+ </div>
+ )}
+ </Space>
+ </Tooltip>
+ );
+
+ if (el.disable) {
+ return <div key={el.id}>{hitlContent}</div>;
+ }
+
+ return (
+ <Popover
+ key={el.id}
+ content={
+ <HITLPopoverContent
+ orgName={orgName}
+ role={role}
+ navigate={navigate}
+ />
+ }
+ trigger="hover"
+ placement="rightTop"
+ arrow={false}
+ overlayClassName="settings-popover-overlay"
+ >
+ {hitlContent}
+ </Popover>
+ );
+ }
+
// Platform item has a hover menu and click navigates to platform settings
if (el.id === 3.6) {
const handlePlatformClick = () => {