diff --git a/src/frontend/src/modals/baseModal/helpers/switch-case-size.ts b/src/frontend/src/modals/baseModal/helpers/switch-case-size.ts
new file mode 100644
index 000000000..35004c2ec
--- /dev/null
+++ b/src/frontend/src/modals/baseModal/helpers/switch-case-size.ts
@@ -0,0 +1,67 @@
+export const switchCaseModalSize = (size: string) => {
+ let minWidth: string;
+ let height: string;
+ switch (size) {
+ case "x-small":
+ minWidth = "min-w-[20vw]";
+ height = "h-full";
+ break;
+ case "smaller":
+ minWidth = "min-w-[40vw]";
+ height = "h-[11rem]";
+ break;
+ case "smaller-h-full":
+ minWidth = "min-w-[40vw]";
+ height = "h-full";
+ break;
+ case "small":
+ minWidth = "min-w-[40vw]";
+ height = "h-[40vh]";
+ break;
+ case "small-h-full":
+ minWidth = "min-w-[40vw]";
+ height = "h-full";
+ break;
+ case "medium":
+ minWidth = "min-w-[60vw]";
+ height = "h-[60vh]";
+ break;
+ case "medium-h-full":
+ minWidth = "min-w-[60vw]";
+ height = "h-full";
+
+ break;
+ case "large":
+ minWidth = "min-w-[85vw]";
+ height = "h-[80vh]";
+ break;
+ case "three-cards":
+ minWidth = "min-w-[1066px]";
+ height = "h-fit";
+ break;
+ case "large-thin":
+ minWidth = "min-w-[65vw]";
+ height = "h-[80vh]";
+ break;
+
+ case "md-thin":
+ minWidth = "min-w-[85vw]";
+ height = "h-[70vh]";
+ break;
+
+ case "sm-thin":
+ minWidth = "min-w-[65vw]";
+ height = "h-[70vh]";
+ break;
+
+ case "large-h-full":
+ minWidth = "min-w-[80vw]";
+ height = "h-full";
+ break;
+ default:
+ minWidth = "min-w-[80vw]";
+ height = "h-[80vh]";
+ break;
+ }
+ return { minWidth, height };
+};
diff --git a/src/frontend/src/modals/baseModal/index.tsx b/src/frontend/src/modals/baseModal/index.tsx
index 2b1c67db7..a53aab173 100644
--- a/src/frontend/src/modals/baseModal/index.tsx
+++ b/src/frontend/src/modals/baseModal/index.tsx
@@ -16,10 +16,10 @@ import {
} from "../../components/ui/dialog-with-no-close";
import { DialogClose } from "@radix-ui/react-dialog";
-import ForwardedIconComponent from "../../components/genericIconComponent";
import { Button } from "../../components/ui/button";
import { modalHeaderType } from "../../types/components";
import { cn } from "../../utils/utils";
+import { switchCaseModalSize } from "./helpers/switch-case-size";
type ContentProps = { children: ReactNode };
type HeaderProps = { children: ReactNode; description: string };
@@ -148,71 +148,7 @@ function BaseModal({
(child) => (child as React.ReactElement).type === Footer,
);
- let minWidth: string;
- let height: string;
-
- switch (size) {
- case "x-small":
- minWidth = "min-w-[20vw]";
- height = "h-full";
- break;
- case "smaller":
- minWidth = "min-w-[40vw]";
- height = "h-[11rem]";
- break;
- case "smaller-h-full":
- minWidth = "min-w-[40vw]";
- height = "h-full";
- break;
- case "small":
- minWidth = "min-w-[40vw]";
- height = "h-[40vh]";
- break;
- case "small-h-full":
- minWidth = "min-w-[40vw]";
- height = "h-full";
- break;
- case "medium":
- minWidth = "min-w-[60vw]";
- height = "h-[60vh]";
- break;
- case "medium-h-full":
- minWidth = "min-w-[60vw]";
- height = "h-full";
-
- break;
- case "large":
- minWidth = "min-w-[85vw]";
- height = "h-[80vh]";
- break;
- case "three-cards":
- minWidth = "min-w-[1066px]";
- height = "h-fit";
- break;
- case "large-thin":
- minWidth = "min-w-[65vw]";
- height = "h-[80vh]";
- break;
-
- case "md-thin":
- minWidth = "min-w-[85vw]";
- height = "h-[70vh]";
- break;
-
- case "sm-thin":
- minWidth = "min-w-[65vw]";
- height = "h-[70vh]";
- break;
-
- case "large-h-full":
- minWidth = "min-w-[80vw]";
- height = "h-full";
- break;
- default:
- minWidth = "min-w-[80vw]";
- height = "h-[80vh]";
- break;
- }
+ let { minWidth, height } = switchCaseModalSize(size);
useEffect(() => {
if (onChangeOpenModal) {
diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/GeneralPageHeader/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/GeneralPageHeader/index.tsx
new file mode 100644
index 000000000..cb65942bd
--- /dev/null
+++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/GeneralPageHeader/index.tsx
@@ -0,0 +1,23 @@
+import ForwardedIconComponent from "../../../../../../components/genericIconComponent";
+
+const GeneralPageHeaderComponent = () => {
+ return (
+ <>
+
+
+
+ General
+
+
+
+ Manage settings related to Langflow and your account.
+
+
+
+ >
+ );
+};
+export default GeneralPageHeaderComponent;
diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/PasswordForm/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/PasswordForm/index.tsx
new file mode 100644
index 000000000..28edb2f09
--- /dev/null
+++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/PasswordForm/index.tsx
@@ -0,0 +1,93 @@
+import * as Form from "@radix-ui/react-form";
+import InputComponent from "../../../../../../components/inputComponent";
+import { Button } from "../../../../../../components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "../../../../../../components/ui/card";
+
+type PasswordFormComponentProps = {
+ password: string;
+ cnfPassword: string;
+ handleInput: (event: any) => void;
+ handlePatchPassword: (
+ password: string,
+ cnfPassword: string,
+ handleInput: any,
+ ) => void;
+};
+const PasswordFormComponent = ({
+ password,
+ cnfPassword,
+ handleInput,
+ handlePatchPassword,
+}: PasswordFormComponentProps) => {
+ return (
+ <>
+ {
+ handlePatchPassword(password, cnfPassword, handleInput);
+ event.preventDefault();
+ }}
+ >
+
+
+ Password
+
+ Type your new password and confirm it.
+
+
+
+
+
+ {
+ handleInput({ target: { name: "password", value } });
+ }}
+ value={password}
+ isForm
+ password={true}
+ placeholder="Password"
+ className="w-full"
+ />
+
+ Please enter your password
+
+
+
+ {
+ handleInput({
+ target: { name: "cnfPassword", value },
+ });
+ }}
+ value={cnfPassword}
+ isForm
+ password={true}
+ placeholder="Confirm Password"
+ className="w-full"
+ />
+
+
+ Please confirm your password
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default PasswordFormComponent;
diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx
new file mode 100644
index 000000000..a92a00103
--- /dev/null
+++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/ProfileGradientForm/index.tsx
@@ -0,0 +1,68 @@
+import * as Form from "@radix-ui/react-form";
+import GradientChooserComponent from "../../../../../../components/gradientChooserComponent";
+import { Button } from "../../../../../../components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "../../../../../../components/ui/card";
+import { gradients } from "../../../../../../utils/styleUtils";
+
+type ProfileGradientFormComponentProps = {
+ gradient: string;
+ handleInput: (event: any) => void;
+ handlePatchGradient: (gradient: string) => void;
+ userData: any;
+};
+const ProfileGradientFormComponent = ({
+ gradient,
+ handleInput,
+ handlePatchGradient,
+ userData,
+}: ProfileGradientFormComponentProps) => {
+ return (
+ <>
+ {
+ handlePatchGradient(gradient);
+ event.preventDefault();
+ }}
+ >
+
+
+ Profile Gradient
+
+ Choose the gradient that appears as your profile picture.
+
+
+
+
+ {
+ handleInput({ target: { name: "gradient", value } });
+ }}
+ />
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default ProfileGradientFormComponent;
diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/StoreApiKeyForm/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/StoreApiKeyForm/index.tsx
new file mode 100644
index 000000000..5bc5ea38b
--- /dev/null
+++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/components/StoreApiKeyForm/index.tsx
@@ -0,0 +1,102 @@
+import * as Form from "@radix-ui/react-form";
+import InputComponent from "../../../../../../components/inputComponent";
+import { Button } from "../../../../../../components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "../../../../../../components/ui/card";
+import {
+ CREATE_API_KEY,
+ INSERT_API_KEY,
+ INVALID_API_KEY,
+ NO_API_KEY,
+} from "../../../../../../constants/constants";
+
+type StoreApiKeyFormComponentProps = {
+ apikey: string;
+ handleInput: (event: any) => void;
+ handleSaveKey: (apikey: string, handleInput: any) => void;
+ loadingApiKey: boolean;
+ validApiKey: boolean;
+ hasApiKey: boolean;
+};
+const StoreApiKeyFormComponent = ({
+ apikey,
+ handleInput,
+ handleSaveKey,
+ loadingApiKey,
+ validApiKey,
+ hasApiKey,
+}: StoreApiKeyFormComponentProps) => {
+ return (
+ <>
+ {
+ event.preventDefault();
+ handleSaveKey(apikey, handleInput);
+ }}
+ >
+
+
+ Store API Key
+
+ {(hasApiKey && !validApiKey
+ ? INVALID_API_KEY
+ : !hasApiKey
+ ? NO_API_KEY
+ : "") + INSERT_API_KEY}
+
+
+
+
+
+
+ {
+ handleInput({ target: { name: "apikey", value } });
+ }}
+ value={apikey}
+ isForm
+ password={true}
+ placeholder="Insert your API Key"
+ className="w-full"
+ />
+
+ Please enter your API Key
+
+
+
+
+ {CREATE_API_KEY}{" "}
+
+ langflow.store
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+export default StoreApiKeyFormComponent;
diff --git a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx
index 755e7959c..718097152 100644
--- a/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx
+++ b/src/frontend/src/pages/SettingsPage/pages/GeneralPage/index.tsx
@@ -1,25 +1,6 @@
-import * as Form from "@radix-ui/react-form";
import { useContext, useState } from "react";
import { useParams } from "react-router-dom";
-import ForwardedIconComponent from "../../../../components/genericIconComponent";
-import GradientChooserComponent from "../../../../components/gradientChooserComponent";
-import InputComponent from "../../../../components/inputComponent";
-import { Button } from "../../../../components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
-} from "../../../../components/ui/card";
-import {
- CONTROL_PATCH_USER_STATE,
- CREATE_API_KEY,
- INSERT_API_KEY,
- INVALID_API_KEY,
- NO_API_KEY,
-} from "../../../../constants/constants";
+import { CONTROL_PATCH_USER_STATE } from "../../../../constants/constants";
import { AuthContext } from "../../../../contexts/authContext";
import useAlertStore from "../../../../stores/alertStore";
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
@@ -28,21 +9,24 @@ import {
inputHandlerEventType,
patchUserInputStateType,
} from "../../../../types/components";
-import { gradients } from "../../../../utils/styleUtils";
import usePatchGradient from "../hooks/use-patch-gradient";
import usePatchPassword from "../hooks/use-patch-password";
import useSaveKey from "../hooks/use-save-key";
import useScrollToElement from "../hooks/use-scroll-to-element";
+import GeneralPageHeaderComponent from "./components/GeneralPageHeader";
+import PasswordFormComponent from "./components/PasswordForm";
+import ProfileGradientFormComponent from "./components/ProfileGradientForm";
+import StoreApiKeyFormComponent from "./components/StoreApiKeyForm";
export default function GeneralPage() {
const setCurrentFlowId = useFlowsManagerStore(
- (state) => state.setCurrentFlowId
+ (state) => state.setCurrentFlowId,
);
const { scrollId } = useParams();
const [inputState, setInputState] = useState(
- CONTROL_PATCH_USER_STATE
+ CONTROL_PATCH_USER_STATE,
);
const { autoLogin } = useContext(AuthContext);
@@ -63,14 +47,14 @@ export default function GeneralPage() {
const { handlePatchPassword } = usePatchPassword(
userData,
setSuccessData,
- setErrorData
+ setErrorData,
);
const { handlePatchGradient } = usePatchGradient(
setSuccessData,
setErrorData,
userData,
- setUserData
+ setUserData,
);
useScrollToElement(scrollId, setCurrentFlowId);
@@ -80,7 +64,7 @@ export default function GeneralPage() {
setErrorData,
setHasApiKey,
setValidApiKey,
- setLoadingApiKey
+ setLoadingApiKey,
);
function handleInput({
@@ -91,192 +75,33 @@ export default function GeneralPage() {
return (
-
-
-
- General
-
-
-
- Manage settings related to Langflow and your account.
-
-
-
+
-
{
- handlePatchGradient(gradient);
- event.preventDefault();
- }}
- >
-
-
- Profile Gradient
-
- Choose the gradient that appears as your profile picture.
-
-
-
-
- {
- handleInput({ target: { name: "gradient", value } });
- }}
- />
-
-
-
-
-
-
-
-
-
- {!autoLogin && (
-
{
- handlePatchPassword(password, cnfPassword, handleInput);
- event.preventDefault();
- }}
- >
-
-
- Password
-
- Type your new password and confirm it.
-
-
-
-
-
- {
- handleInput({ target: { name: "password", value } });
- }}
- value={password}
- isForm
- password={true}
- placeholder="Password"
- className="w-full"
- />
-
- Please enter your password
-
-
-
- {
- handleInput({
- target: { name: "cnfPassword", value },
- });
- }}
- value={cnfPassword}
- isForm
- password={true}
- placeholder="Confirm Password"
- className="w-full"
- />
+
-
- Please confirm your password
-
-
-
-
-
-
-
-
-
-
-
+ {!autoLogin && (
+
)}
{hasStore && (
-
{
- event.preventDefault();
- handleSaveKey(apikey, handleInput);
- }}
- >
-
-
- Store API Key
-
- {(hasApiKey && !validApiKey
- ? INVALID_API_KEY
- : !hasApiKey
- ? NO_API_KEY
- : "") + INSERT_API_KEY}
-
-
-
-
-
-
- {
- handleInput({ target: { name: "apikey", value } });
- }}
- value={apikey}
- isForm
- password={true}
- placeholder="Insert your API Key"
- className="w-full"
- />
-
- Please enter your API Key
-
-
-
-
- {CREATE_API_KEY}{" "}
-
- langflow.store
-
-
-
-
-
-
-
-
-
-
-
+
)}