mirror of
https://github.com/langgenius/dify.git
synced 2025-06-27 05:30:04 +00:00
Compare commits
8 Commits
4c583f3d9a
...
afd0d31354
Author | SHA1 | Date | |
---|---|---|---|
![]() |
afd0d31354 | ||
![]() |
18bbf1165d | ||
![]() |
5f17edc77f | ||
![]() |
836027cb33 | ||
![]() |
f3cbfe2223 | ||
![]() |
bc1e4c88e0 | ||
![]() |
d114485abd | ||
![]() |
3e8a4a66fe |
@ -0,0 +1,7 @@
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M28.0049 16C28.0049 20.4183 24.4231 24 20.0049 24C15.5866 24 12.0049 20.4183 12.0049 16C12.0049 11.5817 15.5866 8 20.0049 8C24.4231 8 28.0049 11.5817 28.0049 16Z" stroke="#676F83" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.00488 16H6.67155" stroke="#676F83" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.00488 9.33334H8.00488" stroke="#676F83" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.00488 22.6667H8.00488" stroke="#676F83" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M26 22L29.3333 25.3333" stroke="#676F83" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 823 B |
37
web/app/components/base/icons/src/public/llm/OpenaiTale.json
Normal file
37
web/app/components/base/icons/src/public/llm/OpenaiTale.json
Normal file
File diff suppressed because one or more lines are too long
20
web/app/components/base/icons/src/public/llm/OpenaiTale.tsx
Normal file
20
web/app/components/base/icons/src/public/llm/OpenaiTale.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
// GENERATE BY script
|
||||
// DON NOT EDIT IT MANUALLY
|
||||
|
||||
import * as React from 'react'
|
||||
import data from './OpenaiTale.json'
|
||||
import IconBase from '@/app/components/base/icons/IconBase'
|
||||
import type { IconData } from '@/app/components/base/icons/IconBase'
|
||||
|
||||
const Icon = (
|
||||
{
|
||||
ref,
|
||||
...props
|
||||
}: React.SVGProps<SVGSVGElement> & {
|
||||
ref?: React.RefObject<React.MutableRefObject<HTMLOrSVGElement>>;
|
||||
},
|
||||
) => <IconBase {...props} ref={ref} data={data as IconData} />
|
||||
|
||||
Icon.displayName = 'OpenaiTale'
|
||||
|
||||
export default Icon
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,20 @@
|
||||
// GENERATE BY script
|
||||
// DON NOT EDIT IT MANUALLY
|
||||
|
||||
import * as React from 'react'
|
||||
import data from './OpenaiYellow.json'
|
||||
import IconBase from '@/app/components/base/icons/IconBase'
|
||||
import type { IconData } from '@/app/components/base/icons/IconBase'
|
||||
|
||||
const Icon = (
|
||||
{
|
||||
ref,
|
||||
...props
|
||||
}: React.SVGProps<SVGSVGElement> & {
|
||||
ref?: React.RefObject<React.MutableRefObject<HTMLOrSVGElement>>;
|
||||
},
|
||||
) => <IconBase {...props} ref={ref} data={data as IconData} />
|
||||
|
||||
Icon.displayName = 'OpenaiYellow'
|
||||
|
||||
export default Icon
|
@ -31,7 +31,9 @@ export { default as OpenaiGreen } from './OpenaiGreen'
|
||||
export { default as OpenaiText } from './OpenaiText'
|
||||
export { default as OpenaiTransparent } from './OpenaiTransparent'
|
||||
export { default as OpenaiViolet } from './OpenaiViolet'
|
||||
export { default as OpenaiTale } from './OpenaiTale'
|
||||
export { default as OpenllmText } from './OpenllmText'
|
||||
export { default as OpenaiYellow } from './OpenaiYellow'
|
||||
export { default as Openllm } from './Openllm'
|
||||
export { default as ReplicateText } from './ReplicateText'
|
||||
export { default as Replicate } from './Replicate'
|
||||
|
@ -0,0 +1,77 @@
|
||||
{
|
||||
"icon": {
|
||||
"type": "element",
|
||||
"isRootNode": true,
|
||||
"name": "svg",
|
||||
"attributes": {
|
||||
"width": "32",
|
||||
"height": "32",
|
||||
"viewBox": "0 0 32 32",
|
||||
"fill": "none",
|
||||
"xmlns": "http://www.w3.org/2000/svg"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"d": "M28.0049 16C28.0049 20.4183 24.4231 24 20.0049 24C15.5866 24 12.0049 20.4183 12.0049 16C12.0049 11.5817 15.5866 8 20.0049 8C24.4231 8 28.0049 11.5817 28.0049 16Z",
|
||||
"stroke": "currentColor",
|
||||
"stroke-width": "2",
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linejoin": "round"
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"d": "M4.00488 16H6.67155",
|
||||
"stroke": "currentColor",
|
||||
"stroke-width": "2",
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linejoin": "round"
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"d": "M4.00488 9.33334H8.00488",
|
||||
"stroke": "currentColor",
|
||||
"stroke-width": "2",
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linejoin": "round"
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"d": "M4.00488 22.6667H8.00488",
|
||||
"stroke": "currentColor",
|
||||
"stroke-width": "2",
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linejoin": "round"
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"d": "M26 22L29.3333 25.3333",
|
||||
"stroke": "currentColor",
|
||||
"stroke-width": "2",
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linejoin": "round"
|
||||
},
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": "SearchMenu"
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// GENERATE BY script
|
||||
// DON NOT EDIT IT MANUALLY
|
||||
|
||||
import * as React from 'react'
|
||||
import data from './SearchMenu.json'
|
||||
import IconBase from '@/app/components/base/icons/IconBase'
|
||||
import type { IconData } from '@/app/components/base/icons/IconBase'
|
||||
|
||||
const Icon = (
|
||||
{
|
||||
ref,
|
||||
...props
|
||||
}: React.SVGProps<SVGSVGElement> & {
|
||||
ref?: React.RefObject<React.MutableRefObject<HTMLOrSVGElement>>;
|
||||
},
|
||||
) => <IconBase {...props} ref={ref} data={data as IconData} />
|
||||
|
||||
Icon.displayName = 'SearchMenu'
|
||||
|
||||
export default Icon
|
@ -19,6 +19,7 @@ export { default as Pin01 } from './Pin01'
|
||||
export { default as Pin02 } from './Pin02'
|
||||
export { default as Plus02 } from './Plus02'
|
||||
export { default as Refresh } from './Refresh'
|
||||
export { default as SearchMenu } from './SearchMenu'
|
||||
export { default as Settings01 } from './Settings01'
|
||||
export { default as Settings04 } from './Settings04'
|
||||
export { default as Target04 } from './Target04'
|
||||
|
@ -10,7 +10,7 @@ import type { ExposeRefs } from './install-multi'
|
||||
import InstallMulti from './install-multi'
|
||||
import { useInstallOrUpdate } from '@/service/use-plugins'
|
||||
import useRefreshPluginList from '../../hooks/use-refresh-plugin-list'
|
||||
import { useCanInstallPluginFromMarketplace } from '@/app/components/plugins/plugin-page/use-permission'
|
||||
import { useCanInstallPluginFromMarketplace } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import { useMittContextSelector } from '@/context/mitt-context'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
const i18nPrefix = 'plugin.installModal'
|
||||
|
@ -39,6 +39,9 @@ import { AutoUpdateLine } from '../../base/icons/src/vender/system'
|
||||
import { timeOfDayToDayjs } from '../reference-setting-modal/auto-update-setting/utils'
|
||||
import DowngradeWarningModal from '../update-plugin/downgrade-warning-modal'
|
||||
import { getMarketplaceUrl } from '@/utils/var'
|
||||
import useReferenceSetting from '../plugin-page/use-reference-setting'
|
||||
import { AUTO_UPDATE_MODE } from '../reference-setting-modal/auto-update-setting/types'
|
||||
import { useInvalidateReferenceSettings, useRemoveAutoUpgrade } from '@/service/use-plugins'
|
||||
|
||||
const i18nPrefix = 'plugin.action'
|
||||
|
||||
@ -100,7 +103,20 @@ const DetailHeader = ({
|
||||
setFalse: hideUpdateModal,
|
||||
}] = useBoolean(false)
|
||||
|
||||
const isAutoUpgradeEnabled = true // toeo
|
||||
const { referenceSetting } = useReferenceSetting()
|
||||
const { auto_upgrade: autoUpgradeInfo } = referenceSetting || {}
|
||||
const isAutoUpgradeEnabled = useMemo(() => {
|
||||
if(!autoUpgradeInfo)
|
||||
return false
|
||||
if(autoUpgradeInfo.upgrade_mode === AUTO_UPDATE_MODE.update_all)
|
||||
return true
|
||||
if(autoUpgradeInfo.upgrade_mode === AUTO_UPDATE_MODE.partial && autoUpgradeInfo.include_plugins.includes(plugin_id))
|
||||
return true
|
||||
if(autoUpgradeInfo.upgrade_mode === AUTO_UPDATE_MODE.exclude && !autoUpgradeInfo.exclude_plugins.includes(plugin_id))
|
||||
return true
|
||||
return false
|
||||
}, [autoUpgradeInfo, plugin_id])
|
||||
|
||||
const [isShowDowngradeWarningModal, {
|
||||
setTrue: showDowngradeWarningModal,
|
||||
setFalse: hideDowngradeWarningModal,
|
||||
@ -150,9 +166,16 @@ const DetailHeader = ({
|
||||
hideDowngradeWarningModal()
|
||||
}
|
||||
|
||||
const { mutateAsync } = useRemoveAutoUpgrade()
|
||||
const invalidateReferenceSettings = useInvalidateReferenceSettings()
|
||||
|
||||
const handleExcludeAndDownload = async () => {
|
||||
// TODO: exclude logic
|
||||
onUpdate()
|
||||
await mutateAsync({
|
||||
plugin_id,
|
||||
})
|
||||
invalidateReferenceSettings()
|
||||
// TODO: missing do upgrade logic
|
||||
handleUpdatedFromMarketplace()
|
||||
hideDowngradeWarningModal()
|
||||
}
|
||||
|
||||
@ -185,9 +208,6 @@ const DetailHeader = ({
|
||||
}
|
||||
}, [showDeleting, installation_id, hideDeleting, hideDeleteConfirm, onUpdate, category, refreshModelProviders, invalidateAllToolProviders])
|
||||
|
||||
// #plugin TODO# used in apps
|
||||
// const usedInApps = 3
|
||||
|
||||
return (
|
||||
<div className={cn('shrink-0 border-b border-divider-subtle bg-components-panel-bg p-4 pb-3')}>
|
||||
<div className="flex">
|
||||
@ -227,14 +247,17 @@ const DetailHeader = ({
|
||||
}
|
||||
/>
|
||||
{/* Auto update info */}
|
||||
<Tooltip popupContent={t('plugin.autoUpdate.nextUpdateTime', { time: timeOfDayToDayjs(3600).format('hh:mm A') })}>
|
||||
{/* add a a div to fix tooltip hover not show problem */}
|
||||
<div>
|
||||
<Badge className='mr-1 cursor-pointer px-1'>
|
||||
<AutoUpdateLine className='size-3' />
|
||||
</Badge>
|
||||
</div>
|
||||
</Tooltip>
|
||||
{isAutoUpgradeEnabled && (
|
||||
<Tooltip popupContent={t('plugin.autoUpdate.nextUpdateTime', { time: timeOfDayToDayjs(autoUpgradeInfo?.upgrade_time_of_day || 0).format('hh:mm A') })}>
|
||||
{/* add a a div to fix tooltip hover not show problem */}
|
||||
<div>
|
||||
<Badge className='mr-1 cursor-pointer px-1'>
|
||||
<AutoUpdateLine className='size-3' />
|
||||
</Badge>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{(hasNewVersion || isFromGitHub) && (
|
||||
<Button variant='secondary-accent' size='small' className='!h-5' onClick={() => {
|
||||
if (isFromMarketplace) {
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
} from './context'
|
||||
import InstallPluginDropdown from './install-plugin-dropdown'
|
||||
import { useUploader } from './use-uploader'
|
||||
import usePermission from './use-permission'
|
||||
import useReferenceSetting from './use-reference-setting'
|
||||
import DebugInfo from './debug-info'
|
||||
import PluginTasks from './plugin-tasks'
|
||||
import Button from '@/app/components/base/button'
|
||||
@ -121,12 +121,12 @@ const PluginPage = ({
|
||||
}, [packageId, bundleInfo])
|
||||
|
||||
const {
|
||||
referenceSetting,
|
||||
canManagement,
|
||||
canDebugger,
|
||||
canSetPermissions,
|
||||
permissions,
|
||||
setPermissions,
|
||||
} = usePermission()
|
||||
setReferenceSettings,
|
||||
} = useReferenceSetting()
|
||||
const [showPluginSettingModal, {
|
||||
setTrue: setShowPluginSettingModal,
|
||||
setFalse: setHidePluginSettingModal,
|
||||
@ -277,9 +277,9 @@ const PluginPage = ({
|
||||
|
||||
{showPluginSettingModal && (
|
||||
<ReferenceSettingModal
|
||||
payload={permissions!}
|
||||
payload={referenceSetting!}
|
||||
onHide={setHidePluginSettingModal}
|
||||
onSave={setPermissions}
|
||||
onSave={setReferenceSettings}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { PermissionType } from '../types'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import Toast from '../../base/toast'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useInvalidatePermissions, useMutationPermissions, usePermissions } from '@/service/use-plugins'
|
||||
import { useInvalidateReferenceSettings, useMutationReferenceSettings, useReferenceSettings } from '@/service/use-plugins'
|
||||
import { useMemo } from 'react'
|
||||
import { useGlobalPublicStore } from '@/context/global-public-context'
|
||||
|
||||
@ -19,14 +19,16 @@ const hasPermission = (permission: PermissionType | undefined, isAdmin: boolean)
|
||||
return isAdmin
|
||||
}
|
||||
|
||||
const usePermission = () => {
|
||||
const useReferenceSetting = () => {
|
||||
const { t } = useTranslation()
|
||||
const { isCurrentWorkspaceManager, isCurrentWorkspaceOwner } = useAppContext()
|
||||
const { data: permissions } = usePermissions()
|
||||
const invalidatePermissions = useInvalidatePermissions()
|
||||
const { mutate: updatePermission, isPending: isUpdatePending } = useMutationPermissions({
|
||||
const { data } = useReferenceSettings()
|
||||
// console.log(data)
|
||||
const { permission: permissions } = data || {}
|
||||
const invalidateReferenceSettings = useInvalidateReferenceSettings()
|
||||
const { mutate: updateReferenceSetting, isPending: isUpdatePending } = useMutationReferenceSettings({
|
||||
onSuccess: () => {
|
||||
invalidatePermissions()
|
||||
invalidateReferenceSettings()
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: t('common.api.actionSuccess'),
|
||||
@ -36,18 +38,18 @@ const usePermission = () => {
|
||||
const isAdmin = isCurrentWorkspaceManager || isCurrentWorkspaceOwner
|
||||
|
||||
return {
|
||||
referenceSetting: data,
|
||||
setReferenceSettings: updateReferenceSetting,
|
||||
canManagement: hasPermission(permissions?.install_permission, isAdmin),
|
||||
canDebugger: hasPermission(permissions?.debug_permission, isAdmin),
|
||||
canSetPermissions: isAdmin,
|
||||
permissions,
|
||||
setPermissions: updatePermission,
|
||||
isUpdatePending,
|
||||
}
|
||||
}
|
||||
|
||||
export const useCanInstallPluginFromMarketplace = () => {
|
||||
const { enable_marketplace } = useGlobalPublicStore(s => s.systemFeatures)
|
||||
const { canManagement } = usePermission()
|
||||
const { canManagement } = useReferenceSetting()
|
||||
|
||||
const canInstallPluginFromMarketplace = useMemo(() => {
|
||||
return enable_marketplace && canManagement
|
||||
@ -58,4 +60,4 @@ export const useCanInstallPluginFromMarketplace = () => {
|
||||
}
|
||||
}
|
||||
|
||||
export default usePermission
|
||||
export default useReferenceSetting
|
@ -1,9 +1,9 @@
|
||||
import type { AutoUpdateConfig } from './types'
|
||||
import { AUTO_UPDATE_MODE, AUTO_UPDATE_STRATEGY } from './types'
|
||||
export const defaultValue: AutoUpdateConfig = {
|
||||
strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly, // For test
|
||||
strategy_setting: AUTO_UPDATE_STRATEGY.disabled,
|
||||
upgrade_time_of_day: 0,
|
||||
upgrade_mode: AUTO_UPDATE_MODE.exclude, // For test
|
||||
exclude_plugins: ['langgenius/openai_api_compatible', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai', 'langgenius/openai'],
|
||||
include_plugins: ['langgenius/openai'],
|
||||
upgrade_mode: AUTO_UPDATE_MODE.update_all,
|
||||
exclude_plugins: [],
|
||||
include_plugins: [],
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import cn from '@/utils/classnames'
|
||||
import { Group } from '@/app/components/base/icons/src/vender/other'
|
||||
import { SearchMenu } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
type Props = {
|
||||
className: string
|
||||
noPlugins?: boolean
|
||||
}
|
||||
|
||||
const NoDataPlaceholder: FC<Props> = ({
|
||||
className,
|
||||
noPlugins,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const icon = noPlugins ? (<Group className='size-6 text-text-quaternary' />) : (<SearchMenu className='size-8 text-text-tertiary' />)
|
||||
const text = t(`plugin.autoUpdate.noPluginPlaceholder.${noPlugins ? 'noInstalled' : 'noFound'}`)
|
||||
return (
|
||||
<div className={cn('flex items-center justify-center', className)}>
|
||||
<div className='flex flex-col items-center'>
|
||||
{icon}
|
||||
<div className='system-sm-regular mt-2 text-text-tertiary'>{text}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(NoDataPlaceholder)
|
@ -12,6 +12,8 @@ import SearchBox from '@/app/components/plugins/marketplace/search-box'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from '@/utils/classnames'
|
||||
import ToolItem from './tool-item'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import NoDataPlaceholder from './no-data-placeholder'
|
||||
|
||||
type Props = {
|
||||
trigger: React.ReactNode
|
||||
@ -64,7 +66,7 @@ const ToolPicker: FC<Props> = ({
|
||||
const [pluginType, setPluginType] = useState(PLUGIN_TYPE_SEARCH_MAP.all)
|
||||
const [query, setQuery] = useState('')
|
||||
const [tags, setTags] = useState<string[]>([])
|
||||
const { data } = useFetchPluginListOrBundleList({
|
||||
const { data, isLoading } = useFetchPluginListOrBundleList({
|
||||
query,
|
||||
tags,
|
||||
category: pluginType,
|
||||
@ -79,6 +81,30 @@ const ToolPicker: FC<Props> = ({
|
||||
onChange(newValue)
|
||||
}
|
||||
}, [onChange, value])
|
||||
|
||||
const listContent = (
|
||||
<div className='max-h-[396px] overflow-y-auto'>
|
||||
{list.map(item => (
|
||||
<ToolItem
|
||||
key={item.plugin_id}
|
||||
payload={item}
|
||||
isChecked={value.includes(item.plugin_id)}
|
||||
onCheckChange={handleCheckChange(item.plugin_id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
const loadingContent = (
|
||||
<div className='flex h-[396px] items-center justify-center'>
|
||||
<Loading />
|
||||
</div>
|
||||
)
|
||||
|
||||
const noData = (
|
||||
<NoDataPlaceholder className='h-[396px]' noPlugins={!query} />
|
||||
)
|
||||
|
||||
return (
|
||||
<PortalToFollowElem
|
||||
placement='top'
|
||||
@ -123,21 +149,13 @@ const ToolPicker: FC<Props> = ({
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{list.length > 0 && (
|
||||
<div className='max-h-[396px] overflow-y-auto'>
|
||||
{list.map(item => (
|
||||
<ToolItem
|
||||
key={item.plugin_id}
|
||||
payload={item}
|
||||
isChecked={value.includes(item.plugin_id)}
|
||||
onCheckChange={handleCheckChange(item.plugin_id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{!isLoading && list.length > 0 && listContent}
|
||||
{!isLoading && list.length === 0 && noData}
|
||||
{isLoading && loadingContent}
|
||||
</div>
|
||||
</PortalToFollowElemContent>
|
||||
</PortalToFollowElem>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(ToolPicker)
|
||||
|
@ -7,7 +7,7 @@ export enum AUTO_UPDATE_STRATEGY {
|
||||
export enum AUTO_UPDATE_MODE {
|
||||
partial = 'partial',
|
||||
exclude = 'exclude',
|
||||
update_all = 'update_all',
|
||||
update_all = 'all',
|
||||
}
|
||||
|
||||
export type AutoUpdateConfig = {
|
||||
|
@ -5,19 +5,18 @@ import { useTranslation } from 'react-i18next'
|
||||
import Modal from '@/app/components/base/modal'
|
||||
import OptionCard from '@/app/components/workflow/nodes/_base/components/option-card'
|
||||
import Button from '@/app/components/base/button'
|
||||
import type { Permissions } from '@/app/components/plugins/types'
|
||||
import type { Permissions, ReferenceSetting } from '@/app/components/plugins/types'
|
||||
import { PermissionType } from '@/app/components/plugins/types'
|
||||
import type { AutoUpdateConfig } from './auto-update-setting/types'
|
||||
import AutoUpdateSetting from './auto-update-setting'
|
||||
import { defaultValue as autoUpdateDefaultValue } from './auto-update-setting/config'
|
||||
import Label from './label'
|
||||
|
||||
type Payload = Permissions & { autoUpdate: AutoUpdateConfig }
|
||||
const i18nPrefix = 'plugin.privilege'
|
||||
type Props = {
|
||||
payload: Payload
|
||||
payload: ReferenceSetting
|
||||
onHide: () => void
|
||||
onSave: (payload: Payload) => void
|
||||
onSave: (payload: ReferenceSetting) => void
|
||||
}
|
||||
|
||||
const PluginSettingModal: FC<Props> = ({
|
||||
@ -26,7 +25,7 @@ const PluginSettingModal: FC<Props> = ({
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { autoUpdate: autoUpdateConfig, ...privilege } = payload || {}
|
||||
const { auto_upgrade: autoUpdateConfig, permission: privilege } = payload || {}
|
||||
const [tempPrivilege, setTempPrivilege] = useState<Permissions>(privilege)
|
||||
const [tempAutoUpdateConfig, setTempAutoUpdateConfig] = useState<AutoUpdateConfig>(autoUpdateConfig || autoUpdateDefaultValue)
|
||||
const handlePrivilegeChange = useCallback((key: string) => {
|
||||
@ -40,8 +39,8 @@ const PluginSettingModal: FC<Props> = ({
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
await onSave({
|
||||
...tempPrivilege,
|
||||
autoUpdate: tempAutoUpdateConfig,
|
||||
permission: tempPrivilege,
|
||||
auto_upgrade: tempAutoUpdateConfig,
|
||||
})
|
||||
onHide()
|
||||
}, [onHide, onSave, tempAutoUpdateConfig, tempPrivilege])
|
||||
|
@ -2,6 +2,7 @@ import type { CredentialFormSchemaBase } from '../header/account-setting/model-p
|
||||
import type { ToolCredential } from '@/app/components/tools/types'
|
||||
import type { Locale } from '@/i18n'
|
||||
import type { AgentFeature } from '@/app/components/workflow/nodes/agent/types'
|
||||
import type { AutoUpdateConfig } from './reference-setting-modal/auto-update-setting/types'
|
||||
export enum PluginType {
|
||||
tool = 'tool',
|
||||
model = 'model',
|
||||
@ -167,6 +168,11 @@ export type Permissions = {
|
||||
debug_permission: PermissionType
|
||||
}
|
||||
|
||||
export type ReferenceSetting = {
|
||||
permission: Permissions
|
||||
auto_upgrade: AutoUpdateConfig
|
||||
}
|
||||
|
||||
export type UpdateFromMarketPlacePayload = {
|
||||
category: PluginType
|
||||
originalPackageInfo: {
|
||||
|
@ -135,7 +135,7 @@ const translation = {
|
||||
},
|
||||
updateTimeTitle: 'Update time',
|
||||
upgradeMode: {
|
||||
update_all: 'Update all',
|
||||
all: 'Update all',
|
||||
exclude: 'Exclude selected',
|
||||
partial: 'Only selected',
|
||||
},
|
||||
@ -156,6 +156,10 @@ const translation = {
|
||||
downgrade: 'Downgrade anyway',
|
||||
exclude: 'Exclude from auto-update',
|
||||
},
|
||||
noPluginPlaceholder: {
|
||||
noFound: 'No plugins were found',
|
||||
noInstalled: 'No plugins installed',
|
||||
},
|
||||
},
|
||||
pluginInfoModal: {
|
||||
title: 'Plugin info',
|
||||
|
@ -135,7 +135,7 @@ const translation = {
|
||||
},
|
||||
updateTimeTitle: '更新时间',
|
||||
upgradeMode: {
|
||||
update_all: '更新全部',
|
||||
all: '更新全部',
|
||||
exclude: '排除选定',
|
||||
partial: '仅选定',
|
||||
},
|
||||
@ -156,6 +156,10 @@ const translation = {
|
||||
downgrade: '仍然降级',
|
||||
exclude: '从自动更新中排除',
|
||||
},
|
||||
noPluginPlaceholder: {
|
||||
noFound: '未找到插件',
|
||||
noInstalled: '未安装插件',
|
||||
},
|
||||
},
|
||||
pluginInfoModal: {
|
||||
title: '插件信息',
|
||||
|
@ -12,7 +12,6 @@ import type {
|
||||
InstalledLatestVersionResponse,
|
||||
InstalledPluginListWithTotalResponse,
|
||||
PackageDependency,
|
||||
Permissions,
|
||||
Plugin,
|
||||
PluginDeclaration,
|
||||
PluginDetail,
|
||||
@ -21,6 +20,7 @@ import type {
|
||||
PluginType,
|
||||
PluginsFromMarketplaceByInfoResponse,
|
||||
PluginsFromMarketplaceResponse,
|
||||
ReferenceSetting,
|
||||
VersionInfo,
|
||||
VersionListResponse,
|
||||
uploadGitHubResponse,
|
||||
@ -39,7 +39,7 @@ import {
|
||||
useQueryClient,
|
||||
} from '@tanstack/react-query'
|
||||
import { useInvalidateAllBuiltInTools } from './use-tools'
|
||||
import usePermission from '@/app/components/plugins/plugin-page/use-permission'
|
||||
import useReferenceSetting from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import { uninstallPlugin } from '@/service/plugins'
|
||||
import useRefreshPluginList from '@/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
@ -349,37 +349,45 @@ export const useDebugKey = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const usePermissionsKey = [NAME_SPACE, 'permissions']
|
||||
export const usePermissions = () => {
|
||||
const useReferenceSettingKey = [NAME_SPACE, 'referenceSettings']
|
||||
export const useReferenceSettings = () => {
|
||||
return useQuery({
|
||||
queryKey: usePermissionsKey,
|
||||
queryFn: () => get<Permissions>('/workspaces/current/plugin/permission/fetch'),
|
||||
queryKey: useReferenceSettingKey,
|
||||
queryFn: () => get<ReferenceSetting>('/workspaces/current/plugin/preferences/fetch'),
|
||||
})
|
||||
}
|
||||
|
||||
export const useInvalidatePermissions = () => {
|
||||
export const useInvalidateReferenceSettings = () => {
|
||||
const queryClient = useQueryClient()
|
||||
return () => {
|
||||
queryClient.invalidateQueries(
|
||||
{
|
||||
queryKey: usePermissionsKey,
|
||||
queryKey: useReferenceSettingKey,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const useMutationPermissions = ({
|
||||
export const useMutationReferenceSettings = ({
|
||||
onSuccess,
|
||||
}: {
|
||||
onSuccess?: () => void
|
||||
}) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: Permissions) => {
|
||||
return post('/workspaces/current/plugin/permission/change', { body: payload })
|
||||
mutationFn: (payload: ReferenceSetting) => {
|
||||
return post('/workspaces/current/plugin/preferences/change', { body: payload })
|
||||
},
|
||||
onSuccess,
|
||||
})
|
||||
}
|
||||
|
||||
export const useRemoveAutoUpgrade = () => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: { plugin_id: string }) => {
|
||||
return post('/workspaces/current/plugin/preferences/autoupgrade/exclude', { body: payload })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const useMutationPluginsFromMarketplace = () => {
|
||||
return useMutation({
|
||||
mutationFn: (pluginsSearchParams: PluginsSearchParams) => {
|
||||
@ -480,7 +488,7 @@ const usePluginTaskListKey = [NAME_SPACE, 'pluginTaskList']
|
||||
export const usePluginTaskList = (category?: PluginType) => {
|
||||
const {
|
||||
canManagement,
|
||||
} = usePermission()
|
||||
} = useReferenceSetting()
|
||||
const { refreshPluginList } = useRefreshPluginList()
|
||||
const {
|
||||
data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user