From a653c58384a664dbe59cbd665f0573d51c10045b Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Wed, 3 Jan 2024 22:02:06 +0700 Subject: [PATCH] Revert back save button thread setting --- web/containers/Checkbox/index.tsx | 70 +-- web/containers/Layout/Ribbon/index.tsx | 131 +----- web/containers/Layout/TopBar/index.tsx | 2 +- web/containers/ModelConfigInput/index.tsx | 56 +-- web/containers/Slider/index.tsx | 68 +-- web/helpers/atoms/Thread.atom.ts | 2 - web/hooks/useUpdateModelParameters.ts | 9 +- web/screens/Chat/EngineSetting/index.tsx | 4 +- web/screens/Chat/ModelSetting/index.tsx | 4 +- .../ModelSetting/settingComponentBuilder.tsx | 80 +--- web/screens/Chat/Sidebar/index.tsx | 416 ++++++------------ web/screens/Chat/index.tsx | 11 +- 12 files changed, 219 insertions(+), 634 deletions(-) diff --git a/web/containers/Checkbox/index.tsx b/web/containers/Checkbox/index.tsx index b6fcb32c6..4c124021e 100644 --- a/web/containers/Checkbox/index.tsx +++ b/web/containers/Checkbox/index.tsx @@ -1,76 +1,32 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import React from 'react' -import { - Switch, - Tooltip, - TooltipArrow, - TooltipContent, - TooltipPortal, - TooltipTrigger, -} from '@janhq/uikit' +import { Switch } from '@janhq/uikit' -// import { useAtomValue } from 'jotai' +import { useAtomValue } from 'jotai' -import { InfoIcon } from 'lucide-react' +import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' -// import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' - -// import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' +import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' type Props = { name: string title: string - description: string - value: boolean checked: boolean - onBlur: () => void - onChange: (e: boolean) => void } -const Checkbox: React.FC = ({ - name, - value, - title, - checked, - description, - onChange, - onBlur, -}) => { - // const { updateModelParameter } = useUpdateModelParameters() - // const threadId = useAtomValue(getActiveThreadIdAtom) +const Checkbox: React.FC = ({ name, title, checked }) => { + const { updateModelParameter } = useUpdateModelParameters() + const threadId = useAtomValue(getActiveThreadIdAtom) - // const onCheckedChange = (checked: boolean) => { - // if (!threadId) return - - // updateModelParameter(threadId, name, checked) - // } + const onCheckedChange = (checked: boolean) => { + if (!threadId) return + updateModelParameter(threadId, name, checked) + } return (
-
-

- {title} -

- - - - - - - {description} - - - - -
- - onChange(e)} - onBlur={onBlur} - /> +

{title}

