Skip to content

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

Feat/unified dev portal (#582)

jagadeeswaran-zipstack0902291b9c1f
diff --git a/docker/dockerfiles/frontend.Dockerfile b/docker/dockerfiles/frontend.Dockerfile
index 8c935ca39..242e3f4a1 100644
--- a/docker/dockerfiles/frontend.Dockerfile
+++ b/docker/dockerfiles/frontend.Dockerfile
@@ -1,5 +1,6 @@
FROM node:16 AS builder
+# Build-time environment variables
ENV BUILD_CONTEXT_PATH frontend
ENV REACT_APP_BACKEND_URL ""
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index d2c4d022f..fcf2d882b 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -17,6 +17,7 @@
"@rjsf/core": "^5.8.1",
"@rjsf/utils": "^5.8.1",
"@rjsf/validator-ajv8": "^5.8.1",
+ "@stripe/stripe-js": "^4.2.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
@@ -4176,6 +4177,14 @@
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
},
+ "node_modules/@stripe/stripe-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/@stripe/stripe-js/-/stripe-js-4.2.0.tgz",
+ "integrity": "sha512-MdTpmXqtm+B9rIAmaSlCkF6qv3793UrghA95SFI4Ge7KGYWZAMYyxbX/z9FXs6XnU5gUbKtGtlVgZQp1T88UfQ==",
+ "engines": {
+ "node": ">=12.16"
+ }
+ },
"node_modules/@surma/rollup-plugin-off-main-thread": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
@@ -7976,6 +7985,16 @@
"node": ">= 0.8"
}
},
+ "node_modules/encoding": {
+ "version": "0.1.13",
+ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
+ "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
+ "optional": true,
+ "peer": true,
+ "dependencies": {
+ "iconv-lite": "^0.6.2"
+ }
+ },
"node_modules/engine.io-client": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.2.tgz",
@@ -23463,6 +23482,11 @@
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
},
+ "@stripe/stripe-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/@stripe/stripe-js/-/stripe-js-4.2.0.tgz",
+ "integrity": "sha512-MdTpmXqtm+B9rIAmaSlCkF6qv3793UrghA95SFI4Ge7KGYWZAMYyxbX/z9FXs6XnU5gUbKtGtlVgZQp1T88UfQ=="
+ },
"@surma/rollup-plugin-off-main-thread": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
@@ -26287,6 +26311,16 @@
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="
},
+ "encoding": {
+ "version": "0.1.13",
+ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
+ "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
+ "optional": true,
+ "peer": true,
+ "requires": {
+ "iconv-lite": "^0.6.2"
+ }
+ },
"engine.io-client": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.2.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 9b2e384cd..e1709eddf 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -12,6 +12,7 @@
"@rjsf/core": "^5.8.1",
"@rjsf/utils": "^5.8.1",
"@rjsf/validator-ajv8": "^5.8.1",
+ "@stripe/stripe-js": "^4.2.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
diff --git a/frontend/public/index.html b/frontend/public/index.html
index c346457d7..eea6f6464 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -5,10 +5,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
- <meta
- name="description"
- content="Unstract"
- />
+ <meta name="description" content="Unstract" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Unstract</title>
</head>
diff --git a/frontend/src/components/helpers/auth/RequireAuth.js b/frontend/src/components/helpers/auth/RequireAuth.js
index da89696ab..e5649c696 100644
--- a/frontend/src/components/helpers/auth/RequireAuth.js
+++ b/frontend/src/components/helpers/auth/RequireAuth.js
@@ -15,6 +15,13 @@ try {
} catch {
// The component will remain null of it is not available
}
+let selectedProductStore;
+let isLlmWhisperer;
+try {
+ selectedProductStore = require("../../../plugins/llm-whisperer/store/select-product-store.js");
+} catch {
+ // do nothing
+}
const RequireAuth = () => {
const { sessionDetails } = useSessionStore();
@@ -24,7 +31,18 @@ const RequireAuth = () => {
const orgName = sessionDetails?.orgName;
const pathname = location?.pathname;
const adapters = sessionDetails?.adapters;
- const currOrgName = getOrgNameFromPathname(pathname);
+ try {
+ isLlmWhisperer =
+ selectedProductStore.useSelectedProductStore(
+ (state) => state?.selectedProduct
+ ) === "llm-whisperer";
+ } catch (error) {
+ // Do nothing
+ }
+ const currOrgName = getOrgNameFromPathname(
+ pathname,
+ isLlmWhisperer !== undefined ? !isLlmWhisperer : null
+ );
useEffect(() => {
if (!sessionDetails?.isLoggedIn) {
@@ -35,7 +53,9 @@ const RequireAuth = () => {
}, [sessionDetails]);
let navigateTo = `/${orgName}/onboard`;
- if (onboardCompleted(adapters)) {
+ if (isLlmWhisperer) {
+ navigateTo = `/llm-whisperer/${orgName}/playground`;
+ } else if (onboardCompleted(adapters)) {
navigateTo = `/${orgName}/tools`;
}
if (
diff --git a/frontend/src/components/helpers/auth/RequireGuest.js b/frontend/src/components/helpers/auth/RequireGuest.js
index b92a8446f..00b1fa62c 100644
--- a/frontend/src/components/helpers/auth/RequireGuest.js
+++ b/frontend/src/components/helpers/auth/RequireGuest.js
@@ -2,14 +2,32 @@ import { Navigate, Outlet, useLocation } from "react-router-dom";
import { publicRoutes, onboardCompleted } from "../../../helpers/GetStaticData";
import { useSessionStore } from "../../../store/session-store";
+let selectedProductStore;
+let isLlmWhisperer;
+try {
+ selectedProductStore = require("../../../plugins/llm-whisperer/store/select-product-store.js");
+} catch {
+ // do nothing
+}
const RequireGuest = () => {
const { sessionDetails } = useSessionStore();
const { orgName, adapters } = sessionDetails;
const location = useLocation();
const pathname = location.pathname;
+ try {
+ isLlmWhisperer =
+ selectedProductStore.useSelectedProductStore(
+ (state) => state?.selectedProduct
+ ) === "llm-whisperer";
+ } catch (error) {
+ // Do nothing
+ }
+
let navigateTo = `/${orgName}/onboard`;
- if (onboardCompleted(adapters)) {
+ if (isLlmWhisperer) {
+ navigateTo = `/llm-whisperer/${orgName}/playground`;
+ } else if (onboardCompleted(adapters)) {
navigateTo = `/${orgName}/tools`;
}
if (
diff --git a/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx b/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
index 60f54256a..0a1997d9d 100644
--- a/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
+++ b/frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
@@ -24,12 +24,23 @@ try {
// Plugin unavailable.
}
+let sideMenu;
+try {
+ sideMenu = require("../../../plugins/hooks/useSideMenu");
+} catch (err) {
+ // Plugin unavailable.
+}
+
const SideNavBar = ({ collapsed }) => {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
const { orgName, flags } = sessionDetails;
+ let menu;
+ if (sideMenu) {
+ menu = sideMenu.useSideMenu();
+ }
- const data = [
+ const data = menu || [
{
id: 1,
mainTitle: "MANAGE",
@@ -144,8 +155,8 @@ const SideNavBar = ({ collapsed }) => {
},
];
- if (getMenuItem && flags.app_deployment) {
- data[0].subMenu.splice(1, 0, getMenuItem.default(orgName));
+ if (getMenuItem && flags?.app_deployment) {
+ data[0]?.subMenu?.splice(1, 0, getMenuItem?.default(orgName));
}
return (
diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.css b/frontend/src/components/navigations/top-nav-bar/TopNavBar.css
index bb4095d7d..8e724fec8 100644
--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.css
+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.css
@@ -70,3 +70,8 @@
font-weight: 600;
margin-left: 10px;
}
+
+.platform-switch-container {
+ display: flex;
+ align-items: center;
+}
diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
index 73feb5e80..f82089c17 100644
--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
@@ -19,6 +19,7 @@ import {
import { useEffect, useState } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import axios from "axios";
+import PropTypes from "prop-types";
import { UnstractLogo } from "../../../assets/index.js";
import {
@@ -40,8 +41,38 @@ try {
} catch (err) {
// Plugin not found
}
+let selectedProduct;
+let selectedProductStore;
-function TopNavBar() {
+try {
+ selectedProductStore = require("../../../plugins/llm-whisperer/store/select-product-store.js");
+} catch {
+ // Ignore if hook not available
+}
+
+let PlatformDropdown;
+
+try {
+ PlatformDropdown =
+ require("../../../plugins/platform-dropdown/PlatformDropDown.jsx").PlatformDropdown;
+} catch (err) {
+ // Plugin not found
+}
+
+try {
+ selectedProductStore = require("../../../plugins/llm-whisperer/store/select-product-store.js");
+} catch {
+ // Ignore if hook not available
+}
+
+let WhispererLogo;
+try {
+ WhispererLogo = require("../../../plugins/assets/index.js").WhispererLogo;
+} catch {
+ // Ignore if hook not available
+}
+
+function TopNavBar({ isSimpleLayout }) {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
const { orgName, remainingTrialDays, allOrganization, orgId } =
@@ -57,6 +88,14 @@ function TopNavBar() {
const handleException = useExceptionHandler();
const location = useLocation();
+ if (selectedProductStore) {
+ selectedProduct = selectedProductStore.useSelectedProductStore(
+ (state) => state?.selectedProduct
+ );
+ }
+
+ const isUnstract = !(selectedProduct && selectedProduct !== "unstract");
+
useEffect(() => {
const isUnstractReviewer = sessionDetails.role === "unstract_reviewer";
const isUnstractSupervisor = sessionDetails.role === "unstract_supervisor";
@@ -90,7 +129,7 @@ function TopNavBar() {
}
}, [location]);
- const cascadeOptions = allOrganization.map((org) => {
+ const cascadeOptions = allOrganization?.map((org) => {
return {
key: org?.id,
label:
@@ -126,6 +165,7 @@ function TopNavBar() {
};
await axios(requestOptions)
.then(() => {
+ navigate("/");
window.location.reload();
})
.catch((err) => {
@@ -146,7 +186,7 @@ function TopNavBar() {
</Button>
),
},
- allOrganization.length > 1 && {
+ allOrganization?.length > 1 && {
key: "3",
label: (
<Dropdown
@@ -166,39 +206,42 @@ function TopNavBar() {
</Dropdown>
),
},
- (reviewerStatus || approverStatus) && {
- key: "4",
- label: (
- <Button
- onClick={() => navigate(`/${orgName}/review`)}
- className="logout-button"
- >
- <FileProtectOutlined /> Review
- </Button>
- ),
- },
- approverStatus && {
- key: "5",
- label: (
- <Button
- onClick={() => navigate(`/${orgName}/review/approve`)}
- className="logout-button"
- >
- <LikeOutlined /> Approve
- </Button>
- ),
- },
- approverStatus && {
- key: "6",
- label: (
- <Button
- onClick={() => navigate(`/${orgName}/review/download_and_sync`)}
- className="logout-button"
- >
- <DownloadOutlined /> Download and Sync Manager
- </Button>
- ),
- },
+ isUnstract &&
+ (reviewerStatus || approverStatus) && {
+ key: "4",
+ label: (
+ <Button
+ onClick={() => navigate(`/${orgName}/review`)}
+ className="logout-button"
+ >
+ <FileProtectOutlined /> Review
+ </Button>
+ ),
+ },
+ isUnstract &&
+ approverStatus && {
+ key: "5",
+ label: (
+ <Button
+ onClick={() => navigate(`/${orgName}/review/approve`)}
+ className="logout-button"
+ >
+ <LikeOutlined /> Approve
+ </Button>
+ ),
+ },
+ isUnstract &&
+ approverStatus && {
+ key: "6",
+ label: (
+ <Button
+ onClick={() => navigate(`/${orgName}/review/download_and_sync`)}
+ className="logout-button"
+ >
+ <DownloadOutlined /> Download and Sync Manager
+ </Button>
+ ),
+ },
{
key: "2",
label: (
@@ -221,66 +264,80 @@ function TopNavBar() {
return (
<Row align="middle" className="topNav">
- <Col span={6}>
- <UnstractLogo className="topbar-logo" />
+ <Col span={6} className="platform-switch-container">
+ {isUnstract ? (
+ <UnstractLogo className="topbar-logo" />
+ ) : (
+ WhispererLogo && <WhispererLogo className="topbar-logo" />
+ )}
{reviewPageHeader && (
<span className="page-identifier">
<span className="custom-tools-header-v-divider" />
<span className="page-heading">{reviewPageHeader}</span>
</span>
)}
+ {PlatformDropdown && <PlatformDropdown />}
</Col>
- <Col span={14} className="top-nav-alert-col">
- {showOnboardBanner && (
- <Alert
- type="error"
- message={
- <>
- <span className="top-nav-alert-msg">
- Your setup process is incomplete. Now, that&apos;s a bummer!
- </span>
- <a
- href={onBoardUrl}
- size="small"
- type="text"
- className="top-nav-alert-link"
- >
- Complete it to start using Unstract
- </a>
- </>
- }
- showIcon
- />
- )}
- </Col>
- <Col span={4}>
- <Row justify="end" align="middle">
- <Space>
- {TrialDaysInfo && (
- <TrialDaysInfo remainingTrialDays={remainingTrialDays} />
+ {!isSimpleLayout && (
+ <>
+ <Col span={14} className="top-nav-alert-col">
+ {isUnstract && showOnboardBanner && (
+ <Alert
+ type="error"
+ message={
+ <>
+ <span className="top-nav-alert-msg">
+ Your setup process is incomplete. Now, that&apos;s a
+ bummer!
+ </span>
+ <a
+ href={onBoardUrl}
+ size="small"
+ type="text"
+ className="top-nav-alert-link"
+ >
+ Complete it to start using Unstract
+ </a>
+ </>
+ }
+ showIcon
+ />
)}
- <Dropdown menu={{ items }} placement="bottomLeft" arrow>
- <div className="top-navbar-dp">
- {sessionDetails?.picture ? (
- <Image
- className="navbar-img"
- height="100%"
- width="100%"
- preview={false}
- src={sessionDetails?.picture}
- />
- ) : (
- <Typography.Text className="initials">
- {getInitials(sessionDetails?.name)}
- </Typography.Text>
+ </Col>
+ <Col span={4}>
+ <Row justify="end" align="middle">
+ <Space>
+ {isUnstract && TrialDaysInfo && (
+ <TrialDaysInfo remainingTrialDays={remainingTrialDays} />
)}
- </div>
- </Dropdown>
- </Space>
- </Row>
- </Col>
+ <Dropdown menu={{ items }} placement="bottomLeft" arrow>
+ <div className="top-navbar-dp">
+ {sessionDetails?.picture ? (
+ <Image
+ className="navbar-img"
+ height="100%"
+ width="100%"
+ preview={false}
+ src={sessionDetails?.picture}
+ />
+ ) : (
+ <Typography.Text className="initials">
+ {getInitials(sessionDetails?.name)}
+ </Typography.Text>
+ )}
+ </div>
+ </Dropdown>
+ </Space>
+ </Row>
+ </Col>
+ </>
+ )}
</Row>
);
}
+TopNavBar.propTypes = {
+ isSimpleLayout: PropTypes.bool,
+};
+
export { TopNavBar };
diff --git a/frontend/src/components/set-org/SetOrg.jsx b/frontend/src/components/set-org/SetOrg.jsx
index ff5a3a6aa..0c342f04d 100644
--- a/frontend/src/components/set-org/SetOrg.jsx
+++ b/frontend/src/components/set-org/SetOrg.jsx
@@ -5,6 +5,7 @@ import { useLocation, useNavigate } from "react-router-dom";
import "./SetOrg.css"; // Import your CSS file for styling
import axios from "axios";
import Proptypes from "prop-types";
+
import {
OrgAvatar,
OrgSelection,
diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.js
index ef76a50a0..262a131a9 100644
--- a/frontend/src/helpers/GetStaticData.js
+++ b/frontend/src/helpers/GetStaticData.js
@@ -27,7 +27,7 @@ const getBaseUrl = () => {
return url;
};
-const getOrgNameFromPathname = (pathname) => {
+const getOrgNameFromPathname = (pathname, isUnstract = true) => {
if (!pathname) {
return null;
}
@@ -35,6 +35,10 @@ const getOrgNameFromPathname = (pathname) => {
if (publicRoutes.includes(pathname)) {
return null;
}
+
+ if (!isUnstract) {
+ return pathname?.split("/")[2];
+ }
return pathname?.split("/")[1];
};
diff --git a/frontend/src/hooks/useLogout.js b/frontend/src/hooks/useLogout.js
index 1395dc905..cdcedbdb2 100644
--- a/frontend/src/hooks/useLogout.js
+++ b/frontend/src/hooks/useLogout.js
@@ -15,6 +15,7 @@ function useLogout() {
return () => {
setSessionDetails(getSessionData(null));
+ localStorage.removeItem("selectedProduct");
posthog.reset();
clearSessionCookies();
const baseUrl = getBaseUrl();
diff --git a/frontend/src/hooks/useSessionValid.js b/frontend/src/hooks/useSessionValid.js
index d9a4ebb21..cf7b202f4 100644
--- a/frontend/src/hooks/useSessionValid.js
+++ b/frontend/src/hooks/useSessionValid.js
@@ -8,7 +8,6 @@ import { useSessionStore } from "../store/session-store";
import { useUserSession } from "./useUserSession.js";
import { listFlags } from "../helpers/FeatureFlagsData.js";
import { useAlertStore } from "../store/alert-store";
-import useLogout from "./useLogout.js";
let getTrialDetails;
let isPlatformAdmin;
@@ -29,17 +28,43 @@ try {
// Ignore if hook not available
}
+let selectedProduct;
+let selectedProductStore;
+
+try {
+ selectedProductStore = require("../plugins/llm-whisperer/store/select-product-store.js");
+} catch {
+ // Ignore if hook not available
+}
function useSessionValid() {
const setSessionDetails = useSessionStore((state) => state.setSessionDetails);
const handleException = useExceptionHandler();
const { setAlertDetails } = useAlertStore();
const navigate = useNavigate();
const userSession = useUserSession();
- const logout = useLogout();
+ try {
+ if (selectedProductStore?.useSelectedProductStore) {
+ selectedProduct = selectedProductStore?.useSelectedProductStore(
+ (state) => state?.selectedProduct
+ );
+ }
+ } catch (error) {
+ // Do nothing
+ }
+ const navToSelectProduct = (
+ userSessionData,
+ selectedProductStore,
+ selectedProduct
+ ) => {
+ if (userSessionData && selectedProductStore && !selectedProduct) {
+ navigate("/selectProduct");
+ return true; // Indicate that navigation has occurred
+ }
+ return false;
+ };
return async () => {
try {
- const timestamp = new Date().getTime();
const userSessionData = await userSession();
// Return if the user is not authenticated
@@ -48,11 +73,20 @@ function useSessionValid() {
}
const signedInOrgId = userSessionData?.organization_id;
+ const shouldNavigate = navToSelectProduct(
+ userSessionData,
+ selectedProductStore,
+ selectedProduct
+ );
+ if (shouldNavigate) {
+ return; // Exit early, don't run the remaining steps
+ }
+ const isUnstract = !(selectedProduct && selectedProduct !== "unstract");
// API to get the list of organizations
const requestOptions = {
method: "GET",
- url: `/api/v1/organization?q=${timestamp}`,
+ url: "/api/v1/organization",
};
const getOrgsRes = await axios(requestOptions);
const orgs = getOrgsRes?.data?.organizations;
@@ -67,15 +101,9 @@ function useSessionValid() {
const orgId = signedInOrgId || orgs[0].id;
const csrfToken = Cookies.get("csrftoken");
- if (!orgId || !csrfToken) {
- throw Error("Required fields are missing.");
- }
-
// API to set the organization and get the user details
requestOptions["method"] = "POST";
- requestOptions[
- "url"
- ] = `/api/v1/organization/${orgId}/set?q=${timestamp}`;
+ requestOptions["url"] = `/api/v1/organization/${orgId}/set`;
requestOptions["headers"] = {
"X-CSRFToken": csrfToken,
};
@@ -99,9 +127,7 @@ function useSessionValid() {
requestOptions["method"] = "GET";
- requestOptions[
- "url"
- ] = `/api/v1/unstract/${orgId}/users/profile/?q=${timestamp}`;
+ requestOptions["url"] = `/api/v1/unstract/${orgId}/users/profile/`;
requestOptions["headers"] = {
"X-CSRFToken": csrfToken,
};
@@ -117,24 +143,25 @@ function useSessionValid() {
.pop()
.split(";")[0];
userAndOrgDetails["zCode"] = zCode;
+ if (isUnstract) {
+ requestOptions["method"] = "GET";
+
+ requestOptions["url"] = `/api/v1/unstract/${orgId}/adapter/`;
+ requestOptions["headers"] = {
+ "X-CSRFToken": csrfToken,
+ };
+ const getAdapterDetails = await axios(requestOptions);
+ const adapterTypes = [
+ ...new Set(
+ getAdapterDetails?.data?.map((obj) =>
+ obj.adapter_type.toLowerCase()
+ )
+ ),
+ ];
+ userAndOrgDetails["adapters"] = adapterTypes;
+ }
- requestOptions["method"] = "GET";
-
- requestOptions[
- "url"
- ] = `/api/v1/unstract/${orgId}/adapter/?q=${timestamp}`;
- requestOptions["headers"] = {
- "X-CSRFToken": csrfToken,
- };
- const getAdapterDetails = await axios(requestOptions);
- const adapterTypes = [
- ...new Set(
- getAdapterDetails?.data?.map((obj) => obj.adapter_type.toLowerCase())
- ),
- ];
- userAndOrgDetails["adapters"] = adapterTypes;
-
- if (getTrialDetails) {
+ if (getTrialDetails && isUnstract) {
const remainingTrialDays = await getTrialDetails.fetchTrialDetails(
orgId,
csrfToken
@@ -143,8 +170,10 @@ function useSessionValid() {
userAndOrgDetails["remainingTrialDays"] = remainingTrialDays;
}
- const flags = await listFlags(orgId, csrfToken);
- userAndOrgDetails["flags"] = flags;
+ if (isUnstract) {
+ const flags = await listFlags(orgId, csrfToken);
+ userAndOrgDetails["flags"] = flags;
+ }
userAndOrgDetails["allOrganization"] = orgs;
if (isPlatformAdmin) {
@@ -154,10 +183,10 @@ function useSessionValid() {
// Set the session details
setSessionDetails(getSessionData(userAndOrgDetails));
} catch (err) {
- setAlertDetails(handleException(err));
+ // TODO: Throw popup error message
+ // REVIEW: Add condition to check for trial period status
if (err.response?.status === 402) {
handleException(err);
- return;
}
if (err.request?.status === 412) {
@@ -166,10 +195,8 @@ function useSessionValid() {
const code = response.code;
window.location.href = `/error?code=${code}&domain=${domainName}`;
// May be need a logout button there or auto logout
- return;
}
-
- logout();
+ setAlertDetails(handleException(err));
}
};
}
diff --git a/frontend/src/layouts/page-layout/PageLayout.jsx b/frontend/src/layouts/page-layout/PageLayout.jsx
index def141962..aa15e9d65 100644
--- a/frontend/src/layouts/page-layout/PageLayout.jsx
+++ b/frontend/src/layouts/page-layout/PageLayout.jsx
@@ -2,12 +2,13 @@ import { LeftOutlined, RightOutlined } from "@ant-design/icons";
import { Button, Layout } from "antd";
import { useEffect, useState } from "react";
import { Outlet } from "react-router-dom";
+import PropTypes from "prop-types";
import "./PageLayout.css";
import SideNavBar from "../../components/navigations/side-nav-bar/SideNavBar.jsx";
import { TopNavBar } from "../../components/navigations/top-nav-bar/TopNavBar.jsx";
-function PageLayout() {
+function PageLayout({ sideBarOptions, topNavBarOptions }) {
const initialCollapsedValue =
JSON.parse(localStorage.getItem("collapsed")) || false;
const [collapsed, setCollapsed] = useState(initialCollapsedValue);
@@ -17,9 +18,9 @@ function PageLayout() {
return (
<div className="landingPage">
- <TopNavBar />
+ <TopNavBar {...topNavBarOptions} />
<Layout>
- <SideNavBar collapsed={collapsed} />
+ <SideNavBar collapsed={collapsed} {...sideBarOptions} />
<Layout>
<Button
shape="circle"
@@ -34,5 +35,9 @@ function PageLayout() {
</div>
);
}
+PageLayout.propTypes = {
+ sideBarOptions: PropTypes.any,
+ topNavBarOptions: PropTypes.any,
+};
export { PageLayout };
diff --git a/frontend/src/routes/Router.jsx b/frontend/src/routes/Router.jsx
index 5966a383a..455294dca 100644
--- a/frontend/src/routes/Router.jsx
+++ b/frontend/src/routes/Router.jsx
@@ -3,62 +3,33 @@ import { Route, Routes } from "react-router-dom";
import { GenericError } from "../components/error/GenericError/GenericError.jsx";
import { NotFound } from "../components/error/NotFound/NotFound.jsx";
import { PersistentLogin } from "../components/helpers/auth/PersistentLogin.js";
-import { RequireAdmin } from "../components/helpers/auth/RequireAdmin.js";
-import { RequireAuth } from "../components/helpers/auth/RequireAuth.js";
import { RequireGuest } from "../components/helpers/auth/RequireGuest.js";
-import { CustomToolsHelper } from "../components/helpers/custom-tools/CustomToolsHelper.js";
-import { ProjectHelper } from "../components/helpers/project/ProjectHelper.js";
import { OAuthStatus } from "../components/oauth-ds/oauth-status/OAuthStatus.jsx";
-import { DefaultTriad } from "../components/settings/default-triad/DefaultTriad.jsx";
-import { PlatformSettings } from "../components/settings/platform/PlatformSettings.jsx";
-import { deploymentTypes } from "../helpers/GetStaticData.js";
-import { FullPageLayout } from "../layouts/fullpage-payout/FullPageLayout.jsx";
-import { PageLayout } from "../layouts/page-layout/PageLayout.jsx";
-import { AgencyPage } from "../pages/AgencyPage.jsx";
-import { CustomTools } from "../pages/CustomTools.jsx";
-import { DeploymentsPage } from "../pages/DeploymentsPage.jsx";
-import { InviteEditUserPage } from "../pages/InviteEditUserPage.jsx";
import { LandingPage } from "../pages/LandingPage.jsx";
-import { OnBoardPage } from "../pages/OnBoardPage.jsx";
-import { OutputAnalyzerPage } from "../pages/OutputAnalyzerPage.jsx";
-import { ProfilePage } from "../pages/ProfilePage.jsx";
import { SetOrgPage } from "../pages/SetOrgPage.jsx";
-import { SettingsPage } from "../pages/SettingsPage.jsx";
+import { useMainAppRoutes } from "./useMainAppRoutes.js";
+import { RequireAuth } from "../components/helpers/auth/RequireAuth.js";
import { ToolIdePage } from "../pages/ToolIdePage.jsx";
-import { ToolsSettingsPage } from "../pages/ToolsSettingsPage.jsx";
-import { UsersPage } from "../pages/UsersPage.jsx";
-import { WorkflowsPage } from "../pages/WorkflowsPage.jsx";
+import { OutputAnalyzerPage } from "../pages/OutputAnalyzerPage.jsx";
let TrialRoutes;
-let RequirePlatformAdmin;
-let PlatformAdminPage;
-let AppDeployments;
-let ChatAppPage;
-let ChatAppLayout;
let ManualReviewPage;
let SimpleManualReviewPage;
let ReviewLayout;
let PublicPromptStudioHelper;
-let ManualReviewSettings;
+let PaymentSuccessful;
+let SelectProduct;
try {
TrialRoutes =
require("../plugins/subscription/trial-page/TrialEndPage.jsx").TrialEndPage;
- RequirePlatformAdmin =
- require("../plugins/frictionless-onboard/RequirePlatformAdmin.jsx").RequirePlatformAdmin;
- PlatformAdminPage =
- require("../plugins/frictionless-onboard/platform-admin-page/PlatformAdminPage.jsx").PlatformAdminPage;
} catch (err) {
// Do nothing, Not-found Page will be triggered.
}
try {
- AppDeployments =
- require("../plugins/app-deployment/AppDeployments.jsx").AppDeployments;
- ChatAppPage =
- require("../plugins/app-deployment/chat-app/ChatAppPage.jsx").ChatAppPage;
- ChatAppLayout =
- require("../plugins/app-deployment/chat-app/ChatAppLayout.jsx").ChatAppLayout;
+ PaymentSuccessful =
+ require("../plugins/payment-successful/PaymentSuccessful.jsx").PaymentSuccessful;
} catch (err) {
// Do nothing, Not-found Page will be triggered.
}
@@ -68,8 +39,6 @@ try {
require("../plugins/manual-review/page/ManualReviewPage.jsx").ManualReviewPage;
ReviewLayout =
require("../plugins/manual-review/review-layout/ReviewLayout.jsx").ReviewLayout;
- ManualReviewSettings =
- require("../plugins/manual-review/settings/Settings.jsx").ManualReviewSettings;
SimpleManualReviewPage =
require("../plugins/manual-review/page/simple/SimpleManualReviewPage.jsx").SimpleManualReviewPage;
} catch (err) {
@@ -98,7 +67,23 @@ try {
} catch (err) {
// Do nothing, Not-found Page will be triggered.
}
+
+let llmWhispererRouter;
+try {
+ llmWhispererRouter =
+ require("../plugins/routes/useLlmWhispererRoutes.js").useLlmWhispererRoutes;
+} catch (err) {
+ // Do nothing, Not-found Page will be triggered.
+}
+
+try {
+ SelectProduct =
+ require("../plugins/select-product/SelectProduct.jsx").SelectProduct;
+} catch (err) {
+ // Do nothing, Not-found Page will be triggered.
+}
function Router() {
+ const MainAppRoute = useMainAppRoutes();
return (
<Routes>
<Route path="error" element={<GenericError />} />
@@ -140,84 +125,11 @@ function Router() {
{/* protected routes */}
<Route path="setOrg" element={<SetOrgPage />} />
+ <Route path="">{MainAppRoute}</Route>
+ {llmWhispererRouter && (
+ <Route path="llm-whisperer">{llmWhispererRouter()}</Route>
+ )}
<Route path="" element={<RequireAuth />}>
- <Route path=":orgName" element={<FullPageLayout />}>
- <Route path="onboard" element={<OnBoardPage />} />
- </Route>
- {ChatAppLayout && ChatAppPage && (
- <Route path=":orgName" element={<ChatAppLayout />}>
- <Route path="app/:id" element={<ChatAppPage />} />
- </Route>
- )}
- <Route path=":orgName" element={<PageLayout />}>
- <Route path="profile" element={<ProfilePage />} />
- <Route
- path="api"
- element={<DeploymentsPage type={deploymentTypes.api} />}
- />
- <Route
- path="etl"
- element={<DeploymentsPage type={deploymentTypes.etl} />}
- />
- <Route
- path="task"
- element={<DeploymentsPage type={deploymentTypes.task} />}
- />
- {AppDeployments && (
- <Route path="app" element={<AppDeployments type="app" />} />
- )}
- <Route path="workflows" element={<WorkflowsPage />} />
- <Route path="workflows/:id" element={<ProjectHelper />}>
- <Route path="" element={<AgencyPage />} />
- </Route>
- <Route path="tools" element={<CustomTools />} />
- <Route path="" element={<CustomToolsHelper />}>
- <Route path="tools/:id" element={<ToolIdePage />} />
- <Route
- path="tools/:id/outputAnalyzer"
- element={<OutputAnalyzerPage />}
- />
- </Route>
- <Route
- path="settings/llms"
- element={<ToolsSettingsPage type="llm" />}
- />
- <Route
- path="settings/vectorDbs"
- element={<ToolsSettingsPage type="vector_db" />}
- />
- <Route
- path="settings/embedding"
- element={<ToolsSettingsPage type="embedding" />}
- />
- <Route
- path="settings/textExtractor"
- element={<ToolsSettingsPage type="x2text" />}
- />
- <Route
- path="settings/ocr"
- element={<ToolsSettingsPage type="ocr" />}
- />
- <Route path="settings" element={<SettingsPage />} />
- {ManualReviewSettings && (
- <Route
- path="settings/review"
- element={<ManualReviewSettings />}
- />
- )}
- <Route path="settings/platform" element={<PlatformSettings />} />
- <Route element={<RequireAdmin />}>
- <Route path="users" element={<UsersPage />} />
- <Route path="users/invite" element={<InviteEditUserPage />} />
- <Route path="users/edit" element={<InviteEditUserPage />} />
- </Route>
- <Route path="settings/triad" element={<DefaultTriad />} />
- {RequirePlatformAdmin && PlatformAdminPage && (
- <Route element={<RequirePlatformAdmin />}>
- <Route path="settings/admin" element={<PlatformAdminPage />} />
- </Route>
- )}
- </Route>
{ReviewLayout && ManualReviewPage && (
<Route path=":orgName" element={<ReviewLayout />}>
<Route
@@ -249,6 +161,12 @@ function Router() {
<Route path="*" element={<NotFound />} />
</Route>
<Route path="oauth-status" element={<OAuthStatus />} />
+ {SelectProduct && (
+ <Route path="selectProduct" element={<SelectProduct />} />
+ )}
+ {PaymentSuccessful && (
+ <Route path="/payment/success" element={<PaymentSuccessful />} />
+ )}
</Routes>
);
}
diff --git a/frontend/src/routes/useMainAppRoutes.js b/frontend/src/routes/useMainAppRoutes.js
new file mode 100644
index 000000000..a0c88a1c3
--- /dev/null
+++ b/frontend/src/routes/useMainAppRoutes.js
@@ -0,0 +1,137 @@
+import { Route } from "react-router-dom";
+
+import { OnBoardPage } from "../pages/OnBoardPage.jsx";
+import { FullPageLayout } from "../layouts/fullpage-payout/FullPageLayout.jsx";
+import { ToolsSettingsPage } from "../pages/ToolsSettingsPage.jsx";
+import { SettingsPage } from "../pages/SettingsPage.jsx";
+import { PlatformSettings } from "../components/settings/platform/PlatformSettings.jsx";
+import { RequireAdmin } from "../components/helpers/auth/RequireAdmin.js";
+import { UsersPage } from "../pages/UsersPage.jsx";
+import { InviteEditUserPage } from "../pages/InviteEditUserPage.jsx";
+import { DefaultTriad } from "../components/settings/default-triad/DefaultTriad.jsx";
+import { PageLayout } from "../layouts/page-layout/PageLayout.jsx";
+import { ProfilePage } from "../pages/ProfilePage.jsx";
+import { DeploymentsPage } from "../pages/DeploymentsPage.jsx";
+import { WorkflowsPage } from "../pages/WorkflowsPage.jsx";
+import { ProjectHelper } from "../components/helpers/project/ProjectHelper.js";
+import { AgencyPage } from "../pages/AgencyPage.jsx";
+import { CustomTools } from "../pages/CustomTools.jsx";
+import { CustomToolsHelper } from "../components/helpers/custom-tools/CustomToolsHelper.js";
+import { ToolIdePage } from "../pages/ToolIdePage.jsx";
+import { OutputAnalyzerPage } from "../pages/OutputAnalyzerPage.jsx";
+import { deploymentTypes } from "../helpers/GetStaticData.js";
+import { RequireAuth } from "../components/helpers/auth/RequireAuth.js";
+
+let RequirePlatformAdmin;
+let PlatformAdminPage;
+let AppDeployments;
+let ChatAppPage;
+let ChatAppLayout;
+let ManualReviewSettings;
+
+try {
+ RequirePlatformAdmin =
+ require("../plugins/frictionless-onboard/RequirePlatformAdmin.jsx").RequirePlatformAdmin;
+ PlatformAdminPage =
+ require("../plugins/frictionless-onboard/platform-admin-page/PlatformAdminPage.jsx").PlatformAdminPage;
+} catch (err) {
+ // Do nothing, Not-found Page will be triggered.
+}
+
+try {
+ AppDeployments =
+ require("../plugins/app-deployment/AppDeployments.jsx").AppDeployments;
+ ChatAppPage =
+ require("../plugins/app-deployment/chat-app/ChatAppPage.jsx").ChatAppPage;
+ ChatAppLayout =
+ require("../plugins/app-deployment/chat-app/ChatAppLayout.jsx").ChatAppLayout;
+} catch (err) {
+ // Do nothing, Not-found Page will be triggered.
+}
+
+try {
+ ManualReviewSettings =
+ require("../plugins/manual-review/settings/Settings.jsx").ManualReviewSettings;
+} catch (err) {
+ // Do nothing, Not-found Page will be triggered.
+}
+
+function useMainAppRoutes() {
+ return (
+ <Route path="" element={<RequireAuth />}>
+ <Route path=":orgName" element={<FullPageLayout />}>
+ <Route path="onboard" element={<OnBoardPage />} />
+ </Route>
+ {ChatAppLayout && ChatAppPage && (
+ <Route path=":orgName" element={<ChatAppLayout />}>
+ <Route path="app/:id" element={<ChatAppPage />} />
+ </Route>
+ )}
+ <Route path=":orgName" element={<PageLayout />}>
+ <Route path="profile" element={<ProfilePage />} />
+ <Route
+ path="api"
+ element={<DeploymentsPage type={deploymentTypes.api} />}
+ />
+ <Route
+ path="etl"
+ element={<DeploymentsPage type={deploymentTypes.etl} />}
+ />
+ <Route
+ path="task"
+ element={<DeploymentsPage type={deploymentTypes.task} />}
+ />
+ {AppDeployments && (
+ <Route path="app" element={<AppDeployments type="app" />} />
+ )}
+ <Route path="workflows" element={<WorkflowsPage />} />
+ <Route path="workflows/:id" element={<ProjectHelper />}>
+ <Route path="" element={<AgencyPage />} />
+ </Route>
+ <Route path="tools" element={<CustomTools />} />
+ <Route path="" element={<CustomToolsHelper />}>
+ <Route path="tools/:id" element={<ToolIdePage />} />
+ <Route
+ path="tools/:id/outputAnalyzer"
+ element={<OutputAnalyzerPage />}
+ />
+ </Route>
+ <Route
+ path="settings/llms"
+ element={<ToolsSettingsPage type="llm" />}
+ />
+ <Route
+ path="settings/vectorDbs"
+ element={<ToolsSettingsPage type="vector_db" />}
+ />
+ <Route
+ path="settings/embedding"
+ element={<ToolsSettingsPage type="embedding" />}
+ />
+ <Route
+ path="settings/textExtractor"
+ element={<ToolsSettingsPage type="x2text" />}
+ />
+ <Route path="settings/ocr" element={<ToolsSettingsPage type="ocr" />} />
+ <Route path="settings" element={<SettingsPage />} />
+ {ManualReviewSettings && (
+ <Route path="settings/review" element={<ManualReviewSettings />} />
+ )}
+ <Route path="settings/platform" element={<PlatformSettings />} />
+ <Route element={<RequireAdmin />}>
+ <Route path="users" element={<UsersPage />} />
+ <Route path="users/invite" element={<InviteEditUserPage />} />
+ <Route path="users/edit" element={<InviteEditUserPage />} />
+ </Route>
+ <Route path="settings/triad" element={<DefaultTriad />} />
+ {RequirePlatformAdmin && PlatformAdminPage && (
+ <Route element={<RequirePlatformAdmin />}>
+ <Route path="settings/admin" element={<PlatformAdminPage />} />
+ </Route>
+ )}
+ </Route>
+ </Route>
+ );
+}
+
+export { useMainAppRoutes };