diff --git a/web/app/components/explore/app-card/index.tsx b/web/app/components/explore/app-card/index.tsx index a61ed3bc26..8a95378710 100644 --- a/web/app/components/explore/app-card/index.tsx +++ b/web/app/components/explore/app-card/index.tsx @@ -16,11 +16,15 @@ const CustomizeBtn = ( ) export type AppCardProps = { - app: App + app: App, + onCreate: () => void, + onAddToWorkspace: (appId: string) => void, } const AppCard = ({ app, + onCreate, + onAddToWorkspace }: AppCardProps) => { const { t } = useTranslation() @@ -39,11 +43,11 @@ const AppCard = ({
- - diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx index ab5012e57a..d0fc92c8c7 100644 --- a/web/app/components/explore/app-list/index.tsx +++ b/web/app/components/explore/app-list/index.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next' import Category from '@/app/components/explore/category' import AppCard from '@/app/components/explore/app-card' import { fetchAppList } from '@/service/explore' +import CreateAppModal from '@/app/components/explore/create-app-modal' import s from './style.module.css' @@ -65,6 +66,16 @@ const Apps: FC = ({ }) => { })() } }, []) + + const handleAddToWorkspace = (appId: string) => { + console.log('handleAddToWorkspace', appId) + } + + const [currApp, setCurrApp] = React.useState(null) + const [isShowCreateModal, setIsShowCreateModal] = React.useState(false) + const onCreate = ({name}: any) => { + console.log({id: currApp.id, name}) + } return (
@@ -80,10 +91,27 @@ const Apps: FC = ({ }) => {
+ + {isShowCreateModal && ( + setIsShowCreateModal(false)} + /> + )}
) } diff --git a/web/app/components/explore/create-app-modal/index.tsx b/web/app/components/explore/create-app-modal/index.tsx new file mode 100644 index 0000000000..05f58e4ff5 --- /dev/null +++ b/web/app/components/explore/create-app-modal/index.tsx @@ -0,0 +1,66 @@ +'use client' +import React from 'react' +import { useTranslation } from 'react-i18next' +import Modal from '@/app/components/base/modal' +import Button from '@/app/components/base/button' +import Toast from '@/app/components/base/toast' + +import cn from 'classnames' +import s from './style.module.css' + +type IProps = { + appName: string, + show: boolean, + onConfirm: (info: any) => void, + onHide: () => void, +} + +const CreateAppModal = ({ + appName, + show = false, + onConfirm, + onHide, +}: IProps) => { + const { t } = useTranslation() + + const [name, setName] = React.useState('') + + const submit = () => { + if(!name.trim()) { + Toast.notify({ type: 'error', message: t('explore.appCustomize.nameRequired') }) + return + } + onConfirm({ + name, + }) + onHide() + } + + return ( + + +
{t('explore.appCustomize.title', {name: appName})}
+
+
{t('explore.appCustomize.subTitle')}
+
+
+ setName(e.target.value)} + className='h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg grow' + /> +
+
+
+ + +
+
+ ) +} + +export default CreateAppModal diff --git a/web/app/components/explore/create-app-modal/style.module.css b/web/app/components/explore/create-app-modal/style.module.css new file mode 100644 index 0000000000..798a463b8c --- /dev/null +++ b/web/app/components/explore/create-app-modal/style.module.css @@ -0,0 +1,36 @@ +.modal { + position: relative; +} + +.modal .close { + position: absolute; + right: 16px; + top: 25px; + width: 32px; + height: 32px; + border-radius: 8px; + background: center no-repeat url(~@/app/components/datasets/create/assets/close.svg); + background-size: 16px; + cursor: pointer; +} + +.modal .title { + @apply mb-9; + font-weight: 600; + font-size: 20px; + line-height: 30px; + color: #101828; +} + +.modal .content { + @apply mb-9; + font-weight: 400; + font-size: 14px; + line-height: 20px; + color: #101828; +} + +.subTitle { + margin-bottom: 8px; + font-weight: 500; +} \ No newline at end of file diff --git a/web/i18n/lang/common.en.ts b/web/i18n/lang/common.en.ts index 0f2921127d..924a6b0a06 100644 --- a/web/i18n/lang/common.en.ts +++ b/web/i18n/lang/common.en.ts @@ -6,6 +6,7 @@ const translation = { remove: 'Removed', }, operation: { + create: 'Create', confirm: 'Confirm', cancel: 'Cancel', clear: 'Clear', diff --git a/web/i18n/lang/common.zh.ts b/web/i18n/lang/common.zh.ts index f1a32feede..741f3eb508 100644 --- a/web/i18n/lang/common.zh.ts +++ b/web/i18n/lang/common.zh.ts @@ -6,6 +6,7 @@ const translation = { remove: '已移除', }, operation: { + create: '创建', confirm: '确认', cancel: '取消', clear: '清空', diff --git a/web/i18n/lang/explore.en.ts b/web/i18n/lang/explore.en.ts index b82381c2e7..06058dd7ff 100644 --- a/web/i18n/lang/explore.en.ts +++ b/web/i18n/lang/explore.en.ts @@ -11,6 +11,11 @@ const translation = { appCard: { addToWorkspace: 'Add to Workspace', customize: 'Customize', + }, + appCustomize: { + title: 'Create app from {{name}}', + subTitle: 'App icon & name', + nameRequired: 'App name is required', } } diff --git a/web/i18n/lang/explore.zh.ts b/web/i18n/lang/explore.zh.ts index b449bade59..66b65bdfff 100644 --- a/web/i18n/lang/explore.zh.ts +++ b/web/i18n/lang/explore.zh.ts @@ -11,6 +11,11 @@ const translation = { appCard: { addToWorkspace: '添加到工作区', customize: '自定义', + }, + appCustomize: { + title: '从 {{name}} 创建应用程序', + subTitle: '应用程序图标和名称', + nameRequired: '应用程序名称不能为空', } }