Skip to content

Commit

Permalink
Merge branch 'main' into fix/unstructured_x2text
Browse files Browse the repository at this point in the history
  • Loading branch information
jaseemjaskp authored Jan 23, 2025
2 parents e057212 + 89697c4 commit c5a6bda
Show file tree
Hide file tree
Showing 33 changed files with 489 additions and 222 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/helpers/auth/RequireAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect } from "react";

import {
getOrgNameFromPathname,
homePagePath,
onboardCompleted,
} from "../../../helpers/GetStaticData";
import { useSessionStore } from "../../../store/session-store";
Expand Down Expand Up @@ -53,7 +54,7 @@ const RequireAuth = () => {
if (isLlmWhisperer) {
navigateTo = `/llm-whisperer/${orgName}/playground`;
} else if (onboardCompleted(adapters)) {
navigateTo = `/${orgName}/tools`;
navigateTo = `/${orgName}/${homePagePath}`;
}
if (
sessionDetails.role === "unstract_reviewer" ||
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/helpers/auth/RequireGuest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Navigate, Outlet, useLocation } from "react-router-dom";

import { publicRoutes, onboardCompleted } from "../../../helpers/GetStaticData";
import {
publicRoutes,
onboardCompleted,
homePagePath,
} from "../../../helpers/GetStaticData";
import { useSessionStore } from "../../../store/session-store";
let selectedProductStore;
let isLlmWhisperer;
Expand Down Expand Up @@ -28,7 +32,7 @@ const RequireGuest = () => {
if (isLlmWhisperer) {
navigateTo = `/llm-whisperer/${orgName}/playground`;
} else if (onboardCompleted(adapters)) {
navigateTo = `/${orgName}/tools`;
navigateTo = `/${orgName}/${homePagePath}`;
}
if (
sessionDetails.role === "unstract_reviewer" ||
Expand Down
37 changes: 36 additions & 1 deletion frontend/src/components/input-output/add-source/AddSource.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import { EmptyState } from "../../widgets/empty-state/EmptyState";
import { ConfigureDs } from "../configure-ds/ConfigureDs";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler";

let transformLlmWhispererJsonSchema;
let LLMW_V2_ID;
let PLAN_TYPES;
let unstractSubscriptionPlanStore;
try {
transformLlmWhispererJsonSchema =
require("../../../plugins/unstract-subscription/helper/transformLlmWhispererJsonSchema").transformLlmWhispererJsonSchema;
LLMW_V2_ID =
require("../../../plugins/unstract-subscription/helper/transformLlmWhispererJsonSchema").LLMW_V2_ID;
PLAN_TYPES =
require("../../../plugins/unstract-subscription/helper/constants").PLAN_TYPES;
unstractSubscriptionPlanStore = require("../../../plugins/store/unstract-subscription-plan-store");
} catch (err) {
// Ignore if not available
}

function AddSource({
selectedSourceId,
selectedSourceName,
Expand All @@ -32,6 +48,13 @@ function AddSource({
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();

let planType;
if (unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore) {
planType = unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore(
(state) => state?.unstractSubscriptionPlan?.planType
);
}

useEffect(() => {
if (!selectedSourceId) {
setSpec({});
Expand All @@ -56,7 +79,19 @@ function AddSource({
.then((res) => {
const data = res?.data;
setFormData(metadata || {});
setSpec(data?.json_schema || {});

if (
LLMW_V2_ID &&
transformLlmWhispererJsonSchema &&
PLAN_TYPES &&
selectedSourceId === LLMW_V2_ID &&
planType === PLAN_TYPES?.PAID
) {
setSpec(transformLlmWhispererJsonSchema(data?.json_schema || {}));
} else {
setSpec(data?.json_schema || {});
}

if (data?.oauth) {
setOAuthProvider(data?.python_social_auth_backend);
} else {
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ try {
// Plugin unavailable.
}

let dashboardSideMenuItem;
try {
dashboardSideMenuItem =
require("../../../plugins/unstract-subscription/helper/constants").dashboardSideMenuItem;
} catch (err) {
// Plugin unavailable.
}

const SideNavBar = ({ collapsed }) => {
const navigate = useNavigate();
const { sessionDetails } = useSessionStore();
Expand All @@ -40,7 +48,7 @@ const SideNavBar = ({ collapsed }) => {
menu = sideMenu.useSideMenu();
}

const data = menu || [
const unstractMenuItems = [
{
id: 1,
mainTitle: "MANAGE",
Expand Down Expand Up @@ -155,6 +163,12 @@ const SideNavBar = ({ collapsed }) => {
},
];

if (dashboardSideMenuItem) {
unstractMenuItems[2].subMenu.push(dashboardSideMenuItem(orgName));
}

const data = menu || unstractMenuItems;

if (getMenuItem && flags?.app_deployment) {
data[0]?.subMenu?.splice(1, 0, getMenuItem?.default(orgName));
}
Expand Down
Loading

0 comments on commit c5a6bda

Please sign in to comment.