FEAT: NEW WORKFLOW ENGINE (#3160)
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: jyong <718720800@qq.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import NavLink from './navLink'
|
||||
import type { NavIcon } from './navLink'
|
||||
import AppBasic from './basic'
|
||||
import AppInfo from './app-info'
|
||||
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
||||
import {
|
||||
AlignLeft01,
|
||||
AlignRight01,
|
||||
} from '@/app/components/base/icons/src/vender/line/layout'
|
||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||
import { APP_SIDEBAR_SHOULD_COLLAPSE } from '@/app/components/app/configuration/debug/types'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
|
||||
export type IAppDetailNavProps = {
|
||||
iconType?: 'app' | 'dataset' | 'notion'
|
||||
@@ -26,28 +26,22 @@ export type IAppDetailNavProps = {
|
||||
}
|
||||
|
||||
const AppDetailNav = ({ title, desc, icon, icon_background, navigation, extraInfo, iconType = 'app' }: IAppDetailNavProps) => {
|
||||
const localeMode = localStorage.getItem('app-detail-collapse-or-expand') || 'expand'
|
||||
const { appSidebarExpand, setAppSiderbarExpand } = useAppStore()
|
||||
const media = useBreakpoints()
|
||||
const isMobile = media === MediaType.mobile
|
||||
const mode = isMobile ? 'collapse' : 'expand'
|
||||
const [modeState, setModeState] = useState(isMobile ? mode : localeMode)
|
||||
const [modeState, setModeState] = useState(appSidebarExpand)
|
||||
const expand = modeState === 'expand'
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
setModeState((prev) => {
|
||||
const next = prev === 'expand' ? 'collapse' : 'expand'
|
||||
localStorage.setItem('app-detail-collapse-or-expand', next)
|
||||
return next
|
||||
})
|
||||
}, [])
|
||||
const handleToggle = (state: string) => {
|
||||
setAppSiderbarExpand(state === 'expand' ? 'collapse' : 'expand')
|
||||
}
|
||||
|
||||
const { eventEmitter } = useEventEmitterContextContext()
|
||||
eventEmitter?.useSubscription((v: any) => {
|
||||
if (v.type === APP_SIDEBAR_SHOULD_COLLAPSE) {
|
||||
setModeState('collapse')
|
||||
localStorage.setItem('app-detail-collapse-or-expand', 'collapse')
|
||||
useEffect(() => {
|
||||
if (appSidebarExpand) {
|
||||
localStorage.setItem('app-detail-collapse-or-expand', appSidebarExpand)
|
||||
setModeState(appSidebarExpand)
|
||||
}
|
||||
})
|
||||
}, [appSidebarExpand])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -59,18 +53,26 @@ const AppDetailNav = ({ title, desc, icon, icon_background, navigation, extraInf
|
||||
<div
|
||||
className={`
|
||||
shrink-0
|
||||
${expand ? 'p-4' : 'p-2'}
|
||||
${expand ? 'p-3' : 'p-2'}
|
||||
`}
|
||||
>
|
||||
<AppBasic
|
||||
mode={modeState}
|
||||
iconType={iconType}
|
||||
icon={icon}
|
||||
icon_background={icon_background}
|
||||
name={title}
|
||||
type={desc}
|
||||
/>
|
||||
{iconType === 'app' && (
|
||||
<AppInfo expand={expand}/>
|
||||
)}
|
||||
{iconType !== 'app' && (
|
||||
<AppBasic
|
||||
mode={modeState}
|
||||
iconType={iconType}
|
||||
icon={icon}
|
||||
icon_background={icon_background}
|
||||
name={title}
|
||||
type={desc}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{!expand && (
|
||||
<div className='mt-1 mx-auto w-6 h-[1px] bg-gray-100'/>
|
||||
)}
|
||||
<nav
|
||||
className={`
|
||||
grow space-y-1 bg-white
|
||||
@@ -94,7 +96,7 @@ const AppDetailNav = ({ title, desc, icon, icon_background, navigation, extraInf
|
||||
>
|
||||
<div
|
||||
className='flex items-center justify-center w-6 h-6 text-gray-500 cursor-pointer'
|
||||
onClick={handleToggle}
|
||||
onClick={() => handleToggle(modeState)}
|
||||
>
|
||||
{
|
||||
expand
|
||||
|
||||
Reference in New Issue
Block a user