Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
'use client'
import type { TriggerSubscription } from '@/app/components/workflow/block-selector/types'
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { CreateSubscriptionButton } from './create'
import { CreateButtonType } from './create/types'
import { DeleteConfirm } from './delete-confirm'
import { useSubscriptionList } from './use-subscription-list'
type SubscriptionSelectorProps = {
selectedId?: string
onSelect?: ({ id, name }: { id: string; name: string }) => void
}
export const SubscriptionSelectorView: React.FC<SubscriptionSelectorProps> = ({
selectedId,
onSelect,
}) => {
const titleId = React.useId()
const { t } = useTranslation(['common', 'pluginTrigger'])
const { subscriptions } = useSubscriptionList()
const [deletedSubscription, setDeletedSubscription] = useState<TriggerSubscription | null>(null)
const subscriptionCount = subscriptions?.length || 0
return (
<div className="w-[320px] p-1">
{subscriptionCount > 0 && (
<div className="mr-1.5 ml-7 flex h-8 items-center justify-between">
<div className="flex shrink-0 items-center gap-1">
<span id={titleId} className="system-sm-semibold-uppercase text-text-secondary">
{t(($) => $['subscription.listNum'], { ns: 'pluginTrigger', num: subscriptionCount })}
</span>
<Infotip>
<InfotipTrigger aria-labelledby={titleId} className="size-3.5" />
<InfotipContent aria-labelledby={titleId}>
{t(($) => $['subscription.list.tip'], { ns: 'pluginTrigger' })}
</InfotipContent>
</Infotip>
</div>
<CreateSubscriptionButton buttonType={CreateButtonType.ICON_BUTTON} shape="circle" />
</div>
)}
<div className="max-h-80 overflow-y-auto">
{subscriptions?.map((subscription) => (
<div
key={subscription.id}
className={cn(
'group flex w-full items-center justify-between rounded-lg p-1 text-left transition-colors',
'hover:bg-state-base-hover has-[.subscription-delete-btn:hover]:bg-state-destructive-hover!',
selectedId === subscription.id && 'bg-state-base-hover',
)}
>
<button
type="button"
className="flex flex-1 items-center text-left"
onClick={() => onSelect?.(subscription)}
>
<div className="flex items-center">
{selectedId === subscription.id && (
<span
aria-hidden
className="mr-2 i-ri-check-line size-4 shrink-0 text-text-accent"
/>
)}
<span
aria-hidden
className={cn(
'mr-1.5 i-ri-webhook-line size-3.5 text-text-secondary',
selectedId !== subscription.id && 'ml-6',
)}
/>
<span className="system-md-regular leading-6 text-text-secondary">
{subscription.name}
</span>
</div>
</button>
<IconButton
aria-label={t(($) => $['operation.delete'], { ns: 'common' })}
tone="destructive"
onClick={(e) => {
e.stopPropagation()
setDeletedSubscription(subscription)
}}
className="subscription-delete-btn hidden shrink-0 group-hover:flex"
>
<span aria-hidden="true" className="i-ri-delete-bin-line size-4" />
</IconButton>
</div>
))}
</div>
{deletedSubscription && (
<DeleteConfirm
onClose={(deleted) => {
if (deleted) onSelect?.({ id: '', name: '' })
setDeletedSubscription(null)
}}
isShow={!!deletedSubscription}
currentId={deletedSubscription.id}
currentName={deletedSubscription.name}
workflowsInUse={deletedSubscription.workflows_in_use}
/>
)}
</div>
)
}