app creation

This commit is contained in:
JzoNg
2024-03-02 16:47:43 +08:00
parent 93d116a9d0
commit 4c7941adef
15 changed files with 204 additions and 59 deletions

View File

@ -71,11 +71,13 @@ const Apps = ({
name,
icon,
icon_background,
description,
}) => {
const { app_model_config: model_config } = await fetchAppDetail(
currApp?.app.id as string,
)
// #TODO# need yaml config from app detail
// #TODO# use import api
try {
const app = await createApp({
name,
@ -91,10 +93,14 @@ const Apps = ({
message: t('app.newApp.appCreated'),
})
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
router.push(
`/app/${app.id}/${isCurrentWorkspaceManager ? 'configuration' : 'overview'
}`,
)
if (!isCurrentWorkspaceManager) {
router.push(`/app/${app.id}/'overview'`)
}
else {
if (app.mode === 'workflow' || app.mode === 'advanced-chat')
router.push(`/app/${app.id}/'workflow'`)
router.push(`/app/${app.id}/'configuration'`)
}
}
catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
@ -111,8 +117,8 @@ const Apps = ({
return (
<div className={cn(
'flex flex-col border-l border-gray-200',
pageType === PageType.EXPLORE ? 'h-full' : 'h-[calc(100%-76px)]',
'flex flex-col',
pageType === PageType.EXPLORE ? 'h-full border-l border-gray-200' : 'h-[calc(100%-76px)]',
)}>
{pageType === PageType.EXPLORE && (
<div className='shrink-0 pt-6 px-12'>

View File

@ -12,6 +12,7 @@ import { XClose } from '@/app/components/base/icons/src/vender/line/general'
export type CreateAppModalProps = {
appName: string
appDescription?: string
show: boolean
onConfirm: (info: {
name: string
@ -24,6 +25,7 @@ export type CreateAppModalProps = {
const CreateAppModal = ({
appName,
appDescription,
show = false,
onConfirm,
onHide,
@ -33,7 +35,7 @@ const CreateAppModal = ({
const [name, setName] = React.useState(appName)
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
const [emoji, setEmoji] = useState({ icon: '🤖', icon_background: '#FFEAD5' })
const [description, setDescription] = useState('')
const [description, setDescription] = useState(appDescription || '')
const { plan, enableBilling } = useProviderContext()
const isAppsFull = (enableBilling && plan.usage.buildApps >= plan.total.buildApps)