chore: blank add to template link

This commit is contained in:
Joel
2026-02-13 13:48:04 +08:00
parent 0893c8531d
commit a7ab84106e
5 changed files with 33 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { trackEvent } from '@/app/components/base/amplitude'
import { ToastContext } from '@/app/components/base/toast'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { MARKETPLACE_URL_PREFIX, NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { useAppContext } from '@/context/app-context'
import { useProviderContext } from '@/context/provider-context'
import { createApp } from '@/service/apps'
@@ -159,4 +159,16 @@ describe('CreateAppModal', () => {
expect(mockNotify).toHaveBeenCalledWith({ type: 'error', message: 'boom' })
expect(onClose).not.toHaveBeenCalled()
})
it('renders community explore link with marketplace templates URL', async () => {
renderModal()
await waitFor(() => {
expect(screen.getByRole('link', { name: 'app.newApp.orExploreCommunity' })).toBeInTheDocument()
})
const link = screen.getByRole('link', { name: 'app.newApp.orExploreCommunity' })
expect(link).toHaveAttribute('href', `${MARKETPLACE_URL_PREFIX.replace(/\/$/, '')}/templates`)
expect(link).toHaveAttribute('target', '_blank')
expect(link).toHaveAttribute('rel', 'noopener noreferrer')
})
})

View File

@@ -21,7 +21,7 @@ import CustomSelect from '@/app/components/base/select/custom'
import Textarea from '@/app/components/base/textarea'
import { ToastContext } from '@/app/components/base/toast'
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { MARKETPLACE_URL_PREFIX, NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { STORAGE_KEYS } from '@/config/storage-keys'
import { useAppContext } from '@/context/app-context'
import { useProviderContext } from '@/context/provider-context'
@@ -49,6 +49,8 @@ type RuntimeOption = {
recommended?: boolean
}
const marketplaceTemplatesUrl = `${MARKETPLACE_URL_PREFIX.replace(/\/$/, '')}/templates`
function CreateApp({ onClose, onSuccess, onCreateFromTemplate, defaultAppMode }: CreateAppProps) {
const { t } = useTranslation()
const { push } = useRouter()
@@ -332,11 +334,21 @@ function CreateApp({ onClose, onSuccess, onCreateFromTemplate, defaultAppMode }:
</div>
{isAppsFull && <AppsFull className="mt-4" loc="app-create" />}
<div className="flex items-center justify-between pb-10 pt-5">
<div className="flex cursor-pointer items-center gap-1 text-text-tertiary system-xs-regular" onClick={onCreateFromTemplate}>
<span>{t('newApp.noIdeaTip', { ns: 'app' })}</span>
<div className="p-[1px]">
<RiArrowRightLine className="h-3.5 w-3.5" />
<div className="flex items-center gap-2 system-xs-regular">
<div className="flex cursor-pointer items-center gap-1 text-text-tertiary" onClick={onCreateFromTemplate}>
<span>{t('newApp.noIdeaTip', { ns: 'app' })}</span>
<div className="p-[1px]">
<RiArrowRightLine className="h-3.5 w-3.5" />
</div>
</div>
<a
href={marketplaceTemplatesUrl}
target="_blank"
rel="noopener noreferrer"
className="text-text-tertiary hover:text-text-secondary hover:underline"
>
{t('newApp.orExploreCommunity', { ns: 'app' })}
</a>
</div>
<div className="flex gap-2">
<Button onClick={onClose}>{t('newApp.Cancel', { ns: 'app' })}</Button>

View File

@@ -176,6 +176,7 @@
"newApp.noTemplateFound": "No templates found",
"newApp.noTemplateFoundTip": "Try searching using different keywords.",
"newApp.optional": "Optional",
"newApp.orExploreCommunity": "or explore the community",
"newApp.previewDemo": "Preview demo",
"newApp.recommended": "RECOMMENDED",
"newApp.runtimeLabel": "Runtime",

View File

@@ -174,6 +174,7 @@
"newApp.noTemplateFound": "未找到模板",
"newApp.noTemplateFoundTip": "请尝试使用不同的关键字进行搜索。",
"newApp.optional": "可选",
"newApp.orExploreCommunity": "或探索社区",
"newApp.previewDemo": "预览 Demo",
"newApp.recommended": "推荐",
"newApp.runtimeLabel": "运行时",

View File

@@ -173,6 +173,7 @@
"newApp.noTemplateFound": "未找到範本",
"newApp.noTemplateFoundTip": "嘗試使用不同的關鍵字進行搜索。",
"newApp.optional": "自選",
"newApp.orExploreCommunity": "或探索社群",
"newApp.previewDemo": "預覽 Demo",
"newApp.showTemplates": "我想從範例模板中選擇",
"newApp.startFromBlank": "建立空白應用",