Files
dify/web/contract/console/plugins.ts
yyh 45c96dc254 feat(model-provider): add plugin update indicators and migrate to oRPC contracts
Problem: Model provider settings page (/plugins?action=showSettings&tab=provider)
was missing plugin update indicators (red dot badge, Update button) that the
/plugins page correctly displayed, because it only fetched installation data
without querying for latest marketplace versions.

Decision: Extract a shared usePluginsWithLatestVersion hook and migrate plugin
API endpoints to oRPC contracts, ensuring both pages use identical data flows.

Model: Both pages now follow the same pattern — fetch installed plugins via
consoleQuery.plugins.checkInstalled, enrich with latest version metadata via
usePluginsWithLatestVersion, then pass complete PluginDetail objects downstream
where useDetailHeaderState computes hasNewVersion for UI indicators.

Impact:
- Update badge red dot and Update button now appear on provider settings page
- Shared hook eliminates 15 lines of duplicate enrichment logic in plugins-panel
- oRPC contracts replace legacy post() calls for plugin endpoints
- Operation dropdown uses auto-width to prevent "View on Marketplace" text wrapping
- Version badge aligned to use Badge component consistently across both pages
- Update button tooltip added with bilingual i18n support
- Deprecated Tooltip migrated to Base UI Tooltip in detail-header
2026-03-10 23:28:09 +08:00

28 lines
699 B
TypeScript

import type { InstalledLatestVersionResponse, PluginDetail } from '@/app/components/plugins/types'
import { type } from '@orpc/contract'
import { base } from '../base'
export const pluginCheckInstalledContract = base
.route({
path: '/workspaces/current/plugin/list/installations/ids',
method: 'POST',
})
.input(type<{
body: {
plugin_ids: string[]
}
}>())
.output(type<{ plugins: PluginDetail[] }>())
export const pluginLatestVersionsContract = base
.route({
path: '/workspaces/current/plugin/list/latest-versions',
method: 'POST',
})
.input(type<{
body: {
plugin_ids: string[]
}
}>())
.output(type<InstalledLatestVersionResponse>())