diff --git a/web/app/components/base/tab-slider/index.tsx b/web/app/components/base/tab-slider/index.tsx index 93dbbe3f62..5e290d1dc9 100644 --- a/web/app/components/base/tab-slider/index.tsx +++ b/web/app/components/base/tab-slider/index.tsx @@ -40,7 +40,7 @@ const TabSlider: FC = ({ const newIndex = options.findIndex(option => option.value === value) setActiveIndex(newIndex) updateSliderStyle(newIndex) - }, [value, options]) + }, [value, options, pluginList]) return (
diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx index 15c0f1f800..e8fdd69f0c 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx @@ -1,6 +1,6 @@ 'use client' -import React, { useCallback, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import Modal from '@/app/components/base/modal' import type { Item } from '@/app/components/base/select' import type { InstallState } from '@/app/components/plugins/types' @@ -134,6 +134,11 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on }) } + useEffect(() => { + if (state.step === InstallStepFromGitHub.selectPackage) + handleUrlSubmit() + }, []) + return ( { - const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/) + const match = url.match(/^https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/?$/) return match ? { isValid: true, owner: match[1], repo: match[2] } : { isValid: false } } diff --git a/web/app/components/plugins/plugin-item/action.tsx b/web/app/components/plugins/plugin-item/action.tsx index 6d02eee345..624adf87b0 100644 --- a/web/app/components/plugins/plugin-item/action.tsx +++ b/web/app/components/plugins/plugin-item/action.tsx @@ -1,7 +1,7 @@ 'use client' import type { FC } from 'react' import React, { useCallback } from 'react' -import type { MetaData } from '../types' +import { type MetaData, PluginSource } from '../types' import { RiDeleteBinLine, RiInformation2Line, RiLoopLeftLine } from '@remixicon/react' import { useBoolean } from 'ahooks' import { useTranslation } from 'react-i18next' @@ -13,6 +13,7 @@ import { uninstallPlugin } from '@/service/plugins' import { useGitHubReleases } from '../install-plugin/hooks' import { compareVersion, getLatestVersion } from '@/utils/semver' import Toast from '@/app/components/base/toast' +import { useModalContext } from '@/context/modal-context' const i18nPrefix = 'plugin.action' @@ -49,6 +50,7 @@ const Action: FC = ({ setFalse: hideDeleting, }] = useBoolean(false) const { fetchReleases } = useGitHubReleases() + const { setShowUpdatePluginModal } = useModalContext() const handleFetchNewVersion = async () => { try { @@ -56,8 +58,19 @@ const Action: FC = ({ const versions = fetchedReleases.map(release => release.tag_name) const latestVersion = getLatestVersion(versions) if (compareVersion(latestVersion, version) === 1) { - // todo: open plugin updating modal - console.log('New version available:', latestVersion) + setShowUpdatePluginModal({ + payload: { + type: PluginSource.github, + github: { + originalPackageInfo: { + id: installationId, + repo: `https://github.com/${meta!.repo}`, + version: meta!.version, + package: meta!.package, + }, + }, + }, + }) } else { Toast.notify({ @@ -87,7 +100,7 @@ const Action: FC = ({ hideDeleteConfirm() onDelete() } - }, [installationId]) + }, [installationId, onDelete]) return (
{/* Only plugin installed from GitHub need to check if it's the new version */} diff --git a/web/app/components/plugins/plugin-item/index.tsx b/web/app/components/plugins/plugin-item/index.tsx index 190f962167..ad5860801d 100644 --- a/web/app/components/plugins/plugin-item/index.tsx +++ b/web/app/components/plugins/plugin-item/index.tsx @@ -125,7 +125,7 @@ const PluginItem: FC = ({
{source === PluginSource.github && <> - +
{t('plugin.from')}