Skip to content

armgit / dify

Public Imported from GitHub
0

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.

1.4 KB
Raw Blame
import type { SimpleSubscription } from './types'
import type { PluginDetail } from '@/app/components/plugins/types'
import { withErrorBoundary } from '@/app/components/base/error-boundary'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import { SubscriptionListView } from './list-view'
import { SubscriptionSelectorView } from './selector-view'
import { SubscriptionListMode } from './types'
import { useSubscriptionList } from './use-subscription-list'

type SubscriptionListProps = {
  mode?: SubscriptionListMode
  selectedId?: string
  onSelect?: (v: SimpleSubscription, callback?: () => void) => void
  pluginDetail?: PluginDetail
}

export type { SimpleSubscription } from './types'

export const SubscriptionList = withErrorBoundary(
  ({
    mode = SubscriptionListMode.PANEL,
    selectedId,
    onSelect,
    pluginDetail,
  }: SubscriptionListProps) => {
    const { isLoading, refetch } = useSubscriptionList()
    if (isLoading) {
      return (
        <div className="flex items-center justify-center py-4">
          <LoadingPlaceholder />
        </div>
      )
    }

    if (mode === SubscriptionListMode.SELECTOR) {
      return (
        <SubscriptionSelectorView
          selectedId={selectedId}
          onSelect={(v) => {
            onSelect?.(v, refetch)
          }}
        />
      )
    }

    return <SubscriptionListView pluginDetail={pluginDetail} />
  },
)