|
@@ -1,48 +1,46 @@
|
|
'use client'
|
|
'use client'
|
|
-import type { MouseEventHandler } from 'react'
|
|
|
|
|
|
+
|
|
import { useCallback, useRef, useState } from 'react'
|
|
import { useCallback, useRef, useState } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
-import {
|
|
|
|
- RiCloseLine,
|
|
|
|
- RiQuestionLine,
|
|
|
|
-} from '@remixicon/react'
|
|
|
|
|
|
+
|
|
import { useRouter } from 'next/navigation'
|
|
import { useRouter } from 'next/navigation'
|
|
import { useContext, useContextSelector } from 'use-context-selector'
|
|
import { useContext, useContextSelector } from 'use-context-selector'
|
|
|
|
+import { RiArrowRightLine, RiCommandLine, RiCornerDownLeftLine, RiExchange2Fill } from '@remixicon/react'
|
|
|
|
+import Link from 'next/link'
|
|
|
|
+import { useDebounceFn, useKeyPress } from 'ahooks'
|
|
|
|
+import Image from 'next/image'
|
|
import AppIconPicker from '../../base/app-icon-picker'
|
|
import AppIconPicker from '../../base/app-icon-picker'
|
|
import type { AppIconSelection } from '../../base/app-icon-picker'
|
|
import type { AppIconSelection } from '../../base/app-icon-picker'
|
|
-import s from './style.module.css'
|
|
|
|
|
|
+import Button from '@/app/components/base/button'
|
|
|
|
+import Divider from '@/app/components/base/divider'
|
|
import cn from '@/utils/classnames'
|
|
import cn from '@/utils/classnames'
|
|
import AppsContext, { useAppContext } from '@/context/app-context'
|
|
import AppsContext, { useAppContext } from '@/context/app-context'
|
|
import { useProviderContext } from '@/context/provider-context'
|
|
import { useProviderContext } from '@/context/provider-context'
|
|
import { ToastContext } from '@/app/components/base/toast'
|
|
import { ToastContext } from '@/app/components/base/toast'
|
|
import type { AppMode } from '@/types/app'
|
|
import type { AppMode } from '@/types/app'
|
|
import { createApp } from '@/service/apps'
|
|
import { createApp } from '@/service/apps'
|
|
-import Modal from '@/app/components/base/modal'
|
|
|
|
-import Button from '@/app/components/base/button'
|
|
|
|
import Input from '@/app/components/base/input'
|
|
import Input from '@/app/components/base/input'
|
|
import Textarea from '@/app/components/base/textarea'
|
|
import Textarea from '@/app/components/base/textarea'
|
|
import AppIcon from '@/app/components/base/app-icon'
|
|
import AppIcon from '@/app/components/base/app-icon'
|
|
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
|
|
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
|
|
-import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'
|
|
|
|
-import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'
|
|
|
|
-import Tooltip from '@/app/components/base/tooltip'
|
|
|
|
|
|
+import { BubbleTextMod, ChatBot, ListSparkle, Logic } from '@/app/components/base/icons/src/vender/solid/communication'
|
|
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
|
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
|
import { getRedirection } from '@/utils/app-redirection'
|
|
import { getRedirection } from '@/utils/app-redirection'
|
|
|
|
+import FullScreenModal from '@/app/components/base/fullscreen-modal'
|
|
|
|
|
|
-type CreateAppDialogProps = {
|
|
|
|
- show: boolean
|
|
|
|
|
|
+type CreateAppProps = {
|
|
onSuccess: () => void
|
|
onSuccess: () => void
|
|
onClose: () => void
|
|
onClose: () => void
|
|
|
|
+ onCreateFromTemplate?: () => void
|
|
}
|
|
}
|
|
|
|
|
|
-const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => {
|
|
|
|
|
|
+function CreateApp({ onClose, onSuccess, onCreateFromTemplate }: CreateAppProps) {
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
const { push } = useRouter()
|
|
const { push } = useRouter()
|
|
const { notify } = useContext(ToastContext)
|
|
const { notify } = useContext(ToastContext)
|
|
const mutateApps = useContextSelector(AppsContext, state => state.mutateApps)
|
|
const mutateApps = useContextSelector(AppsContext, state => state.mutateApps)
|
|
|
|
|
|
const [appMode, setAppMode] = useState<AppMode>('chat')
|
|
const [appMode, setAppMode] = useState<AppMode>('chat')
|
|
- const [showChatBotType, setShowChatBotType] = useState<boolean>(true)
|
|
|
|
const [appIcon, setAppIcon] = useState<AppIconSelection>({ type: 'emoji', icon: '🤖', background: '#FFEAD5' })
|
|
const [appIcon, setAppIcon] = useState<AppIconSelection>({ type: 'emoji', icon: '🤖', background: '#FFEAD5' })
|
|
const [showAppIconPicker, setShowAppIconPicker] = useState(false)
|
|
const [showAppIconPicker, setShowAppIconPicker] = useState(false)
|
|
const [name, setName] = useState('')
|
|
const [name, setName] = useState('')
|
|
@@ -53,7 +51,8 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => {
|
|
const { isCurrentWorkspaceEditor } = useAppContext()
|
|
const { isCurrentWorkspaceEditor } = useAppContext()
|
|
|
|
|
|
const isCreatingRef = useRef(false)
|
|
const isCreatingRef = useRef(false)
|
|
- const onCreate: MouseEventHandler = useCallback(async () => {
|
|
|
|
|
|
+
|
|
|
|
+ const onCreate = useCallback(async () => {
|
|
if (!appMode) {
|
|
if (!appMode) {
|
|
notify({ type: 'error', message: t('app.newApp.appTypeRequired') })
|
|
notify({ type: 'error', message: t('app.newApp.appTypeRequired') })
|
|
return
|
|
return
|
|
@@ -87,237 +86,281 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => {
|
|
isCreatingRef.current = false
|
|
isCreatingRef.current = false
|
|
}, [name, notify, t, appMode, appIcon, description, onSuccess, onClose, mutateApps, push, isCurrentWorkspaceEditor])
|
|
}, [name, notify, t, appMode, appIcon, description, onSuccess, onClose, mutateApps, push, isCurrentWorkspaceEditor])
|
|
|
|
|
|
- return (
|
|
|
|
- <Modal
|
|
|
|
- overflowVisible
|
|
|
|
- className='!p-0 !max-w-[720px] !w-[720px] rounded-xl'
|
|
|
|
- isShow={show}
|
|
|
|
- onClose={() => { }}
|
|
|
|
- >
|
|
|
|
- {/* Heading */}
|
|
|
|
- <div className='shrink-0 flex flex-col h-full bg-white rounded-t-xl'>
|
|
|
|
- <div className='shrink-0 pl-8 pr-6 pt-6 pb-3 bg-white text-xl rounded-t-xl leading-[30px] font-semibold text-gray-900 z-10'>{t('app.newApp.startFromBlank')}</div>
|
|
|
|
- </div>
|
|
|
|
- {/* app type */}
|
|
|
|
- <div className='py-2 px-8'>
|
|
|
|
- <div className='py-2 text-sm leading-[20px] font-medium text-gray-900'>{t('app.newApp.captionAppType')}</div>
|
|
|
|
- <div className='flex'>
|
|
|
|
- <Tooltip
|
|
|
|
- popupContent={
|
|
|
|
- <div className='max-w-[280px] leading-[18px] text-xs text-gray-700'>{t('app.newApp.chatbotDescription')}</div>
|
|
|
|
- }
|
|
|
|
- >
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow box-border w-[158px] mr-2 px-0.5 pt-3 pb-2 flex flex-col items-center justify-center gap-1 rounded-lg border border-gray-100 bg-white text-gray-700 cursor-pointer shadow-xs hover:border-gray-300',
|
|
|
|
- showChatBotType && 'border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- s['grid-bg-chat'],
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('chat')
|
|
|
|
- setShowChatBotType(true)
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <ChatBot className='w-6 h-6 text-[#1570EF]' />
|
|
|
|
- <div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.types.chatbot')}</div>
|
|
|
|
|
|
+ const { run: handleCreateApp } = useDebounceFn(onCreate, { wait: 300 })
|
|
|
|
+ useKeyPress(['meta.enter', 'ctrl.enter'], () => {
|
|
|
|
+ if (isAppsFull)
|
|
|
|
+ return
|
|
|
|
+ handleCreateApp()
|
|
|
|
+ })
|
|
|
|
+ return <>
|
|
|
|
+ <div className='flex justify-center h-full overflow-y-auto overflow-x-hidden'>
|
|
|
|
+ <div className='flex-1 shrink-0 flex justify-end'>
|
|
|
|
+ <div className='px-10'>
|
|
|
|
+ <div className='w-full h-6 2xl:h-[139px]' />
|
|
|
|
+ <div className='pt-1 pb-6'>
|
|
|
|
+ <span className='title-2xl-semi-bold text-text-primary'>{t('app.newApp.startFromBlank')}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div className='leading-6 mb-2'>
|
|
|
|
+ <span className='system-sm-semibold text-text-secondary'>{t('app.newApp.chooseAppType')}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div className='flex flex-col w-[660px] gap-4'>
|
|
|
|
+ <div>
|
|
|
|
+ <div className='mb-2'>
|
|
|
|
+ <span className='system-2xs-medium-uppercase text-text-tertiary'>{t('app.newApp.forBeginners')}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div className='flex flex-row gap-2'>
|
|
|
|
+ <AppTypeCard
|
|
|
|
+ active={appMode === 'chat'}
|
|
|
|
+ title={t('app.types.chatbot')}
|
|
|
|
+ description={t('app.newApp.chatbotShortDescription')}
|
|
|
|
+ icon={<div className='w-6 h-6 bg-components-icon-bg-blue-solid rounded-md flex items-center justify-center'>
|
|
|
|
+ <ChatBot className='w-4 h-4 text-components-avatar-shape-fill-stop-100' />
|
|
|
|
+ </div>}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setAppMode('chat')
|
|
|
|
+ }} />
|
|
|
|
+ <AppTypeCard
|
|
|
|
+ active={appMode === 'agent-chat'}
|
|
|
|
+ title={t('app.types.agent')}
|
|
|
|
+ description={t('app.newApp.agentShortDescription')}
|
|
|
|
+ icon={<div className='w-6 h-6 bg-components-icon-bg-violet-solid rounded-md flex items-center justify-center'>
|
|
|
|
+ <Logic className='w-4 h-4 text-components-avatar-shape-fill-stop-100' />
|
|
|
|
+ </div>}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setAppMode('agent-chat')
|
|
|
|
+ }} />
|
|
|
|
+ <AppTypeCard
|
|
|
|
+ active={appMode === 'completion'}
|
|
|
|
+ title={t('app.newApp.completeApp')}
|
|
|
|
+ description={t('app.newApp.completionShortDescription')}
|
|
|
|
+ icon={<div className='w-6 h-6 bg-components-icon-bg-teal-solid rounded-md flex items-center justify-center'>
|
|
|
|
+ <ListSparkle className='w-4 h-4 text-components-avatar-shape-fill-stop-100' />
|
|
|
|
+ </div>}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setAppMode('completion')
|
|
|
|
+ }} />
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </Tooltip>
|
|
|
|
- <Tooltip
|
|
|
|
- popupContent={
|
|
|
|
- <div className='flex flex-col max-w-[320px] leading-[18px] text-xs'>
|
|
|
|
- <div className='text-gray-700'>{t('app.newApp.completionDescription')}</div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <div className='mb-2'>
|
|
|
|
+ <span className='system-2xs-medium-uppercase text-text-tertiary'>{t('app.newApp.forAdvanced')}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div className='flex flex-row gap-2'>
|
|
|
|
+ <AppTypeCard
|
|
|
|
+ beta
|
|
|
|
+ active={appMode === 'advanced-chat'}
|
|
|
|
+ title={t('app.types.advanced')}
|
|
|
|
+ description={t('app.newApp.advancedShortDescription')}
|
|
|
|
+ icon={<div className='w-6 h-6 bg-components-icon-bg-blue-light-solid rounded-md flex items-center justify-center'>
|
|
|
|
+ <BubbleTextMod className='w-4 h-4 text-components-avatar-shape-fill-stop-100' />
|
|
|
|
+ </div>}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setAppMode('advanced-chat')
|
|
|
|
+ }} />
|
|
|
|
+ <AppTypeCard
|
|
|
|
+ beta
|
|
|
|
+ active={appMode === 'workflow'}
|
|
|
|
+ title={t('app.types.workflow')}
|
|
|
|
+ description={t('app.newApp.workflowShortDescription')}
|
|
|
|
+ icon={<div className='w-6 h-6 bg-components-icon-bg-indigo-solid rounded-md flex items-center justify-center'>
|
|
|
|
+ <RiExchange2Fill className='w-4 h-4 text-components-avatar-shape-fill-stop-100' />
|
|
|
|
+ </div>}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ setAppMode('workflow')
|
|
|
|
+ }} />
|
|
</div>
|
|
</div>
|
|
- }
|
|
|
|
- >
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow box-border w-[158px] mr-2 px-0.5 pt-3 pb-2 flex flex-col items-center justify-center gap-1 rounded-lg border border-gray-100 text-gray-700 cursor-pointer bg-white shadow-xs hover:border-gray-300',
|
|
|
|
- s['grid-bg-completion'],
|
|
|
|
- appMode === 'completion' && 'border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('completion')
|
|
|
|
- setShowChatBotType(false)
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <AiText className='w-6 h-6 text-[#0E9384]' />
|
|
|
|
- <div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.newApp.completeApp')}</div>
|
|
|
|
</div>
|
|
</div>
|
|
- </Tooltip>
|
|
|
|
- <Tooltip
|
|
|
|
- popupContent={
|
|
|
|
- <div className='max-w-[280px] leading-[18px] text-xs text-gray-700'>{t('app.newApp.agentDescription')}</div>
|
|
|
|
- }
|
|
|
|
- >
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow box-border w-[158px] mr-2 px-0.5 pt-3 pb-2 flex flex-col items-center justify-center gap-1 rounded-lg border border-gray-100 text-gray-700 cursor-pointer bg-white shadow-xs hover:border-gray-300',
|
|
|
|
- s['grid-bg-agent-chat'],
|
|
|
|
- appMode === 'agent-chat' && 'border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('agent-chat')
|
|
|
|
- setShowChatBotType(false)
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <CuteRobot className='w-6 h-6 text-indigo-600' />
|
|
|
|
- <div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.types.agent')}</div>
|
|
|
|
|
|
+ <Divider style={{ margin: 0 }} />
|
|
|
|
+ <div className='flex space-x-3 items-center'>
|
|
|
|
+ <div className='flex-1'>
|
|
|
|
+ <div className='h-6 flex items-center mb-1'>
|
|
|
|
+ <label className='system-sm-semibold text-text-secondary'>{t('app.newApp.captionName')}</label>
|
|
|
|
+ </div>
|
|
|
|
+ <Input
|
|
|
|
+ value={name}
|
|
|
|
+ onChange={e => setName(e.target.value)}
|
|
|
|
+ placeholder={t('app.newApp.appNamePlaceholder') || ''}
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <AppIcon
|
|
|
|
+ iconType={appIcon.type}
|
|
|
|
+ icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
|
|
|
|
+ background={appIcon.type === 'emoji' ? appIcon.background : undefined}
|
|
|
|
+ imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
|
|
|
|
+ size='xxl' className='cursor-pointer rounded-2xl'
|
|
|
|
+ onClick={() => { setShowAppIconPicker(true) }}
|
|
|
|
+ />
|
|
|
|
+ {showAppIconPicker && <AppIconPicker
|
|
|
|
+ onSelect={(payload) => {
|
|
|
|
+ setAppIcon(payload)
|
|
|
|
+ setShowAppIconPicker(false)
|
|
|
|
+ }}
|
|
|
|
+ onClose={() => {
|
|
|
|
+ setShowAppIconPicker(false)
|
|
|
|
+ }}
|
|
|
|
+ />}
|
|
</div>
|
|
</div>
|
|
- </Tooltip>
|
|
|
|
- <Tooltip
|
|
|
|
- popupContent={
|
|
|
|
- <div className='flex flex-col max-w-[320px] leading-[18px] text-xs'>
|
|
|
|
- <div className='text-gray-700'>{t('app.newApp.workflowDescription')}</div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <div className='h-6 flex items-center mb-1'>
|
|
|
|
+ <label className='system-sm-semibold text-text-secondary'>{t('app.newApp.captionDescription')}</label>
|
|
|
|
+ <span className='system-xs-regular text-text-tertiary ml-1'>({t('app.newApp.optional')})</span>
|
|
</div>
|
|
</div>
|
|
- }
|
|
|
|
- >
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow box-border w-[158px] px-0.5 pt-3 pb-2 flex flex-col items-center justify-center gap-1 rounded-lg border border-gray-100 text-gray-700 cursor-pointer bg-white shadow-xs hover:border-gray-300',
|
|
|
|
- s['grid-bg-workflow'],
|
|
|
|
- appMode === 'workflow' && 'border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('workflow')
|
|
|
|
- setShowChatBotType(false)
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <Route className='w-6 h-6 text-[#f79009]' />
|
|
|
|
- <div className='h-5 text-[13px] font-medium leading-[18px]'>{t('app.types.workflow')}</div>
|
|
|
|
- <span className='absolute top-[-3px] right-[-3px] px-1 rounded-[5px] bg-white border border-black/8 text-gray-500 text-[10px] leading-[18px] font-medium'>BETA</span>
|
|
|
|
|
|
+ <Textarea
|
|
|
|
+ className='resize-none'
|
|
|
|
+ placeholder={t('app.newApp.appDescriptionPlaceholder') || ''}
|
|
|
|
+ value={description}
|
|
|
|
+ onChange={e => setDescription(e.target.value)}
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
- </Tooltip>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- {showChatBotType && (
|
|
|
|
- <div className='py-2 px-8'>
|
|
|
|
- <div className='py-2 text-sm leading-[20px] font-medium text-gray-900'>{t('app.newApp.chatbotType')}</div>
|
|
|
|
- <div className='flex gap-2'>
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow flex-[50%] pl-4 py-[10px] pr-[10px] rounded-lg border border-gray-100 bg-gray-25 text-gray-700 cursor-pointer hover:bg-white hover:shadow-xs hover:border-gray-300',
|
|
|
|
- appMode === 'chat' && 'bg-white shadow-xs border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('chat')
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <div className='flex items-center justify-between'>
|
|
|
|
- <div className='h-5 text-sm font-medium leading-5'>{t('app.newApp.basic')}</div>
|
|
|
|
- <div className='group'>
|
|
|
|
- <RiQuestionLine className='w-[14px] h-[14px] text-gray-400 hover:text-gray-500' />
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'hidden z-20 absolute left-[327px] top-[-158px] w-[376px] rounded-xl bg-white border-[0.5px] border-[rgba(0,0,0,0.05)] shadow-lg group-hover:block',
|
|
|
|
- )}
|
|
|
|
- >
|
|
|
|
- <div className={cn('w-full h-[256px] bg-center bg-no-repeat bg-contain rounded-xl', s.basicPic)} />
|
|
|
|
- <div className='px-4 pb-2'>
|
|
|
|
- <div className='flex items-center justify-between'>
|
|
|
|
- <div className='text-gray-700 text-md leading-6 font-semibold'>{t('app.newApp.basic')}</div>
|
|
|
|
- <div className='text-orange-500 text-xs leading-[18px] font-medium'>{t('app.newApp.basicFor')}</div>
|
|
|
|
- </div>
|
|
|
|
- <div className='mt-1 text-gray-500 text-sm leading-5'>{t('app.newApp.basicDescription')}</div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div className='pt-5 pb-10 flex justify-between items-center'>
|
|
|
|
+ <div className='flex gap-1 items-center system-xs-regular text-text-tertiary cursor-pointer' onClick={onCreateFromTemplate}>
|
|
|
|
+ <span>{t('app.newApp.noIdeaTip')}</span>
|
|
|
|
+ <div className='p-[1px]'>
|
|
|
|
+ <RiArrowRightLine className='w-3.5 h-3.5' />
|
|
</div>
|
|
</div>
|
|
- <div className='mt-[2px] text-gray-500 text-xs leading-[18px]'>{t('app.newApp.basicTip')}</div>
|
|
|
|
</div>
|
|
</div>
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'relative grow flex-[50%] pl-3 py-2 pr-2 rounded-lg border border-gray-100 bg-gray-25 text-gray-700 cursor-pointer hover:bg-white hover:shadow-xs hover:border-gray-300',
|
|
|
|
- appMode === 'advanced-chat' && 'bg-white shadow-xs border-[1.5px] border-primary-400 hover:border-[1.5px] hover:border-primary-400',
|
|
|
|
- )}
|
|
|
|
- onClick={() => {
|
|
|
|
- setAppMode('advanced-chat')
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <div className='flex items-center justify-between'>
|
|
|
|
- <div className='flex items-center'>
|
|
|
|
- <div className='mr-1 h-5 text-sm font-medium leading-5'>{t('app.newApp.advanced')}</div>
|
|
|
|
- <span className='px-1 rounded-[5px] bg-white border border-black/8 text-gray-500 text-[10px] leading-[18px] font-medium'>BETA</span>
|
|
|
|
- </div>
|
|
|
|
- <div className='group'>
|
|
|
|
- <RiQuestionLine className='w-[14px] h-[14px] text-gray-400 hover:text-gray-500' />
|
|
|
|
- <div
|
|
|
|
- className={cn(
|
|
|
|
- 'hidden z-20 absolute right-[26px] top-[-158px] w-[376px] rounded-xl bg-white border-[0.5px] border-[rgba(0,0,0,0.05)] shadow-lg group-hover:block',
|
|
|
|
- )}
|
|
|
|
- >
|
|
|
|
- <div className={cn('w-full h-[256px] bg-center bg-no-repeat bg-contain rounded-xl', s.advancedPic)} />
|
|
|
|
- <div className='px-4 pb-2'>
|
|
|
|
- <div className='flex items-center justify-between'>
|
|
|
|
- <div className='flex items-center'>
|
|
|
|
- <div className='mr-1 text-gray-700 text-md leading-6 font-semibold'>{t('app.newApp.advanced')}</div>
|
|
|
|
- <span className='px-1 rounded-[5px] bg-white border border-black/8 text-gray-500 text-[10px] leading-[18px] font-medium'>BETA</span>
|
|
|
|
- </div>
|
|
|
|
- <div className='text-orange-500 text-xs leading-[18px] font-medium'>{t('app.newApp.advancedFor').toLocaleUpperCase()}</div>
|
|
|
|
- </div>
|
|
|
|
- <div className='mt-1 text-gray-500 text-sm leading-5'>{t('app.newApp.advancedDescription')}</div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div className='flex gap-2'>
|
|
|
|
+ <Button onClick={onClose}>{t('app.newApp.Cancel')}</Button>
|
|
|
|
+ <Button disabled={isAppsFull || !name} className='gap-1' variant="primary" onClick={handleCreateApp}>
|
|
|
|
+ <span>{t('app.newApp.Create')}</span>
|
|
|
|
+ <div className='flex gap-0.5'>
|
|
|
|
+ <RiCommandLine size={14} className='p-0.5 system-kbd bg-components-kbd-bg-white rounded-sm' />
|
|
|
|
+ <RiCornerDownLeftLine size={14} className='p-0.5 system-kbd bg-components-kbd-bg-white rounded-sm' />
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- <div className='mt-[2px] text-gray-500 text-xs leading-[18px]'>{t('app.newApp.advancedFor')}</div>
|
|
|
|
|
|
+ </Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- )}
|
|
|
|
-
|
|
|
|
- {/* icon & name */}
|
|
|
|
- <div className='pt-2 px-8'>
|
|
|
|
- <div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.captionName')}</div>
|
|
|
|
- <div className='flex items-center justify-between space-x-2'>
|
|
|
|
- <AppIcon
|
|
|
|
- iconType={appIcon.type}
|
|
|
|
- icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
|
|
|
|
- background={appIcon.type === 'emoji' ? appIcon.background : undefined}
|
|
|
|
- imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
|
|
|
|
- size='large' className='cursor-pointer'
|
|
|
|
- onClick={() => { setShowAppIconPicker(true) }}
|
|
|
|
- />
|
|
|
|
- <Input
|
|
|
|
- value={name}
|
|
|
|
- onChange={e => setName(e.target.value)}
|
|
|
|
- placeholder={t('app.newApp.appNamePlaceholder') || ''}
|
|
|
|
- className='grow h-10'
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
- {showAppIconPicker && <AppIconPicker
|
|
|
|
- onSelect={(payload) => {
|
|
|
|
- setAppIcon(payload)
|
|
|
|
- setShowAppIconPicker(false)
|
|
|
|
- }}
|
|
|
|
- onClose={() => {
|
|
|
|
- setShowAppIconPicker(false)
|
|
|
|
- }}
|
|
|
|
- />}
|
|
|
|
</div>
|
|
</div>
|
|
- {/* description */}
|
|
|
|
- <div className='pt-2 px-8'>
|
|
|
|
- <div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.captionDescription')}</div>
|
|
|
|
- <Textarea
|
|
|
|
- className='resize-none'
|
|
|
|
- placeholder={t('app.newApp.appDescriptionPlaceholder') || ''}
|
|
|
|
- value={description}
|
|
|
|
- onChange={e => setDescription(e.target.value)}
|
|
|
|
- />
|
|
|
|
|
|
+ <div className='flex-1 shrink h-full flex justify-start relative overflow-hidden'>
|
|
|
|
+ <div className='h-6 2xl:h-[139px] absolute left-0 top-0 right-0 border-b border-b-divider-subtle'></div>
|
|
|
|
+ <div className='max-w-[760px] border-x border-x-divider-subtle'>
|
|
|
|
+ <div className='h-6 2xl:h-[139px]' />
|
|
|
|
+ <AppPreview mode={appMode} />
|
|
|
|
+ <div className='absolute left-0 right-0 border-b border-b-divider-subtle'></div>
|
|
|
|
+ <div className='w-[664px] h-[448px] flex items-center justify-center' style={{ background: 'repeating-linear-gradient(135deg, transparent, transparent 2px, rgba(16,24,40,0.04) 4px,transparent 3px, transparent 6px)' }}>
|
|
|
|
+ <AppScreenShot show={appMode === 'chat'} mode='chat' />
|
|
|
|
+ <AppScreenShot show={appMode === 'advanced-chat'} mode='advanced-chat' />
|
|
|
|
+ <AppScreenShot show={appMode === 'agent-chat'} mode='agent-chat' />
|
|
|
|
+ <AppScreenShot show={appMode === 'completion'} mode='completion' />
|
|
|
|
+ <AppScreenShot show={appMode === 'workflow'} mode='workflow' />
|
|
|
|
+ </div>
|
|
|
|
+ <div className='absolute left-0 right-0 border-b border-b-divider-subtle'></div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- {isAppsFull && (
|
|
|
|
|
|
+ </div>
|
|
|
|
+ {
|
|
|
|
+ isAppsFull && (
|
|
<div className='px-8 py-2'>
|
|
<div className='px-8 py-2'>
|
|
<AppsFull loc='app-create' />
|
|
<AppsFull loc='app-create' />
|
|
</div>
|
|
</div>
|
|
- )}
|
|
|
|
- <div className='px-8 py-6 flex justify-end'>
|
|
|
|
- <Button className='mr-2' onClick={onClose}>{t('app.newApp.Cancel')}</Button>
|
|
|
|
- <Button disabled={isAppsFull || !name} variant="primary" onClick={onCreate}>{t('app.newApp.Create')}</Button>
|
|
|
|
- </div>
|
|
|
|
- <div className='absolute right-6 top-6 p-2 cursor-pointer z-20' onClick={onClose}>
|
|
|
|
- <RiCloseLine className='w-4 h-4 text-gray-500' />
|
|
|
|
- </div>
|
|
|
|
- </Modal>
|
|
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ </>
|
|
|
|
+}
|
|
|
|
+type CreateAppDialogProps = CreateAppProps & {
|
|
|
|
+ show: boolean
|
|
|
|
+}
|
|
|
|
+const CreateAppModal = ({ show, onClose, onSuccess, onCreateFromTemplate }: CreateAppDialogProps) => {
|
|
|
|
+ return (
|
|
|
|
+ <FullScreenModal
|
|
|
|
+ overflowVisible
|
|
|
|
+ closable
|
|
|
|
+ open={show}
|
|
|
|
+ onClose={onClose}
|
|
|
|
+ >
|
|
|
|
+ <CreateApp onClose={onClose} onSuccess={onSuccess} onCreateFromTemplate={onCreateFromTemplate} />
|
|
|
|
+ </FullScreenModal>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
export default CreateAppModal
|
|
export default CreateAppModal
|
|
|
|
+
|
|
|
|
+type AppTypeCardProps = {
|
|
|
|
+ icon: JSX.Element
|
|
|
|
+ beta?: boolean
|
|
|
|
+ title: string
|
|
|
|
+ description: string
|
|
|
|
+ active: boolean
|
|
|
|
+ onClick: () => void
|
|
|
|
+}
|
|
|
|
+function AppTypeCard({ icon, title, beta = false, description, active, onClick }: AppTypeCardProps) {
|
|
|
|
+ const { t } = useTranslation()
|
|
|
|
+ return <div
|
|
|
|
+ className={
|
|
|
|
+ cn(`w-[191px] h-[84px] p-3 border-[0.5px] relative box-content
|
|
|
|
+ rounded-xl border-components-option-card-option-border
|
|
|
|
+ bg-components-panel-on-panel-item-bg shadow-xs cursor-pointer hover:shadow-md`, active
|
|
|
|
+ ? 'outline outline-[1.5px] outline-components-option-card-option-selected-border shadow-md'
|
|
|
|
+ : '')
|
|
|
|
+ }
|
|
|
|
+ onClick={onClick}
|
|
|
|
+ >
|
|
|
|
+ {beta && <div className='px-[5px] py-[3px]
|
|
|
|
+ rounded-[5px] min-w-[18px] absolute top-3 right-3
|
|
|
|
+ border border-divider-deep system-2xs-medium-uppercase text-text-tertiary'>{t('common.menus.status')}</div>}
|
|
|
|
+ {icon}
|
|
|
|
+ <div className='system-sm-semibold text-text-secondary mt-2 mb-0.5'>{title}</div>
|
|
|
|
+ <div className='system-xs-regular text-text-tertiary'>{description}</div>
|
|
|
|
+ </div>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function AppPreview({ mode }: { mode: AppMode }) {
|
|
|
|
+ const { t } = useTranslation()
|
|
|
|
+ const modeToPreviewInfoMap = {
|
|
|
|
+ 'chat': {
|
|
|
|
+ title: t('app.types.chatbot'),
|
|
|
|
+ description: t('app.newApp.chatbotUserDescription'),
|
|
|
|
+ link: 'https://docs.dify.ai/guides/application-orchestrate/conversation-application?fallback=true',
|
|
|
|
+ },
|
|
|
|
+ 'advanced-chat': {
|
|
|
|
+ title: t('app.types.advanced'),
|
|
|
|
+ description: t('app.newApp.advancedUserDescription'),
|
|
|
|
+ link: 'https://docs.dify.ai/guides/workflow',
|
|
|
|
+ },
|
|
|
|
+ 'agent-chat': {
|
|
|
|
+ title: t('app.types.agent'),
|
|
|
|
+ description: t('app.newApp.agentUserDescription'),
|
|
|
|
+ link: 'https://docs.dify.ai/guides/application-orchestrate/agent',
|
|
|
|
+ },
|
|
|
|
+ 'completion': {
|
|
|
|
+ title: t('app.newApp.completeApp'),
|
|
|
|
+ description: t('app.newApp.completionUserDescription'),
|
|
|
|
+ link: null,
|
|
|
|
+ },
|
|
|
|
+ 'workflow': {
|
|
|
|
+ title: t('app.types.workflow'),
|
|
|
|
+ description: t('app.newApp.workflowUserDescription'),
|
|
|
|
+ link: 'https://docs.dify.ai/guides/workflow',
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ const previewInfo = modeToPreviewInfoMap[mode]
|
|
|
|
+ return <div className='px-8 py-4'>
|
|
|
|
+ <h4 className='system-sm-semibold-uppercase text-text-secondary'>{previewInfo.title}</h4>
|
|
|
|
+ <div className='mt-1 system-xs-regular text-text-tertiary max-w-96 min-h-8'>
|
|
|
|
+ <span>{previewInfo.description}</span>
|
|
|
|
+ {previewInfo.link && <Link target='_blank' href={previewInfo.link} className='text-text-accent ml-1'>{t('app.newApp.learnMore')}</Link>}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function AppScreenShot({ mode, show }: { mode: AppMode; show: boolean }) {
|
|
|
|
+ const theme = useContextSelector(AppsContext, state => state.theme)
|
|
|
|
+ const modeToImageMap = {
|
|
|
|
+ 'chat': 'Chatbot',
|
|
|
|
+ 'advanced-chat': 'Chatflow',
|
|
|
|
+ 'agent-chat': 'Agent',
|
|
|
|
+ 'completion': 'TextGenerator',
|
|
|
|
+ 'workflow': 'Workflow',
|
|
|
|
+ }
|
|
|
|
+ return <picture>
|
|
|
|
+ <source media="(resolution: 1x)" srcSet={`/screenshots/${theme}/${modeToImageMap[mode]}.png`} />
|
|
|
|
+ <source media="(resolution: 2x)" srcSet={`/screenshots/${theme}/${modeToImageMap[mode]}@2x.png`} />
|
|
|
|
+ <source media="(resolution: 3x)" srcSet={`/screenshots/${theme}/${modeToImageMap[mode]}@3x.png`} />
|
|
|
|
+ <Image className={show ? '' : 'hidden'}
|
|
|
|
+ src={`/screenshots/${theme}/${modeToImageMap[mode]}.png`}
|
|
|
|
+ alt='App Screen Shot'
|
|
|
|
+ width={664} height={448} />
|
|
|
|
+ </picture>
|
|
|
|
+}
|