mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
chore(web): new lint setup (#30020)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
import { RiBookOpenLine, RiKey2Line } from '@remixicon/react'
|
||||
import Link from 'next/link'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ApiAggregate } from '@/app/components/base/icons/src/vender/knowledge'
|
||||
import Indicator from '@/app/components/header/indicator'
|
||||
import Switch from '@/app/components/base/switch'
|
||||
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import CopyFeedback from '@/app/components/base/copy-feedback'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { RiBookOpenLine, RiKey2Line } from '@remixicon/react'
|
||||
import { useDisableDatasetServiceApi, useEnableDatasetServiceApi } from '@/service/knowledge/use-dataset'
|
||||
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
||||
import Link from 'next/link'
|
||||
import CopyFeedback from '@/app/components/base/copy-feedback'
|
||||
import { ApiAggregate } from '@/app/components/base/icons/src/vender/knowledge'
|
||||
import Switch from '@/app/components/base/switch'
|
||||
import SecretKeyModal from '@/app/components/develop/secret-key/secret-key-modal'
|
||||
import Indicator from '@/app/components/header/indicator'
|
||||
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
||||
import { useDatasetApiAccessUrl } from '@/hooks/use-api-access-url'
|
||||
import { useDisableDatasetServiceApi, useEnableDatasetServiceApi } from '@/service/knowledge/use-dataset'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
type CardProps = {
|
||||
apiEnabled: boolean
|
||||
@ -53,20 +53,20 @@ const Card = ({
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className='flex w-[360px] flex-col rounded-xl border border-components-panel-border bg-components-panel-bg shadow-lg shadow-shadow-shadow-1'>
|
||||
<div className='flex flex-col gap-y-3 p-4'>
|
||||
<div className='flex items-center gap-x-3'>
|
||||
<div className='flex grow items-center gap-x-2'>
|
||||
<div className='flex size-6 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-divider-subtle bg-util-colors-blue-brand-blue-brand-500 shadow-md shadow-shadow-shadow-5'>
|
||||
<ApiAggregate className='size-4 text-text-primary-on-surface' />
|
||||
<div className="flex w-[360px] flex-col rounded-xl border border-components-panel-border bg-components-panel-bg shadow-lg shadow-shadow-shadow-1">
|
||||
<div className="flex flex-col gap-y-3 p-4">
|
||||
<div className="flex items-center gap-x-3">
|
||||
<div className="flex grow items-center gap-x-2">
|
||||
<div className="flex size-6 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-divider-subtle bg-util-colors-blue-brand-blue-brand-500 shadow-md shadow-shadow-shadow-5">
|
||||
<ApiAggregate className="size-4 text-text-primary-on-surface" />
|
||||
</div>
|
||||
<div className='system-sm-semibold grow truncate text-text-secondary'>
|
||||
<div className="system-sm-semibold grow truncate text-text-secondary">
|
||||
{t('dataset.serviceApi.card.title')}
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-x-1'>
|
||||
<div className="flex items-center gap-x-1">
|
||||
<Indicator
|
||||
className='shrink-0'
|
||||
className="shrink-0"
|
||||
color={apiEnabled ? 'green' : 'yellow'}
|
||||
/>
|
||||
<div
|
||||
@ -86,13 +86,13 @@ const Card = ({
|
||||
disabled={!isCurrentWorkspaceManager}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-col'>
|
||||
<div className='system-xs-regular leading-6 text-text-tertiary'>
|
||||
<div className="flex flex-col">
|
||||
<div className="system-xs-regular leading-6 text-text-tertiary">
|
||||
{t('dataset.serviceApi.card.endpoint')}
|
||||
</div>
|
||||
<div className='flex h-8 items-center gap-0.5 rounded-lg bg-components-input-bg-normal p-1 pl-2'>
|
||||
<div className='flex h-4 min-w-0 flex-1 items-start justify-start gap-2 px-1'>
|
||||
<div className='system-xs-medium truncate text-text-secondary'>
|
||||
<div className="flex h-8 items-center gap-0.5 rounded-lg bg-components-input-bg-normal p-1 pl-2">
|
||||
<div className="flex h-4 min-w-0 flex-1 items-start justify-start gap-2 px-1">
|
||||
<div className="system-xs-medium truncate text-text-secondary">
|
||||
{apiBaseUrl}
|
||||
</div>
|
||||
</div>
|
||||
@ -103,30 +103,30 @@ const Card = ({
|
||||
</div>
|
||||
</div>
|
||||
{/* Actions */}
|
||||
<div className='flex gap-x-1 border-t-[0.5px] border-divider-subtle p-4'>
|
||||
<div className="flex gap-x-1 border-t-[0.5px] border-divider-subtle p-4">
|
||||
<Button
|
||||
variant='ghost'
|
||||
size='small'
|
||||
className='gap-x-px text-text-tertiary'
|
||||
variant="ghost"
|
||||
size="small"
|
||||
className="gap-x-px text-text-tertiary"
|
||||
onClick={handleOpenSecretKeyModal}
|
||||
>
|
||||
<RiKey2Line className='size-3.5 shrink-0' />
|
||||
<span className='system-xs-medium px-[3px]'>
|
||||
<RiKey2Line className="size-3.5 shrink-0" />
|
||||
<span className="system-xs-medium px-[3px]">
|
||||
{t('dataset.serviceApi.card.apiKey')}
|
||||
</span>
|
||||
</Button>
|
||||
<Link
|
||||
href={apiReferenceUrl}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Button
|
||||
variant='ghost'
|
||||
size='small'
|
||||
className='gap-x-px text-text-tertiary'
|
||||
variant="ghost"
|
||||
size="small"
|
||||
className="gap-x-px text-text-tertiary"
|
||||
>
|
||||
<RiBookOpenLine className='size-3.5 shrink-0' />
|
||||
<span className='system-xs-medium px-[3px]'>
|
||||
<RiBookOpenLine className="size-3.5 shrink-0" />
|
||||
<span className="system-xs-medium px-[3px]">
|
||||
{t('dataset.serviceApi.card.apiReference')}
|
||||
</span>
|
||||
</Button>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import React, { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ApiAggregate } from '@/app/components/base/icons/src/vender/knowledge'
|
||||
import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'
|
||||
import Indicator from '@/app/components/header/indicator'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'
|
||||
import Card from './card'
|
||||
|
||||
type ServiceApiProps = {
|
||||
@ -25,34 +25,35 @@ const ServiceApi = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='p-3 pt-2'>
|
||||
<div className="p-3 pt-2">
|
||||
<PortalToFollowElem
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
placement='top-start'
|
||||
placement="top-start"
|
||||
offset={{
|
||||
mainAxis: 4,
|
||||
crossAxis: -4,
|
||||
}}
|
||||
>
|
||||
<PortalToFollowElemTrigger
|
||||
className='w-full'
|
||||
className="w-full"
|
||||
onClick={handleToggle}
|
||||
>
|
||||
<div className={cn(
|
||||
'relative flex h-8 cursor-pointer items-center gap-2 rounded-lg border border-components-panel-border px-3',
|
||||
!expand && 'w-8 justify-center',
|
||||
open ? 'bg-state-base-hover' : 'hover:bg-state-base-hover',
|
||||
)}>
|
||||
<ApiAggregate className='size-4 shrink-0 text-text-secondary' />
|
||||
{expand && <div className='system-sm-medium grow text-text-secondary'>{t('dataset.serviceApi.title')}</div>}
|
||||
)}
|
||||
>
|
||||
<ApiAggregate className="size-4 shrink-0 text-text-secondary" />
|
||||
{expand && <div className="system-sm-medium grow text-text-secondary">{t('dataset.serviceApi.title')}</div>}
|
||||
<Indicator
|
||||
className={cn('shrink-0', !expand && 'absolute -right-px -top-px')}
|
||||
color={apiEnabled ? 'green' : 'yellow'}
|
||||
/>
|
||||
</div>
|
||||
</PortalToFollowElemTrigger>
|
||||
<PortalToFollowElemContent className='z-[10]'>
|
||||
<PortalToFollowElemContent className="z-[10]">
|
||||
<Card
|
||||
apiEnabled={apiEnabled}
|
||||
apiBaseUrl={apiBaseUrl}
|
||||
|
||||
Reference in New Issue
Block a user