+
) } diff --git a/web/containers/Layout/Ribbon/index.tsx b/web/containers/Layout/Ribbon/index.tsx index 74f0c0813..208bd5a43 100644 --- a/web/containers/Layout/Ribbon/index.tsx +++ b/web/containers/Layout/Ribbon/index.tsx @@ -16,14 +16,13 @@ import { } from '@janhq/uikit' import { motion as m } from 'framer-motion' -import { useAtomValue } from 'jotai' import { MessageCircleIcon, SettingsIcon, MonitorIcon, LayoutGridIcon, - Twitter, - Github, + // Twitter, + // Github, } from 'lucide-react' import { twMerge } from 'tailwind-merge' @@ -34,13 +33,8 @@ import { MainViewState } from '@/constants/screens' import { useMainViewState } from '@/hooks/useMainViewState' -import { threadSettingFormUpdateAtom } from '@/helpers/atoms/Thread.atom' - export default function RibbonNav() { const { mainViewState, setMainViewState } = useMainViewState() - const threadSettingFormUpdate = useAtomValue(threadSettingFormUpdateAtom) - const [showModalUpdateThreadSetting, setshowModalUpdateThreadSetting] = - useState({ show: false, view: mainViewState }) const onMenuClick = (state: MainViewState) => { if (mainViewState === state) return @@ -70,22 +64,22 @@ export default function RibbonNav() { }, ] - const linksMenu = [ - { - name: 'Twitter', - icon: ( - - ), - link: 'https://twitter.com/janhq_', - }, - { - name: 'Github', - icon: ( - - ), - link: 'https://github.com/janhq/jan', - }, - ] + // const linksMenu = [ + // { + // name: 'Twitter', + // icon: ( + // + // ), + // link: 'https://twitter.com/janhq_', + // }, + // { + // name: 'Github', + // icon: ( + // + // ), + // link: 'https://github.com/janhq/jan', + // }, + // ] const secondaryMenus = [ { @@ -132,23 +126,7 @@ export default function RibbonNav() { 'relative flex w-full flex-shrink-0 cursor-pointer items-center justify-center', isActive && 'z-10' )} - onClick={() => { - if ( - threadSettingFormUpdate && - mainViewState === MainViewState.Thread - ) { - setshowModalUpdateThreadSetting({ - show: true, - view: primary.state, - }) - } else { - setshowModalUpdateThreadSetting({ - show: false, - view: mainViewState, - }) - onMenuClick(primary.state) - } - }} + onClick={() => onMenuClick(primary.state)} > {primary.icon} @@ -170,7 +148,8 @@ export default function RibbonNav() {
- <> + {/* Temporary hidden social media until we finalize design */} + {/* <> {linksMenu .filter((link) => !!link) .map((link, i) => { @@ -195,7 +174,8 @@ export default function RibbonNav() {
) })} - + */} + {secondaryMenus .filter((secondary) => !!secondary) .map((secondary, i) => { @@ -210,23 +190,7 @@ export default function RibbonNav() { 'relative flex w-full flex-shrink-0 cursor-pointer items-center justify-center', isActive && 'z-10' )} - onClick={() => { - if ( - threadSettingFormUpdate && - mainViewState === MainViewState.Thread - ) { - setshowModalUpdateThreadSetting({ - show: true, - view: secondary.state, - }) - } else { - setshowModalUpdateThreadSetting({ - show: false, - view: mainViewState, - }) - onMenuClick(secondary.state) - } - }} + onClick={() => onMenuClick(secondary.state)} > {secondary.icon} @@ -248,53 +212,6 @@ export default function RibbonNav() { - - - setshowModalUpdateThreadSetting({ - show: false, - view: mainViewState, - }) - } - > - - - -
Unsave changes
-
- -

- You have unsave changes. Are you sure you want to leave this - page? -

-
-
- -
- - - - -
-
-
-
) } diff --git a/web/containers/Layout/TopBar/index.tsx b/web/containers/Layout/TopBar/index.tsx index dd5358d82..c830c84e3 100644 --- a/web/containers/Layout/TopBar/index.tsx +++ b/web/containers/Layout/TopBar/index.tsx @@ -181,7 +181,7 @@ const TopBar = () => { />
- View as JSON + Edit Threads Settings Opens thread.json. Changes affect this thread diff --git a/web/containers/ModelConfigInput/index.tsx b/web/containers/ModelConfigInput/index.tsx index 56b8d8edd..caa4f7fa3 100644 --- a/web/containers/ModelConfigInput/index.tsx +++ b/web/containers/ModelConfigInput/index.tsx @@ -1,71 +1,39 @@ -import { - Textarea, - Tooltip, - TooltipPortal, - TooltipArrow, - TooltipContent, - TooltipTrigger, -} from '@janhq/uikit' +import { Textarea } from '@janhq/uikit' -// import { useAtomValue } from 'jotai' +import { useAtomValue } from 'jotai' -import { InfoIcon } from 'lucide-react' +import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' -// import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' - -// import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' +import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' type Props = { title: string name: string - description: string placeholder: string value: string - onBlur: () => void - onChange: () => void } const ModelConfigInput: React.FC = ({ title, name, value, - description, placeholder, - onChange, - onBlur, }) => { - // const { updateModelParameter } = useUpdateModelParameters() - // const threadId = useAtomValue(getActiveThreadIdAtom) + const { updateModelParameter } = useUpdateModelParameters() + const threadId = useAtomValue(getActiveThreadIdAtom) - // const onValueChanged = (e: React.ChangeEvent) => { - // if (!threadId) return + const onValueChanged = (e: React.ChangeEvent) => { + if (!threadId) return - // updateModelParameter(threadId, name, e.target.value) - // } + updateModelParameter(threadId, name, e.target.value) + } return (
-
-

- {title} -

- - - - - - - {description} - - - - -
+

{title}