fix(web): button import

This commit is contained in:
JzoNg 2026-04-15 15:23:50 +08:00
parent 40632589a2
commit 7f5bbe0ee3
18 changed files with 31 additions and 33 deletions

View File

@ -20,11 +20,11 @@
```typescript ```typescript
// ❌ WRONG: Don't mock base components // ❌ WRONG: Don't mock base components
vi.mock('@/app/components/base/loading', () => () => <div>Loading</div>) vi.mock('@/app/components/base/loading', () => () => <div>Loading</div>)
vi.mock('@/app/components/base/button', () => ({ children }: any) => <button>{children}</button>) vi.mock('@/app/components/base/ui/button', () => ({ children }: any) => <button>{children}</button>)
// ✅ CORRECT: Import and use real base components // ✅ CORRECT: Import and use real base components
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
// They will render normally in tests // They will render normally in tests
``` ```

View File

@ -234,7 +234,7 @@ export const PublisherSummarySection = ({
/> />
<TooltipContent <TooltipContent
placement="top" placement="top"
popupClassName="w-[180px]" className="w-[180px]"
> >
{t(workflowTypeSwitchConfig.tipKey, { ns: 'workflow' })} {t(workflowTypeSwitchConfig.tipKey, { ns: 'workflow' })}
</TooltipContent> </TooltipContent>

View File

@ -2,7 +2,7 @@
import type { BatchTestTab, EvaluationResourceProps } from '../../types' import type { BatchTestTab, EvaluationResourceProps } from '../../types'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { toast } from '@/app/components/base/ui/toast' import { toast } from '@/app/components/base/ui/toast'
import { useSaveEvaluationConfigMutation } from '@/service/use-evaluation' import { useSaveEvaluationConfigMutation } from '@/service/use-evaluation'
import { cn } from '@/utils/classnames' import { cn } from '@/utils/classnames'

View File

@ -1,6 +1,6 @@
import type { EvaluationResourceProps } from '../../types' import type { EvaluationResourceProps } from '../../types'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { getEvaluationMockConfig } from '../../mock' import { getEvaluationMockConfig } from '../../mock'
import InputFieldsRequirements from './input-fields/input-fields-requirements' import InputFieldsRequirements from './input-fields/input-fields-requirements'
import UploadRunPopover from './input-fields/upload-run-popover' import UploadRunPopover from './input-fields/upload-run-popover'

View File

@ -2,7 +2,7 @@ import type { ChangeEvent, DragEvent } from 'react'
import type { InputField } from './input-fields-utils' import type { InputField } from './input-fields-utils'
import { useRef } from 'react' import { useRef } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { import {
Popover, Popover,
PopoverContent, PopoverContent,

View File

@ -8,7 +8,7 @@ import type {
} from '../../types' } from '../../types'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import { import {
Select, Select,

View File

@ -4,7 +4,7 @@ import type { EvaluationMetric, EvaluationResourceProps } from '../../types'
import type { NodeInfo } from '@/types/evaluation' import type { NodeInfo } from '@/types/evaluation'
import { useState } from 'react' import { useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { import {
DropdownMenu, DropdownMenu,
DropdownMenuContent, DropdownMenuContent,

View File

@ -3,7 +3,7 @@
import type { EvaluationMetric, EvaluationResourceProps } from '../../types' import type { EvaluationMetric, EvaluationResourceProps } from '../../types'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge' import Badge from '@/app/components/base/badge'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { cn } from '@/utils/classnames' import { cn } from '@/utils/classnames'
import { isCustomMetricConfigured, useEvaluationStore } from '../../store' import { isCustomMetricConfigured, useEvaluationStore } from '../../store'
import CustomMetricEditorCard from '../custom-metric-editor' import CustomMetricEditorCard from '../custom-metric-editor'

View File

@ -4,8 +4,8 @@ import type { ChangeEvent } from 'react'
import type { MetricSelectorProps } from './types' import type { MetricSelectorProps } from './types'
import { useState } from 'react' import { useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import { Button } from '@/app/components/base/ui/button'
import { import {
Popover, Popover,
PopoverContent, PopoverContent,
@ -21,7 +21,6 @@ import { useMetricSelectorData } from './use-metric-selector-data'
const MetricSelector = ({ const MetricSelector = ({
resourceType, resourceType,
resourceId, resourceId,
triggerVariant = 'ghost-accent',
triggerClassName, triggerClassName,
triggerStyle = 'button', triggerStyle = 'button',
}: MetricSelectorProps) => { }: MetricSelectorProps) => {
@ -69,14 +68,14 @@ const MetricSelector = ({
render={( render={(
triggerStyle === 'text' triggerStyle === 'text'
? ( ? (
<button type="button" className={cn('inline-flex items-center text-text-accent system-sm-medium', triggerClassName)}> <button type="button" className={cn('inline-flex items-center system-sm-medium text-text-accent', triggerClassName)}>
<span aria-hidden="true" className="i-ri-add-line mr-1 h-4 w-4" /> <span aria-hidden="true" className="mr-1 i-ri-add-line h-4 w-4" />
{t('metrics.add')} {t('metrics.add')}
</button> </button>
) )
: ( : (
<Button variant={triggerVariant} className={triggerClassName}> <Button variant="ghost-accent" className={triggerClassName}>
<span aria-hidden="true" className="i-ri-add-line mr-1 h-4 w-4" /> <span aria-hidden="true" className="mr-1 i-ri-add-line h-4 w-4" />
{t('metrics.add')} {t('metrics.add')}
</Button> </Button>
) )

View File

@ -2,7 +2,6 @@ import type { EvaluationMetric, EvaluationResourceProps, MetricOption } from '..
import type { NodeInfo } from '@/types/evaluation' import type { NodeInfo } from '@/types/evaluation'
export type MetricSelectorProps = EvaluationResourceProps & { export type MetricSelectorProps = EvaluationResourceProps & {
triggerVariant?: 'primary' | 'warning' | 'secondary' | 'secondary-accent' | 'ghost' | 'ghost-accent' | 'tertiary'
triggerClassName?: string triggerClassName?: string
triggerStyle?: 'button' | 'text' triggerStyle?: 'button' | 'text'
} }

View File

@ -3,7 +3,7 @@
import type { EvaluationResourceProps } from '../../types' import type { EvaluationResourceProps } from '../../types'
import type { InputField } from '../batch-test-panel/input-fields/input-fields-utils' import type { InputField } from '../batch-test-panel/input-fields/input-fields-utils'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { getEvaluationMockConfig } from '../../mock' import { getEvaluationMockConfig } from '../../mock'
import { isEvaluationRunnable, useEvaluationResource } from '../../store' import { isEvaluationRunnable, useEvaluationResource } from '../../store'
import UploadRunPopover from '../batch-test-panel/input-fields/upload-run-popover' import UploadRunPopover from '../batch-test-panel/input-fields/upload-run-popover'

View File

@ -4,7 +4,7 @@ import type { SortableItem } from '@/app/components/rag-pipeline/components/pane
import type { SnippetInputField } from '@/models/snippet' import type { SnippetInputField } from '@/models/snippet'
import { memo, useCallback } from 'react' import { memo, useCallback } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import FieldListContainer from '@/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container' import FieldListContainer from '@/app/components/rag-pipeline/components/panel/input-field/field-list/field-list-container'
type SnippetInputFieldPanelProps = { type SnippetInputFieldPanelProps = {

View File

@ -2,7 +2,7 @@
import type { SnippetDetailUIModel } from '@/models/snippet' import type { SnippetDetailUIModel } from '@/models/snippet'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import ShortcutsName from '@/app/components/workflow/shortcuts-name' import ShortcutsName from '@/app/components/workflow/shortcuts-name'
const PublishMenu = ({ const PublishMenu = ({

View File

@ -4,8 +4,8 @@ import { useDebounceFn, useKeyPress } from 'ahooks'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Uploader from '@/app/components/app/create-from-dsl-modal/uploader' import Uploader from '@/app/components/app/create-from-dsl-modal/uploader'
import Button from '@/app/components/base/button'
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import { Button } from '@/app/components/base/ui/button'
import { Dialog, DialogCloseButton, DialogContent, DialogTitle } from '@/app/components/base/ui/dialog' import { Dialog, DialogCloseButton, DialogContent, DialogTitle } from '@/app/components/base/ui/dialog'
import { toast } from '@/app/components/base/ui/toast' import { toast } from '@/app/components/base/ui/toast'
import { import {
@ -163,14 +163,14 @@ const SnippetImportDSLDialog = ({
<> <>
<Dialog open={show} onOpenChange={open => !open && onClose()}> <Dialog open={show} onOpenChange={open => !open && onClose()}>
<DialogContent className="w-[520px] p-0"> <DialogContent className="w-[520px] p-0">
<div className="flex items-center justify-between pb-3 pl-6 pr-5 pt-6"> <div className="flex items-center justify-between pt-6 pr-5 pb-3 pl-6">
<DialogTitle className="text-text-primary title-2xl-semi-bold"> <DialogTitle className="title-2xl-semi-bold text-text-primary">
{t('importFromDSL', { ns: 'app' })} {t('importFromDSL', { ns: 'app' })}
</DialogTitle> </DialogTitle>
<DialogCloseButton className="right-5 top-6 h-8 w-8" /> <DialogCloseButton className="top-6 right-5 h-8 w-8" />
</div> </div>
<div className="flex h-9 items-center space-x-6 border-b border-divider-subtle px-6 text-text-tertiary system-md-semibold"> <div className="flex h-9 items-center space-x-6 border-b border-divider-subtle px-6 system-md-semibold text-text-tertiary">
{[ {[
{ key: SnippetImportDSLTab.FromFile, label: t('importFromDSLFile', { ns: 'app' }) }, { key: SnippetImportDSLTab.FromFile, label: t('importFromDSLFile', { ns: 'app' }) },
{ key: SnippetImportDSLTab.FromURL, label: t('importFromDSLUrl', { ns: 'app' }) }, { key: SnippetImportDSLTab.FromURL, label: t('importFromDSLUrl', { ns: 'app' }) },
@ -202,7 +202,7 @@ const SnippetImportDSLDialog = ({
)} )}
{currentTab === SnippetImportDSLTab.FromURL && ( {currentTab === SnippetImportDSLTab.FromURL && (
<div> <div>
<div className="mb-1 text-text-secondary system-md-semibold">DSL URL</div> <div className="mb-1 system-md-semibold text-text-secondary">DSL URL</div>
<Input <Input
placeholder={t('importFromDSLUrlPlaceholder', { ns: 'app' }) || ''} placeholder={t('importFromDSLUrlPlaceholder', { ns: 'app' }) || ''}
value={dslUrlValue} value={dslUrlValue}
@ -232,10 +232,10 @@ const SnippetImportDSLDialog = ({
<Dialog open={showVersionMismatchDialog} onOpenChange={open => !open && setShowVersionMismatchDialog(false)}> <Dialog open={showVersionMismatchDialog} onOpenChange={open => !open && setShowVersionMismatchDialog(false)}>
<DialogContent className="w-[480px]"> <DialogContent className="w-[480px]">
<div className="flex flex-col items-start gap-2 self-stretch pb-4"> <div className="flex flex-col items-start gap-2 self-stretch pb-4">
<DialogTitle className="text-text-primary title-2xl-semi-bold"> <DialogTitle className="title-2xl-semi-bold text-text-primary">
{t('newApp.appCreateDSLErrorTitle', { ns: 'app' })} {t('newApp.appCreateDSLErrorTitle', { ns: 'app' })}
</DialogTitle> </DialogTitle>
<div className="flex grow flex-col text-text-secondary system-md-regular"> <div className="flex grow flex-col system-md-regular text-text-secondary">
<div>{t('newApp.appCreateDSLErrorPart1', { ns: 'app' })}</div> <div>{t('newApp.appCreateDSLErrorPart1', { ns: 'app' })}</div>
<div>{t('newApp.appCreateDSLErrorPart2', { ns: 'app' })}</div> <div>{t('newApp.appCreateDSLErrorPart2', { ns: 'app' })}</div>
<br /> <br />
@ -253,7 +253,7 @@ const SnippetImportDSLDialog = ({
<Button variant="secondary" disabled={isImporting} onClick={() => setShowVersionMismatchDialog(false)}> <Button variant="secondary" disabled={isImporting} onClick={() => setShowVersionMismatchDialog(false)}>
{t('newApp.Cancel', { ns: 'app' })} {t('newApp.Cancel', { ns: 'app' })}
</Button> </Button>
<Button variant="primary" destructive disabled={isImporting} onClick={handleConfirmImport}> <Button variant="primary" tone="destructive" disabled={isImporting} onClick={handleConfirmImport}>
{t('newApp.Confirm', { ns: 'app' })} {t('newApp.Confirm', { ns: 'app' })}
</Button> </Button>
</div> </div>

View File

@ -12,7 +12,7 @@ import {
useState, useState,
} from 'react' } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import { useCheckInputsForms } from '@/app/components/base/chat/chat/check-input-forms-hooks' import { useCheckInputsForms } from '@/app/components/base/chat/chat/check-input-forms-hooks'
import { getProcessedInputs } from '@/app/components/base/chat/chat/utils' import { getProcessedInputs } from '@/app/components/base/chat/chat/utils'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'

View File

@ -52,7 +52,7 @@ const LoadingSkeleton = () => {
</div> </div>
))} ))}
</div> </div>
<div className="pointer-events-none absolute inset-0 bg-gradient-to-b from-components-panel-bg-transparent to-background-default-subtle" /> <div className="pointer-events-none absolute inset-0 bg-linear-to-b from-components-panel-bg-transparent to-background-default-subtle" />
</div> </div>
) )
} }
@ -147,7 +147,7 @@ const Snippets = ({
<TooltipContent <TooltipContent
placement="left-start" placement="left-start"
variant="plain" variant="plain"
popupClassName="!bg-transparent !p-0" className="bg-transparent! p-0!"
> >
<SnippetDetailCard snippet={item} /> <SnippetDetailCard snippet={item} />
</TooltipContent> </TooltipContent>

View File

@ -1,6 +1,6 @@
import type { FC } from 'react' import type { FC } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
type SnippetEmptyStateProps = { type SnippetEmptyStateProps = {
onCreate: () => void onCreate: () => void

View File

@ -8,7 +8,7 @@ import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import AppIcon from '@/app/components/base/app-icon' import AppIcon from '@/app/components/base/app-icon'
import AppIconPicker from '@/app/components/base/app-icon-picker' import AppIconPicker from '@/app/components/base/app-icon-picker'
import Button from '@/app/components/base/button' import { Button } from '@/app/components/base/ui/button'
import Input from '@/app/components/base/input' import Input from '@/app/components/base/input'
import Textarea from '@/app/components/base/textarea' import Textarea from '@/app/components/base/textarea'
import { Dialog, DialogCloseButton, DialogContent, DialogPortal, DialogTitle } from '@/app/components/base/ui/dialog' import { Dialog, DialogCloseButton, DialogContent, DialogPortal, DialogTitle } from '@/app/components/base/ui/dialog'