diff --git a/web/app/components/header/account-setting/model-provider-page/model-badge/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-badge/index.tsx index 29da08dc22..cb641ec0fb 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-badge/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-badge/index.tsx @@ -10,7 +10,7 @@ const ModelBadge: FC = ({ children, }) => { return ( -
+
{children}
) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.spec.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.spec.tsx deleted file mode 100644 index c0c5daece1..0000000000 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.spec.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { fireEvent, render, screen } from '@testing-library/react' -import AddModelButton from './add-model-button' - -describe('AddModelButton', () => { - it('should render button with text', () => { - render() - expect(screen.getByText('common.modelProvider.addModel')).toBeInTheDocument() - }) - - it('should call onClick when clicked', () => { - const handleClick = vi.fn() - render() - const button = screen.getByText('common.modelProvider.addModel') - fireEvent.click(button) - expect(handleClick).toHaveBeenCalledTimes(1) - }) -}) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx deleted file mode 100644 index eac6567ac8..0000000000 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import type { FC } from 'react' -import { useTranslation } from 'react-i18next' -import { PlusCircle } from '@/app/components/base/icons/src/vender/solid/general' -import { cn } from '@/utils/classnames' - -type AddModelButtonProps = { - className?: string - onClick: () => void -} -const AddModelButton: FC = ({ - className, - onClick, -}) => { - const { t } = useTranslation() - - return ( - - - {t('modelProvider.addModel', { ns: 'common' })} - - ) -} - -export default AddModelButton diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx index d58c96b5aa..32ed348b47 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx @@ -1,6 +1,8 @@ import type { FC } from 'react' import type { PluginDetail } from '@/app/components/plugins/types' import { useMemo } from 'react' +import { useTranslation } from 'react-i18next' +import Button from '@/app/components/base/button' import { HeaderModals } from '@/app/components/plugins/plugin-detail-panel/detail-header/components' import { useDetailHeaderState, usePluginOperations } from '@/app/components/plugins/plugin-detail-panel/detail-header/hooks' import OperationDropdown from '@/app/components/plugins/plugin-detail-panel/operation-dropdown' @@ -17,10 +19,11 @@ type Props = { } const ProviderCardActions: FC = ({ detail, onUpdate }) => { + const { t } = useTranslation() const { theme } = useTheme() const locale = useLocale() - const { source, version, meta } = detail + const { source, version, latest_version, latest_unique_identifier, meta } = detail const author = detail.declaration?.author ?? '' const name = detail.declaration?.name ?? detail.name @@ -30,6 +33,7 @@ const ProviderCardActions: FC = ({ detail, onUpdate }) => { hasNewVersion, isAutoUpgradeEnabled, isFromMarketplace, + isFromGitHub, } = useDetailHeaderState(detail) const { @@ -49,6 +53,16 @@ const ProviderCardActions: FC = ({ detail, onUpdate }) => { handleUpdate(state.isDowngrade) } + const handleTriggerLatestUpdate = () => { + if (isFromMarketplace) { + versionPicker.setTargetVersion({ + version: latest_version, + unique_identifier: latest_unique_identifier, + }) + } + handleUpdate() + } + const detailUrl = useMemo(() => { if (source === PluginSource.github) return meta?.repo ? `https://github.com/${meta.repo}` : '' @@ -69,23 +83,35 @@ const ProviderCardActions: FC = ({ detail, onUpdate }) => { onSelect={handleVersionSelect} offset={{ mainAxis: 4, crossAxis: 0 }} trigger={( -
{version} - {isFromMarketplace && } + {isFromMarketplace && } {hasNewVersion && ( )} -
+ )} /> )} + {(hasNewVersion || isFromGitHub) && ( + + )} +