This commit is contained in:
Joel 2024-11-22 11:01:00 +08:00
commit c6b1fecc21
6 changed files with 14135 additions and 16198 deletions

View File

@ -11,6 +11,7 @@ import Placeholder from './base/placeholder'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useGetLanguage } from '@/context/i18n' import { useGetLanguage } from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n/language'
import { useCategories } from '../hooks'
export type Props = { export type Props = {
className?: string className?: string
@ -41,9 +42,9 @@ const Card = ({
}: Props) => { }: Props) => {
const defaultLocale = useGetLanguage() const defaultLocale = useGetLanguage()
const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale
const { categoriesMap } = useCategories()
const { type, name, org, label, brief, icon, verified } = payload const { type, category, name, org, label, brief, icon, verified } = payload
const cornerMark = type !== 'plugin' ? type : categoriesMap[category]?.label
const getLocalizedText = (obj: Record<string, string> | undefined) => const getLocalizedText = (obj: Record<string, string> | undefined) =>
obj?.[locale] || obj?.['en-US'] || obj?.en_US || '' obj?.[locale] || obj?.['en-US'] || obj?.en_US || ''
@ -59,7 +60,7 @@ const Card = ({
return ( return (
<div className={wrapClassName}> <div className={wrapClassName}>
{!hideCornerMark && <CornerMark text={type} />} {!hideCornerMark && <CornerMark text={cornerMark} />}
{/* Header */} {/* Header */}
<div className="flex"> <div className="flex">
<Icon src={icon} installed={installed} installFailed={installFailed} /> <Icon src={icon} installed={installed} installFailed={installFailed} />

View File

@ -2,7 +2,7 @@
import React, { useCallback, useState } from 'react' import React, { useCallback, useState } from 'react'
import Modal from '@/app/components/base/modal' import Modal from '@/app/components/base/modal'
import type { Plugin, PluginManifestInMarket } from '../../types' import type { Dependency, Plugin, PluginManifestInMarket } from '../../types'
import { InstallStep, PluginType } from '../../types' import { InstallStep, PluginType } from '../../types'
import Install from './steps/install' import Install from './steps/install'
import Installed from '../base/installed' import Installed from '../base/installed'
@ -10,12 +10,15 @@ import { useTranslation } from 'react-i18next'
import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks' import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { useInvalidateInstalledPluginList } from '@/service/use-plugins' import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
import { useInvalidateAllToolProviders } from '@/service/use-tools' import { useInvalidateAllToolProviders } from '@/service/use-tools'
import ReadyToInstallBundle from '../install-bundle/ready-to-install'
const i18nPrefix = 'plugin.installModal' const i18nPrefix = 'plugin.installModal'
type InstallFromMarketplaceProps = { type InstallFromMarketplaceProps = {
uniqueIdentifier: string uniqueIdentifier: string
manifest: PluginManifestInMarket | Plugin manifest: PluginManifestInMarket | Plugin
isBundle?: boolean
dependencies?: Dependency[]
onSuccess: () => void onSuccess: () => void
onClose: () => void onClose: () => void
} }
@ -23,6 +26,8 @@ type InstallFromMarketplaceProps = {
const InstallFromMarketplace: React.FC<InstallFromMarketplaceProps> = ({ const InstallFromMarketplace: React.FC<InstallFromMarketplaceProps> = ({
uniqueIdentifier, uniqueIdentifier,
manifest, manifest,
isBundle,
dependencies,
onSuccess, onSuccess,
onClose, onClose,
}) => { }) => {
@ -83,7 +88,14 @@ const InstallFromMarketplace: React.FC<InstallFromMarketplaceProps> = ({
) )
} }
{ {
([InstallStep.installed, InstallStep.installFailed].includes(step)) && ( isBundle ? (
<ReadyToInstallBundle
step={step}
onStepChange={setStep}
onClose={onClose}
allPlugins={dependencies!}
/>
) : ([InstallStep.installed, InstallStep.installFailed].includes(step)) && (
<Installed <Installed
payload={manifest!} payload={manifest!}
isMarketPayload isMarketPayload

View File

@ -131,7 +131,7 @@ const PluginTasks = () => {
className='flex items-center p-1 pl-2 h-8 rounded-lg hover:bg-state-base-hover' className='flex items-center p-1 pl-2 h-8 rounded-lg hover:bg-state-base-hover'
> >
<div className='relative flex items-center justify-center mr-2 w-6 h-6 rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge'> <div className='relative flex items-center justify-center mr-2 w-6 h-6 rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge'>
<RiErrorWarningFill className='absolute -right-0.5 -bottom-0.5 w-3 h-3 text-text-destructive' /> <RiErrorWarningFill className='absolute -right-0.5 -bottom-0.5 z-10 w-3 h-3 text-text-destructive' />
<CardIcon <CardIcon
size='tiny' size='tiny'
src={getIconUrl(errorPlugin.icon)} src={getIconUrl(errorPlugin.icon)}

View File

@ -107,7 +107,7 @@ export type PluginDetail = {
} }
export type Plugin = { export type Plugin = {
type: PluginType type: 'plugin' | 'bundle'
org: string org: string
name: string name: string
plugin_id: string plugin_id: string

View File

@ -46,9 +46,7 @@ const InputVarList: FC<Props> = ({
const paramType = (type: string) => { const paramType = (type: string) => {
if (type === FormTypeEnum.textNumber) if (type === FormTypeEnum.textNumber)
return 'Number' return 'Number'
else if (type === FormTypeEnum.file) else if (type === FormTypeEnum.file || type === FormTypeEnum.files)
return 'File'
else if (type === FormTypeEnum.files)
return 'Files' return 'Files'
else if (type === FormTypeEnum.select) else if (type === FormTypeEnum.select)
return 'Options' return 'Options'
@ -141,9 +139,8 @@ const InputVarList: FC<Props> = ({
const varInput = value[variable] const varInput = value[variable]
const isNumber = type === FormTypeEnum.textNumber const isNumber = type === FormTypeEnum.textNumber
const isSelect = type === FormTypeEnum.select const isSelect = type === FormTypeEnum.select
const isFile = type === FormTypeEnum.file const isFile = type === FormTypeEnum.file || type === FormTypeEnum.files
const isFileArray = type === FormTypeEnum.files const isString = !isNumber && !isSelect && !isFile
const isString = !isNumber && !isSelect && !isFile && !isFileArray
return ( return (
<div key={variable} className='space-y-1'> <div key={variable} className='space-y-1'>
@ -188,19 +185,7 @@ const InputVarList: FC<Props> = ({
onChange={handleFileChange(variable)} onChange={handleFileChange(variable)}
onOpen={handleOpen(index)} onOpen={handleOpen(index)}
defaultVarKindType={VarKindType.variable} defaultVarKindType={VarKindType.variable}
filterVar={(varPayload: Var) => varPayload.type === VarType.file} filterVar={(varPayload: Var) => varPayload.type === VarType.file || varPayload.type === VarType.arrayFile}
/>
)}
{isFileArray && (
<VarReferencePicker
readonly={readOnly}
isShowNodeName
nodeId={nodeId}
value={varInput?.value || []}
onChange={handleFileChange(variable)}
onOpen={handleOpen(index)}
defaultVarKindType={VarKindType.variable}
filterVar={(varPayload: Var) => varPayload.type === VarType.arrayFile}
/> />
)} )}
{tooltip && <div className='text-text-tertiary body-xs-regular'>{tooltip[language] || tooltip.en_US}</div>} {tooltip && <div className='text-text-tertiary body-xs-regular'>{tooltip[language] || tooltip.en_US}</div>}

30281
web/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff