mirror of https://github.com/langgenius/dify.git
Add toast notifications to TriggerCard toggle operations
This commit is contained in:
parent
8d4a9df6b1
commit
7da22e4915
|
|
@ -130,6 +130,7 @@ const CardView: FC<ICardViewProps> = ({ appId, isInPanel, className }) => {
|
|||
{showTriggerCard && (
|
||||
<TriggerCard
|
||||
appInfo={appDetail}
|
||||
onToggleResult={handleCallbackResult}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import { BlockEnum } from '@/app/components/workflow/types'
|
|||
|
||||
export type ITriggerCardProps = {
|
||||
appInfo: AppDetailResponse & Partial<AppSSO>
|
||||
onToggleResult?: (err: Error | null, message?: string) => void
|
||||
}
|
||||
|
||||
const getTriggerIcon = (trigger: AppTrigger, triggerPlugins: any[]) => {
|
||||
|
|
@ -79,7 +80,7 @@ const getTriggerIcon = (trigger: AppTrigger, triggerPlugins: any[]) => {
|
|||
)
|
||||
}
|
||||
|
||||
function TriggerCard({ appInfo }: ITriggerCardProps) {
|
||||
function TriggerCard({ appInfo, onToggleResult }: ITriggerCardProps) {
|
||||
const { t } = useTranslation()
|
||||
const appId = appInfo.id
|
||||
const { isCurrentWorkspaceEditor } = useAppContext()
|
||||
|
|
@ -120,12 +121,17 @@ function TriggerCard({ appInfo }: ITriggerCardProps) {
|
|||
enableTrigger: enabled,
|
||||
})
|
||||
invalidateAppTriggers(appId)
|
||||
|
||||
// Success toast notification
|
||||
onToggleResult?.(null)
|
||||
}
|
||||
catch (error) {
|
||||
// Rollback Zustand store state on error
|
||||
const rollbackStatus = enabled ? 'disabled' : 'enabled'
|
||||
setTriggerStatus(trigger.node_id, rollbackStatus)
|
||||
console.error('Failed to update trigger status:', error)
|
||||
|
||||
// Error toast notification
|
||||
onToggleResult?.(error as Error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue