mirror of https://github.com/langgenius/dify.git
fix: update currentTriggerPlugin check in BasePanel component (#28287)
This commit is contained in:
parent
5d2fbf5215
commit
ad7fdd18d0
|
|
@ -24,8 +24,8 @@ import { debounce } from 'lodash-es'
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import LogViewer from '../log-viewer'
|
import LogViewer from '../log-viewer'
|
||||||
import { usePluginSubscriptionStore } from '../store'
|
|
||||||
import { usePluginStore } from '../../store'
|
import { usePluginStore } from '../../store'
|
||||||
|
import { useSubscriptionList } from '../use-subscription-list'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
|
|
@ -91,7 +91,7 @@ const MultiSteps = ({ currentStep }: { currentStep: ApiKeyStep }) => {
|
||||||
export const CommonCreateModal = ({ onClose, createType, builder }: Props) => {
|
export const CommonCreateModal = ({ onClose, createType, builder }: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const detail = usePluginStore(state => state.detail)
|
const detail = usePluginStore(state => state.detail)
|
||||||
const { refresh } = usePluginSubscriptionStore()
|
const { refetch } = useSubscriptionList()
|
||||||
|
|
||||||
const [currentStep, setCurrentStep] = useState<ApiKeyStep>(createType === SupportedCreationMethods.APIKEY ? ApiKeyStep.Verify : ApiKeyStep.Configuration)
|
const [currentStep, setCurrentStep] = useState<ApiKeyStep>(createType === SupportedCreationMethods.APIKEY ? ApiKeyStep.Verify : ApiKeyStep.Configuration)
|
||||||
|
|
||||||
|
|
@ -295,7 +295,7 @@ export const CommonCreateModal = ({ onClose, createType, builder }: Props) => {
|
||||||
message: t('pluginTrigger.subscription.createSuccess'),
|
message: t('pluginTrigger.subscription.createSuccess'),
|
||||||
})
|
})
|
||||||
onClose()
|
onClose()
|
||||||
refresh?.()
|
refetch?.()
|
||||||
},
|
},
|
||||||
onError: async (error: any) => {
|
onError: async (error: any) => {
|
||||||
const errorMessage = await parsePluginErrorMessage(error) || t('pluginTrigger.subscription.createFailed')
|
const errorMessage = await parsePluginErrorMessage(error) || t('pluginTrigger.subscription.createFailed')
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import Toast from '@/app/components/base/toast'
|
||||||
import { useDeleteTriggerSubscription } from '@/service/use-triggers'
|
import { useDeleteTriggerSubscription } from '@/service/use-triggers'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { usePluginSubscriptionStore } from './store'
|
import { useSubscriptionList } from './use-subscription-list'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onClose: (deleted: boolean) => void
|
onClose: (deleted: boolean) => void
|
||||||
|
|
@ -18,7 +18,7 @@ const tPrefix = 'pluginTrigger.subscription.list.item.actions.deleteConfirm'
|
||||||
|
|
||||||
export const DeleteConfirm = (props: Props) => {
|
export const DeleteConfirm = (props: Props) => {
|
||||||
const { onClose, isShow, currentId, currentName, workflowsInUse } = props
|
const { onClose, isShow, currentId, currentName, workflowsInUse } = props
|
||||||
const { refresh } = usePluginSubscriptionStore()
|
const { refetch } = useSubscriptionList()
|
||||||
const { mutate: deleteSubscription, isPending: isDeleting } = useDeleteTriggerSubscription()
|
const { mutate: deleteSubscription, isPending: isDeleting } = useDeleteTriggerSubscription()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [inputName, setInputName] = useState('')
|
const [inputName, setInputName] = useState('')
|
||||||
|
|
@ -40,7 +40,7 @@ export const DeleteConfirm = (props: Props) => {
|
||||||
message: t(`${tPrefix}.success`, { name: currentName }),
|
message: t(`${tPrefix}.success`, { name: currentName }),
|
||||||
className: 'z-[10000001]',
|
className: 'z-[10000001]',
|
||||||
})
|
})
|
||||||
refresh?.()
|
refetch?.()
|
||||||
onClose(true)
|
onClose(true)
|
||||||
},
|
},
|
||||||
onError: (error: any) => {
|
onError: (error: any) => {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import { create } from 'zustand'
|
|
||||||
|
|
||||||
type ShapeSubscription = {
|
|
||||||
refresh?: () => void
|
|
||||||
setRefresh: (refresh: () => void) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export const usePluginSubscriptionStore = create<ShapeSubscription>(set => ({
|
|
||||||
refresh: undefined,
|
|
||||||
setRefresh: (refresh: () => void) => set({ refresh }),
|
|
||||||
}))
|
|
||||||
|
|
@ -1,19 +1,11 @@
|
||||||
import { useEffect } from 'react'
|
|
||||||
import { useTriggerSubscriptions } from '@/service/use-triggers'
|
import { useTriggerSubscriptions } from '@/service/use-triggers'
|
||||||
import { usePluginStore } from '../store'
|
import { usePluginStore } from '../store'
|
||||||
import { usePluginSubscriptionStore } from './store'
|
|
||||||
|
|
||||||
export const useSubscriptionList = () => {
|
export const useSubscriptionList = () => {
|
||||||
const detail = usePluginStore(state => state.detail)
|
const detail = usePluginStore(state => state.detail)
|
||||||
const { setRefresh } = usePluginSubscriptionStore()
|
|
||||||
|
|
||||||
const { data: subscriptions, isLoading, refetch } = useTriggerSubscriptions(detail?.provider || '')
|
const { data: subscriptions, isLoading, refetch } = useTriggerSubscriptions(detail?.provider || '')
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (refetch)
|
|
||||||
setRefresh(refetch)
|
|
||||||
}, [refetch, setRefresh])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
detail,
|
detail,
|
||||||
subscriptions,
|
subscriptions,
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
||||||
const { setDetail } = usePluginStore()
|
const { setDetail } = usePluginStore()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentTriggerPlugin?.subscription_constructor) {
|
if (currentTriggerPlugin) {
|
||||||
setDetail({
|
setDetail({
|
||||||
name: currentTriggerPlugin.label[language],
|
name: currentTriggerPlugin.label[language],
|
||||||
plugin_id: currentTriggerPlugin.plugin_id || '',
|
plugin_id: currentTriggerPlugin.plugin_id || '',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue