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.

3.9 KB
Raw Blame
'use client'

import type { MarketplaceTemplate } from '@dify/contracts/marketplace'
import type { ReactNode } from 'react'
import type {
  CreatorCreation,
  CreatorCreationAction,
  CreatorInventory,
  CreatorProfileViewModel,
} from './model'
import type { Plugin } from '@/app/components/plugins/types'
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'
import { cn } from '@langgenius/dify-ui/cn'
import { iconButtonVariants } from '@langgenius/dify-ui/icon-button'
import { useTranslation } from '#i18n'
import Link from '@/next/link'
import DefaultCreatorBackground from './assets/default-background.png'
import CreatorContent from './creator-content'
import CreatorSidebar from './creator-sidebar'

export type CreatorProfileViewProps = {
  profile: CreatorProfileViewModel
  getCreationAction: (creation: CreatorCreation) => CreatorCreationAction
  header?: ReactNode
  homeHref: string
  isMarketplacePlatform: boolean
  inventory?: CreatorInventory
  locale?: string
  onRecordsLoaded?: (records: {
    pluginsByCreationId: Record<string, Plugin>
    templatesByCreationId: Record<string, MarketplaceTemplate>
  }) => void
}

export default function CreatorProfileView({
  profile,
  getCreationAction,
  header,
  homeHref,
  isMarketplacePlatform,
  inventory,
  locale,
  onRecordsLoaded,
}: CreatorProfileViewProps) {
  const { t } = useTranslation(['plugin'])

  return (
    <div className="flex min-h-full shrink-0 flex-col bg-background-default">
      {header}
      <div
        className={cn(
          'flex w-full flex-1 flex-col px-4',
          isMarketplacePlatform ? 'md:px-6' : 'md:px-9',
        )}
      >
        <Breadcrumb
          aria-label={t(($) => $['marketplace.creatorProfile.breadcrumbLabel'], { ns: 'plugin' })}
          className="h-12 shrink-0"
        >
          <BreadcrumbList className="h-full items-end gap-2">
            <BreadcrumbItem className="shrink-0">
              <BreadcrumbLink
                render={<Link href={homeHref} />}
                aria-label={t(($) => $['marketplace.creatorProfile.home'], { ns: 'plugin' })}
                className={iconButtonVariants({ size: 'md' })}
              >
                <span aria-hidden className="i-ri-home-4-line size-4" />
              </BreadcrumbLink>
            </BreadcrumbItem>
            <BreadcrumbSeparator className="pb-0.5 system-md-regular" />
            <BreadcrumbItem>
              <BreadcrumbPage className="pb-0.5 system-md-regular">
                {t(($) => $['marketplace.creatorProfile.title'], { ns: 'plugin' })}
              </BreadcrumbPage>
            </BreadcrumbItem>
          </BreadcrumbList>
        </Breadcrumb>

        <div className="w-full pt-5 pb-8">
          <div
            className="relative h-40 w-full overflow-hidden rounded-xl border-0 bg-cover bg-center bg-no-repeat md:h-60"
            style={{ backgroundImage: `url("${DefaultCreatorBackground.src}")` }}
          >
            {profile.profile.backgroundUrl && (
              <img
                alt=""
                aria-hidden
                src={profile.profile.backgroundUrl}
                className="size-full border-0 object-cover object-center"
                onError={(event) => {
                  event.currentTarget.hidden = true
                }}
              />
            )}
          </div>

          <div
            className={cn(
              'grid min-w-0 grid-cols-1 gap-8 md:grid-cols-[234px_minmax(0,1fr)]',
              isMarketplacePlatform ? 'md:pl-4' : 'md:pl-9',
            )}
          >
            <CreatorSidebar profile={profile.profile} />
            <CreatorContent
              creations={profile.creations}
              getCreationAction={getCreationAction}
              inventory={inventory}
              locale={locale}
              onRecordsLoaded={onRecordsLoaded}
            />
          </div>
        </div>
      </div>
    </div>
  )
}