mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
fix(trigger): invalid subscription
This commit is contained in:
@ -67,6 +67,7 @@ export const DeleteConfirm = (props: Props) => {
|
||||
: t(`${tPrefix}.content`)}
|
||||
isShow={isShow}
|
||||
isLoading={isDeleting}
|
||||
isDisabled={isDeleting}
|
||||
onConfirm={onConfirm}
|
||||
onCancel={() => onClose(false)}
|
||||
maskClosable={false}
|
||||
|
||||
@ -20,8 +20,6 @@ type SubscriptionTriggerButtonProps = {
|
||||
onSelect: (v: SimpleSubscription, callback?: () => void) => void
|
||||
}
|
||||
|
||||
export const INVALID_SUBSCRIPTION_ID = 'INVALID_SUBSCRIPTION_ID'
|
||||
|
||||
const SubscriptionTriggerButton: React.FC<SubscriptionTriggerButtonProps> = ({
|
||||
selectedId,
|
||||
onClick,
|
||||
@ -46,19 +44,25 @@ const SubscriptionTriggerButton: React.FC<SubscriptionTriggerButtonProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
const selectedSubscription = subscriptions?.find(sub => sub.id === selectedId)
|
||||
if (subscriptions && subscriptions.length > 0) {
|
||||
const selectedSubscription = subscriptions?.find(sub => sub.id === selectedId)
|
||||
|
||||
if (!selectedSubscription) {
|
||||
return {
|
||||
label: t('pluginTrigger.subscription.subscriptionRemoved'),
|
||||
color: 'red' as const,
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedSubscription) {
|
||||
onSelect({ id: INVALID_SUBSCRIPTION_ID, name: '' } as SimpleSubscription)
|
||||
return {
|
||||
label: t('pluginTrigger.subscription.subscriptionRemoved'),
|
||||
color: 'red' as const,
|
||||
label: selectedSubscription.name,
|
||||
color: 'green' as const,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
label: selectedSubscription.name,
|
||||
color: 'green' as const,
|
||||
label: t('pluginTrigger.subscription.noSubscriptionSelected'),
|
||||
color: 'red' as const,
|
||||
}
|
||||
}, [selectedId, subscriptions, t, isOpen])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user