mirror of
https://github.com/langgenius/dify.git
synced 2026-02-09 15:10:13 -05:00
fix: enforce no-leaked-conditional-rendering as error and fix violations (#31262)
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
@@ -71,7 +71,7 @@ const DatasetInfo: FC<DatasetInfoProps> = ({
|
||||
</div>
|
||||
<div className="system-2xs-medium-uppercase text-text-tertiary">
|
||||
{isExternalProvider && t('externalTag', { ns: 'dataset' })}
|
||||
{!isExternalProvider && isPipelinePublished && dataset.doc_form && dataset.indexing_technique && (
|
||||
{!!(!isExternalProvider && isPipelinePublished && dataset.doc_form && dataset.indexing_technique) && (
|
||||
<div className="flex items-center gap-x-2">
|
||||
<span>{t(`chunkingMode.${DOC_FORM_TEXT[dataset.doc_form]}`, { ns: 'dataset' })}</span>
|
||||
<span>{formatIndexingTechniqueAndMethod(dataset.indexing_technique, dataset.retrieval_model_dict?.search_method)}</span>
|
||||
|
||||
@@ -114,7 +114,7 @@ const DatasetSidebarDropdown = ({
|
||||
</div>
|
||||
<div className="system-2xs-medium-uppercase text-text-tertiary">
|
||||
{isExternalProvider && t('externalTag', { ns: 'dataset' })}
|
||||
{!isExternalProvider && dataset.doc_form && dataset.indexing_technique && (
|
||||
{!!(!isExternalProvider && dataset.doc_form && dataset.indexing_technique) && (
|
||||
<div className="flex items-center gap-x-2">
|
||||
<span>{t(`chunkingMode.${DOC_FORM_TEXT[dataset.doc_form]}`, { ns: 'dataset' })}</span>
|
||||
<span>{formatIndexingTechniqueAndMethod(dataset.indexing_technique, dataset.retrieval_model_dict?.search_method)}</span>
|
||||
|
||||
@@ -144,7 +144,7 @@ const EditAnnotationModal: FC<Props> = ({
|
||||
<MessageCheckRemove />
|
||||
<div>{t('editModal.removeThisCache', { ns: 'appAnnotation' })}</div>
|
||||
</div>
|
||||
{createdAt && (
|
||||
{!!createdAt && (
|
||||
<div>
|
||||
{t('editModal.createdAt', { ns: 'appAnnotation' })}
|
||||
|
||||
|
||||
@@ -28,16 +28,16 @@ const FeaturePanel: FC<IFeaturePanelProps> = ({
|
||||
<div className={cn('px-3 pt-2', hasHeaderBottomBorder && 'border-b border-divider-subtle')} data-testid="feature-panel-header">
|
||||
<div className="flex h-8 items-center justify-between">
|
||||
<div className="flex shrink-0 items-center space-x-1">
|
||||
{headerIcon && <div className="flex h-6 w-6 items-center justify-center">{headerIcon}</div>}
|
||||
{!!headerIcon && <div className="flex h-6 w-6 items-center justify-center">{headerIcon}</div>}
|
||||
<div className="system-sm-semibold text-text-secondary">{title}</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{headerRight && <div>{headerRight}</div>}
|
||||
{!!headerRight && <div>{headerRight}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* Body */}
|
||||
{children && (
|
||||
{!!children && (
|
||||
<div className={cn(!noBodySpacing && 'mt-1 px-3')} data-testid="feature-panel-body">
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -91,7 +91,7 @@ const Item: FC<ItemProps> = ({
|
||||
</ActionButton>
|
||||
</div>
|
||||
{
|
||||
config.indexing_technique && (
|
||||
!!config.indexing_technique && (
|
||||
<Badge
|
||||
className="shrink-0 group-hover:hidden"
|
||||
text={formatIndexingTechniqueAndMethod(config.indexing_technique, config.retrieval_model_dict?.search_method)}
|
||||
|
||||
@@ -175,7 +175,7 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
|
||||
</div>
|
||||
)}
|
||||
{
|
||||
item.indexing_technique && (
|
||||
!!item.indexing_technique && (
|
||||
<Badge
|
||||
className="shrink-0"
|
||||
text={formatIndexingTechniqueAndMethod(item.indexing_technique, item.retrieval_model_dict?.search_method)}
|
||||
|
||||
@@ -247,7 +247,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{currentDataset && currentDataset.indexing_technique && (
|
||||
{!!(currentDataset && currentDataset.indexing_technique) && (
|
||||
<div className={cn(rowClass)}>
|
||||
<div className={labelClass}>
|
||||
<div className="system-sm-semibold text-text-secondary">{t('form.indexMethod', { ns: 'datasetSettings' })}</div>
|
||||
|
||||
@@ -465,8 +465,8 @@ vi.mock('@/app/components/base/chat/chat', () => ({
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{questionIcon && <div data-testid="question-icon">{questionIcon}</div>}
|
||||
{answerIcon && <div data-testid="answer-icon">{answerIcon}</div>}
|
||||
{!!questionIcon && <div data-testid="question-icon">{questionIcon}</div>}
|
||||
{!!answerIcon && <div data-testid="answer-icon">{answerIcon}</div>}
|
||||
<textarea
|
||||
data-testid="chat-input"
|
||||
placeholder="Type a message"
|
||||
|
||||
@@ -72,7 +72,7 @@ const ToolCallItem: FC<Props> = ({ toolCall, isLLM = false, isFinal, tokens, obs
|
||||
{toolName}
|
||||
</div>
|
||||
<div className="shrink-0 text-xs leading-[18px] text-text-tertiary">
|
||||
{toolCall.time_cost && (
|
||||
{!!toolCall.time_cost && (
|
||||
<span>{getTime(toolCall.time_cost || 0)}</span>
|
||||
)}
|
||||
{isLLM && (
|
||||
|
||||
@@ -212,7 +212,7 @@ const Answer: FC<AnswerProps> = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
item.siblingCount && item.siblingCount > 1 && item.siblingIndex !== undefined && (
|
||||
!!(item.siblingCount && item.siblingCount > 1 && item.siblingIndex !== undefined) && (
|
||||
<ContentSwitch
|
||||
count={item.siblingCount}
|
||||
currentIndex={item.siblingIndex}
|
||||
|
||||
@@ -29,7 +29,7 @@ const More: FC<MoreProps> = ({
|
||||
>
|
||||
{`${t('detail.tokenCost', { ns: 'appLog' })} ${formatNumber(more.tokens)}`}
|
||||
</div>
|
||||
{more.tokens_per_second && (
|
||||
{!!more.tokens_per_second && (
|
||||
<div
|
||||
className="mr-2 max-w-[25%] shrink-0 truncate"
|
||||
title={`${more.tokens_per_second} tokens/s`}
|
||||
|
||||
@@ -146,7 +146,7 @@ const Popup: FC<PopupProps> = ({
|
||||
icon={<BezierCurve03 className="mr-1 h-3 w-3" />}
|
||||
/>
|
||||
{
|
||||
source.score && (
|
||||
!!source.score && (
|
||||
<ProgressTooltip data={Number(source.score.toFixed(2))} />
|
||||
)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ const UploaderButton: FC<UploaderButtonProps> = ({
|
||||
<PortalToFollowElemContent className="z-50">
|
||||
<div className="w-[260px] rounded-lg border-[0.5px] border-gray-200 bg-white p-2 shadow-lg">
|
||||
<ImageLinkInput onUpload={handleUpload} disabled={disabled} />
|
||||
{hasUploadFromLocal && (
|
||||
{!!hasUploadFromLocal && (
|
||||
<>
|
||||
<div className="mt-2 flex items-center px-2 text-xs font-medium text-gray-400">
|
||||
<div className="mr-3 h-px w-[93px] bg-gradient-to-l from-[#F3F4F6]" />
|
||||
|
||||
@@ -109,7 +109,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(({
|
||||
disabled={disabled}
|
||||
{...props}
|
||||
/>
|
||||
{showClearIcon && value && !disabled && !destructive && (
|
||||
{!!(showClearIcon && value && !disabled && !destructive) && (
|
||||
<div
|
||||
className={cn('group absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer p-[1px]')}
|
||||
onClick={onClear}
|
||||
|
||||
@@ -52,7 +52,7 @@ export default function Modal({
|
||||
<div className={cn('flex min-h-full items-center justify-center p-4 text-center', containerClassName)}>
|
||||
<TransitionChild>
|
||||
<DialogPanel className={cn('relative w-full max-w-[480px] rounded-2xl bg-components-panel-bg p-6 text-left align-middle shadow-xl transition-all', overflowVisible ? 'overflow-visible' : 'overflow-hidden', 'duration-100 ease-in data-[closed]:scale-95 data-[closed]:opacity-0', 'data-[enter]:scale-100 data-[enter]:opacity-100', 'data-[enter]:scale-95 data-[leave]:opacity-0', className)}>
|
||||
{title && (
|
||||
{!!title && (
|
||||
<DialogTitle
|
||||
as="h3"
|
||||
className="title-2xl-semi-bold text-text-primary"
|
||||
@@ -60,7 +60,7 @@ export default function Modal({
|
||||
{title}
|
||||
</DialogTitle>
|
||||
)}
|
||||
{description && (
|
||||
{!!description && (
|
||||
<div className="body-md-regular mt-2 text-text-secondary">
|
||||
{description}
|
||||
</div>
|
||||
|
||||
@@ -86,7 +86,7 @@ const Modal = ({
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
children && (
|
||||
!!children && (
|
||||
<div className="min-h-0 flex-1 overflow-y-auto px-6 py-3">{children}</div>
|
||||
)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ const Modal = ({
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{bottomSlot && (
|
||||
{!!bottomSlot && (
|
||||
<div className="shrink-0">
|
||||
{bottomSlot}
|
||||
</div>
|
||||
|
||||
@@ -56,7 +56,7 @@ const RadioCard: FC<Props> = ({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{((isChosen && chosenConfig) || noRadio) && (
|
||||
{!!((isChosen && chosenConfig) || noRadio) && (
|
||||
<div className="mt-2 flex gap-x-2">
|
||||
<div className="size-8 shrink-0"></div>
|
||||
<div className={cn(chosenConfigWrapClassName, 'grow')}>
|
||||
|
||||
@@ -52,7 +52,7 @@ export default function Radio({
|
||||
)}
|
||||
onClick={() => handleChange(value)}
|
||||
>
|
||||
{children && (
|
||||
{!!children && (
|
||||
<label
|
||||
className={
|
||||
cn(labelClassName, 'cursor-pointer text-sm')
|
||||
|
||||
@@ -130,7 +130,7 @@ export const SegmentedControl = <T extends string | number | symbol>({
|
||||
{text && (
|
||||
<div className={cn('inline-flex items-center gap-x-1', ItemTextWrapperVariants({ size }))}>
|
||||
<span>{text}</span>
|
||||
{count && size === 'large' && (
|
||||
{!!(count && size === 'large') && (
|
||||
<div className="system-2xs-medium-uppercase inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-[5px] border border-divider-deep bg-components-badge-bg-dimm px-[5px] text-text-tertiary">
|
||||
{count}
|
||||
</div>
|
||||
|
||||
@@ -379,7 +379,7 @@ const PortalSelect: FC<PortalSelectProps> = ({
|
||||
{selectedItem?.name ?? localPlaceholder}
|
||||
</span>
|
||||
<div className="mx-0.5">
|
||||
{installedValue && selectedItem && selectedItem.value !== installedValue && (
|
||||
{!!(installedValue && selectedItem && selectedItem.value !== installedValue) && (
|
||||
<Badge>
|
||||
{installedValue}
|
||||
{' '}
|
||||
|
||||
@@ -80,7 +80,7 @@ const Toast = ({
|
||||
<div className="system-sm-semibold text-text-primary [word-break:break-word]">{message}</div>
|
||||
{customComponent}
|
||||
</div>
|
||||
{children && (
|
||||
{!!children && (
|
||||
<div className="system-xs-regular text-text-secondary">
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -12,11 +12,11 @@ export const ToolTipContent: FC<ToolTipContentProps> = ({
|
||||
}) => {
|
||||
return (
|
||||
<div className="w-[180px]">
|
||||
{title && (
|
||||
{!!title && (
|
||||
<div className="mb-1.5 font-semibold text-text-secondary">{title}</div>
|
||||
)}
|
||||
<div className="mb-1.5 text-text-tertiary">{children}</div>
|
||||
{action && <div className="cursor-pointer text-text-accent">{action}</div>}
|
||||
{!!action && <div className="cursor-pointer text-text-accent">{action}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ const Tooltip: FC<TooltipProps> = ({
|
||||
<PortalToFollowElemContent
|
||||
className={cn('z-[9999]', portalContentClassName || '')}
|
||||
>
|
||||
{popupContent && (
|
||||
{!!popupContent && (
|
||||
<div
|
||||
className={cn(
|
||||
!noDecoration && 'system-xs-regular relative max-w-[300px] break-words rounded-md bg-components-panel-bg px-3 py-2 text-left text-text-tertiary shadow-lg',
|
||||
|
||||
@@ -87,10 +87,10 @@ export const OptionCard: FC<OptionCardProps> = (
|
||||
disabled={disabled}
|
||||
/>
|
||||
{/** Body */}
|
||||
{isActive && (children || actions) && (
|
||||
{!!(isActive && (children || actions)) && (
|
||||
<div className="rounded-b-xl bg-components-panel-bg px-4 py-3">
|
||||
{children}
|
||||
{actions && (
|
||||
{!!actions && (
|
||||
<div className="mt-4 flex gap-2">
|
||||
{actions}
|
||||
</div>
|
||||
|
||||
@@ -508,7 +508,7 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
/>
|
||||
)}
|
||||
{/* Show Pagination only if the total is more than the limit */}
|
||||
{pagination.total && (
|
||||
{!!pagination.total && (
|
||||
<Pagination
|
||||
{...pagination}
|
||||
className="w-full shrink-0"
|
||||
|
||||
@@ -24,7 +24,7 @@ vi.mock('@/app/components/datasets/documents/detail/metadata', () => ({
|
||||
<div data-testid="field-info" data-label={label}>
|
||||
<span data-testid="field-label">{label}</span>
|
||||
<span data-testid="field-value">{displayedValue}</span>
|
||||
{valueIcon && <span data-testid="field-icon">{valueIcon}</span>}
|
||||
{!!valueIcon && <span data-testid="field-icon">{valueIcon}</span>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -49,7 +49,7 @@ const DocModeInfo = ({
|
||||
|
||||
return (
|
||||
<div className="system-2xs-medium-uppercase flex items-center gap-x-3 text-text-tertiary">
|
||||
{dataset.doc_form && (
|
||||
{!!dataset.doc_form && (
|
||||
<span
|
||||
className="min-w-0 max-w-full truncate"
|
||||
title={t(`chunkingMode.${DOC_FORM_TEXT[dataset.doc_form]}`, { ns: 'dataset' })}
|
||||
|
||||
@@ -27,7 +27,7 @@ vi.mock('../../../base/modal-like-wrap', () => ({
|
||||
default: ({ children, title, onClose, onConfirm, beforeHeader }: ModalLikeWrapProps) => (
|
||||
<div data-testid="modal-wrap">
|
||||
<div data-testid="modal-title">{title}</div>
|
||||
{beforeHeader && <div data-testid="before-header">{beforeHeader}</div>}
|
||||
{!!beforeHeader && <div data-testid="before-header">{beforeHeader}</div>}
|
||||
<div data-testid="modal-content">{children}</div>
|
||||
<button data-testid="close-btn" onClick={onClose}>Close</button>
|
||||
<button data-testid="confirm-btn" onClick={onConfirm}>Confirm</button>
|
||||
|
||||
@@ -265,7 +265,7 @@ const Form = () => {
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
currentDataset?.doc_form && (
|
||||
!!currentDataset?.doc_form && (
|
||||
<>
|
||||
<Divider
|
||||
type="horizontal"
|
||||
@@ -298,13 +298,13 @@ const Form = () => {
|
||||
</>
|
||||
)
|
||||
}
|
||||
{(isShowIndexMethod || indexMethod === 'high_quality') && (
|
||||
{!!(isShowIndexMethod || indexMethod === 'high_quality') && (
|
||||
<Divider
|
||||
type="horizontal"
|
||||
className="my-1 h-px bg-divider-subtle"
|
||||
/>
|
||||
)}
|
||||
{isShowIndexMethod && (
|
||||
{!!isShowIndexMethod && (
|
||||
<div className={rowClass}>
|
||||
<div className={labelClass}>
|
||||
<div className="system-sm-semibold text-text-secondary">{t('form.indexMethod', { ns: 'datasetSettings' })}</div>
|
||||
|
||||
@@ -77,7 +77,7 @@ const OptionCard = <T,>({
|
||||
)
|
||||
}
|
||||
{
|
||||
icon && (
|
||||
!!icon && (
|
||||
<div className={cn(
|
||||
'flex size-6 shrink-0 items-center justify-center text-text-tertiary',
|
||||
isActive && iconActiveColor,
|
||||
@@ -110,7 +110,7 @@ const OptionCard = <T,>({
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
children && showChildren && (
|
||||
!!(children && showChildren) && (
|
||||
<div className="relative rounded-b-xl bg-components-panel-bg p-4">
|
||||
<ArrowShape className="absolute left-[14px] top-[-11px] size-4 text-components-panel-bg" />
|
||||
{children}
|
||||
|
||||
@@ -48,21 +48,21 @@ const ModelName: FC<ModelNameProps> = ({
|
||||
</div>
|
||||
<div className="flex items-center gap-0.5">
|
||||
{
|
||||
showModelType && modelItem.model_type && (
|
||||
!!(showModelType && modelItem.model_type) && (
|
||||
<ModelBadge className={modelTypeClassName}>
|
||||
{modelTypeFormat(modelItem.model_type)}
|
||||
</ModelBadge>
|
||||
)
|
||||
}
|
||||
{
|
||||
modelItem.model_properties.mode && showMode && (
|
||||
!!(modelItem.model_properties.mode && showMode) && (
|
||||
<ModelBadge className={modeClassName}>
|
||||
{(modelItem.model_properties.mode as string).toLocaleUpperCase()}
|
||||
</ModelBadge>
|
||||
)
|
||||
}
|
||||
{
|
||||
showContextSize && modelItem.model_properties.context_size && (
|
||||
!!(showContextSize && modelItem.model_properties.context_size) && (
|
||||
<ModelBadge>
|
||||
{sizeFormat(modelItem.model_properties.context_size as number)}
|
||||
</ModelBadge>
|
||||
|
||||
@@ -96,17 +96,17 @@ const PopupItem: FC<PopupItemProps> = ({
|
||||
<div className='text-text-tertiary system-xs-regular'>{currentProvider?.description?.[language] || currentProvider?.description?.en_US}</div>
|
||||
)} */}
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{modelItem.model_type && (
|
||||
{!!modelItem.model_type && (
|
||||
<ModelBadge>
|
||||
{modelTypeFormat(modelItem.model_type)}
|
||||
</ModelBadge>
|
||||
)}
|
||||
{modelItem.model_properties.mode && (
|
||||
{!!modelItem.model_properties.mode && (
|
||||
<ModelBadge>
|
||||
{(modelItem.model_properties.mode as string).toLocaleUpperCase()}
|
||||
</ModelBadge>
|
||||
)}
|
||||
{modelItem.model_properties.context_size && (
|
||||
{!!modelItem.model_properties.context_size && (
|
||||
<ModelBadge>
|
||||
{sizeFormat(modelItem.model_properties.context_size as number)}
|
||||
</ModelBadge>
|
||||
|
||||
@@ -81,7 +81,7 @@ vi.mock('@/app/components/base/app-icon', () => ({
|
||||
data-size={size}
|
||||
data-icon-type={iconType}
|
||||
>
|
||||
{innerIcon && <div data-testid="inner-icon">{innerIcon}</div>}
|
||||
{!!innerIcon && <div data-testid="inner-icon">{innerIcon}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -95,7 +95,7 @@ const Card = ({
|
||||
text={getLocalizedText(brief)}
|
||||
descriptionLineRows={descriptionLineRows}
|
||||
/>
|
||||
{footer && <div>{footer}</div>}
|
||||
{!!footer && <div>{footer}</div>}
|
||||
</div>
|
||||
{limitedInstall
|
||||
&& (
|
||||
|
||||
@@ -32,7 +32,7 @@ vi.mock('../../../card', () => ({
|
||||
default: ({ payload, titleLeft }: { payload: Plugin, titleLeft?: React.ReactNode }) => (
|
||||
<div data-testid="plugin-card">
|
||||
<span data-testid="card-name">{payload.name}</span>
|
||||
{titleLeft && <span data-testid="title-left">{titleLeft}</span>}
|
||||
{!!titleLeft && <span data-testid="title-left">{titleLeft}</span>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -118,7 +118,7 @@ vi.mock('../../../card', () => ({
|
||||
<div data-testid="plugin-card">
|
||||
<span data-testid="card-payload-name">{payload?.name}</span>
|
||||
<span data-testid="card-limited-install">{limitedInstall ? 'true' : 'false'}</span>
|
||||
{titleLeft && <div data-testid="card-title-left">{titleLeft}</div>}
|
||||
{!!titleLeft && <div data-testid="card-title-left">{titleLeft}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -279,7 +279,7 @@ vi.mock('@/app/components/plugins/card', () => ({
|
||||
default: ({ payload, footer }: { payload: Plugin, footer?: React.ReactNode }) => (
|
||||
<div data-testid={`card-${payload.name}`}>
|
||||
<div data-testid="card-name">{payload.name}</div>
|
||||
{footer && <div data-testid="card-footer">{footer}</div>}
|
||||
{!!footer && <div data-testid="card-footer">{footer}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -126,7 +126,7 @@ vi.mock('@/app/components/plugins/card', () => ({
|
||||
<div data-testid={`card-${payload.name}`}>
|
||||
<div data-testid="card-name">{payload.name}</div>
|
||||
<div data-testid="card-label">{payload.label?.['en-US'] || payload.name}</div>
|
||||
{footer && <div data-testid="card-footer">{footer}</div>}
|
||||
{!!footer && <div data-testid="card-footer">{footer}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -229,7 +229,7 @@ const DetailHeader = ({
|
||||
<div className="flex h-5 items-center">
|
||||
<Title title={label[locale]} />
|
||||
{verified && !isReadmeView && <Verified className="ml-0.5 h-4 w-4" text={t('marketplace.verifiedTip', { ns: 'plugin' })} />}
|
||||
{version && (
|
||||
{!!version && (
|
||||
<PluginVersionPicker
|
||||
disabled={!isFromMarketplace || isReadmeView}
|
||||
isShow={isShow}
|
||||
@@ -297,7 +297,7 @@ const DetailHeader = ({
|
||||
orgName={author}
|
||||
packageName={name?.includes('/') ? (name.split('/').pop() || '') : name}
|
||||
/>
|
||||
{source && (
|
||||
{!!source && (
|
||||
<>
|
||||
<div className="system-xs-regular ml-1 mr-0.5 text-text-quaternary">·</div>
|
||||
{source === PluginSource.marketplace && (
|
||||
|
||||
@@ -196,7 +196,7 @@ vi.mock('@/app/components/base/modal/modal', () => ({
|
||||
{extraButtonText}
|
||||
</button>
|
||||
)}
|
||||
{bottomSlot && <div data-testid="modal-bottom-slot">{bottomSlot}</div>}
|
||||
{!!bottomSlot && <div data-testid="modal-bottom-slot">{bottomSlot}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -78,7 +78,7 @@ vi.mock('@/app/components/base/app-icon', () => ({
|
||||
data-size={size}
|
||||
data-icon-type={iconType}
|
||||
>
|
||||
{innerIcon && <div data-testid="inner-icon">{innerIcon}</div>}
|
||||
{!!innerIcon && <div data-testid="inner-icon">{innerIcon}</div>}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
@@ -41,7 +41,7 @@ const Empty = ({
|
||||
<div className="mb-1 mt-2 text-[13px] font-medium leading-[18px] text-text-primary">
|
||||
{(hasTitle && renderType) ? t(`addToolModal.${renderType}.title`, { ns: 'tools' }) : 'No tools available'}
|
||||
</div>
|
||||
{(!isAgent && hasTitle && renderType) && (
|
||||
{!!(!isAgent && hasTitle && renderType) && (
|
||||
<Comp className={cn('flex items-center text-[13px] leading-[18px] text-text-tertiary', hasLink && 'cursor-pointer hover:text-text-accent')} {...linkProps}>
|
||||
{t(`addToolModal.${renderType}.tip`, { ns: 'tools' })}
|
||||
{' '}
|
||||
|
||||
@@ -95,7 +95,7 @@ const Base: FC<Props> = ({
|
||||
}}
|
||||
>
|
||||
{headerRight}
|
||||
{showCodeGenerator && codeLanguages && (
|
||||
{!!(showCodeGenerator && codeLanguages) && (
|
||||
<div className="ml-1">
|
||||
<CodeGeneratorButton
|
||||
onGenerated={onGenerated}
|
||||
@@ -119,7 +119,7 @@ const Base: FC<Props> = ({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{tip && <div className="px-1 py-0.5">{tip}</div>}
|
||||
{!!tip && <div className="px-1 py-0.5">{tip}</div>}
|
||||
<PromptEditorHeightResizeWrap
|
||||
height={isExpand ? editorExpandHeight : editorContentHeight}
|
||||
minHeight={editorContentMinHeight}
|
||||
|
||||
@@ -46,7 +46,7 @@ const Field: FC<Props> = ({
|
||||
{' '}
|
||||
{required && <span className="text-text-destructive">*</span>}
|
||||
</div>
|
||||
{tooltip && (
|
||||
{!!tooltip && (
|
||||
<Tooltip
|
||||
popupContent={tooltip}
|
||||
popupClassName="ml-1"
|
||||
@@ -55,13 +55,13 @@ const Field: FC<Props> = ({
|
||||
)}
|
||||
</div>
|
||||
<div className="flex">
|
||||
{operations && <div>{operations}</div>}
|
||||
{!!operations && <div>{operations}</div>}
|
||||
{supportFold && (
|
||||
<RiArrowDownSLine className="h-4 w-4 cursor-pointer text-text-tertiary transition-transform" style={{ transform: fold ? 'rotate(-90deg)' : 'rotate(0deg)' }} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{children && (!supportFold || (supportFold && !fold)) && <div className={cn(!inline && 'mt-1')}>{children}</div>}
|
||||
{!!(children && (!supportFold || (supportFold && !fold))) && <div className={cn(!inline && 'mt-1')}>{children}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ const Editor: FC<Props> = ({
|
||||
{' '}
|
||||
{required && <span className="text-text-destructive">*</span>}
|
||||
</div>
|
||||
{titleTooltip && <Tooltip popupContent={titleTooltip} />}
|
||||
{!!titleTooltip && <Tooltip popupContent={titleTooltip} />}
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<div className="text-xs font-medium leading-[18px] text-text-tertiary">{value?.length || 0}</div>
|
||||
|
||||
@@ -61,7 +61,7 @@ const VariableLabel = ({
|
||||
notShowFullPath={notShowFullPath}
|
||||
/>
|
||||
{
|
||||
variableType && (
|
||||
!!variableType && (
|
||||
<div className="system-xs-regular shrink-0 text-text-tertiary">
|
||||
{capitalize(variableType)}
|
||||
</div>
|
||||
|
||||
@@ -275,7 +275,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
||||
}
|
||||
</div>
|
||||
{
|
||||
data._iterationLength && data._iterationIndex && data._runningStatus === NodeRunningStatus.Running && (
|
||||
!!(data._iterationLength && data._iterationIndex && data._runningStatus === NodeRunningStatus.Running) && (
|
||||
<div className="mr-1.5 text-xs font-medium text-text-accent">
|
||||
{data._iterationIndex > data._iterationLength ? data._iterationLength : data._iterationIndex}
|
||||
/
|
||||
@@ -284,7 +284,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
data.type === BlockEnum.Loop && data._loopIndex && LoopIndex
|
||||
!!(data.type === BlockEnum.Loop && data._loopIndex) && LoopIndex
|
||||
}
|
||||
{
|
||||
isLoading
|
||||
@@ -327,7 +327,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
data.desc && data.type !== BlockEnum.Iteration && data.type !== BlockEnum.Loop && (
|
||||
!!(data.desc && data.type !== BlockEnum.Iteration && data.type !== BlockEnum.Loop) && (
|
||||
<div className="system-xs-regular whitespace-pre-line break-words px-3 pb-2 pt-1 text-text-tertiary">
|
||||
{data.desc}
|
||||
</div>
|
||||
|
||||
@@ -178,7 +178,7 @@ const VarList: FC<Props> = ({
|
||||
className="w-full"
|
||||
/>
|
||||
)}
|
||||
{item.operation === WriteMode.set && assignedVarType && (
|
||||
{!!(item.operation === WriteMode.set && assignedVarType) && (
|
||||
<>
|
||||
{assignedVarType === 'number' && (
|
||||
<Input
|
||||
|
||||
@@ -51,7 +51,7 @@ const NodeComponent: FC<NodeProps<AssignerNodeType>> = ({
|
||||
nodeType={node?.data.type}
|
||||
nodeTitle={node?.data.title}
|
||||
rightSlot={
|
||||
value.operation && <Badge className="!ml-auto shrink-0" text={t(`${i18nPrefix}.operations.${value.operation}`, { ns: 'workflow' })} />
|
||||
!!value.operation && <Badge className="!ml-auto shrink-0" text={t(`${i18nPrefix}.operations.${value.operation}`, { ns: 'workflow' })} />
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -41,7 +41,7 @@ const ChunkStructure = ({
|
||||
}}
|
||||
>
|
||||
{
|
||||
chunkStructure && (
|
||||
!!chunkStructure && (
|
||||
<OptionCard
|
||||
{...optionMap[chunkStructure]}
|
||||
selectedId={chunkStructure}
|
||||
|
||||
@@ -100,7 +100,7 @@ const OptionCard = memo(({
|
||||
>
|
||||
{effectElement}
|
||||
{
|
||||
icon && (
|
||||
!!icon && (
|
||||
<div className="mr-1 flex h-[18px] w-[18px] shrink-0 items-center justify-center">
|
||||
{typeof icon === 'function' ? icon(isActive) : icon}
|
||||
</div>
|
||||
@@ -139,7 +139,7 @@ const OptionCard = memo(({
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
children && isActive && (
|
||||
!!(children && isActive) && (
|
||||
<div className="relative rounded-b-xl bg-components-panel-bg p-3">
|
||||
<ArrowShape className="absolute left-[14px] top-[-11px] h-4 w-4 text-components-panel-bg" />
|
||||
{children}
|
||||
|
||||
@@ -118,7 +118,7 @@ const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
|
||||
/>
|
||||
</Group>
|
||||
{
|
||||
data.chunk_structure && (
|
||||
!!data.chunk_structure && (
|
||||
<>
|
||||
<BoxGroupField
|
||||
boxGroupProps={{
|
||||
|
||||
@@ -110,7 +110,7 @@ const DatasetItem: FC<Props> = ({
|
||||
</div>
|
||||
)}
|
||||
{
|
||||
payload.indexing_technique && (
|
||||
!!payload.indexing_technique && (
|
||||
<Badge
|
||||
className="shrink-0 group-hover/dataset-item:hidden"
|
||||
text={formatIndexingTechniqueAndMethod(payload.indexing_technique, payload.retrieval_model_dict?.search_method)}
|
||||
|
||||
@@ -46,7 +46,7 @@ const ConditionDate = ({
|
||||
}
|
||||
</div>
|
||||
{
|
||||
value && (
|
||||
!!value && (
|
||||
<RiCloseCircleFill
|
||||
className={cn(
|
||||
'hidden h-4 w-4 shrink-0 cursor-pointer hover:text-components-input-text-filled group-hover:block',
|
||||
|
||||
@@ -121,7 +121,7 @@ const ConfigPromptItem: FC<Props> = ({
|
||||
|
||||
<Tooltip
|
||||
popupContent={
|
||||
<div className="max-w-[180px]">{payload.role && t(`${i18nPrefix}.roleDescription.${payload.role}`, { ns: 'workflow' })}</div>
|
||||
<div className="max-w-[180px]">{!!payload.role && t(`${i18nPrefix}.roleDescription.${payload.role}`, { ns: 'workflow' })}</div>
|
||||
}
|
||||
triggerClassName="w-4 h-4"
|
||||
/>
|
||||
|
||||
@@ -86,7 +86,7 @@ const ConditionList = ({
|
||||
className="absolute right-1 top-1/2 flex h-[21px] -translate-y-1/2 cursor-pointer select-none items-center rounded-md border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-1 text-[10px] font-semibold text-text-accent-secondary shadow-xs"
|
||||
onClick={() => doToggleConditionLogicalOperator(conditionId)}
|
||||
>
|
||||
{logicalOperator && logicalOperator.toUpperCase()}
|
||||
{!!logicalOperator && logicalOperator.toUpperCase()}
|
||||
<RiLoopLeftLine className="ml-0.5 h-3 w-3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,7 +115,7 @@ const ConversationVariableModal = ({
|
||||
}}
|
||||
>
|
||||
</div>
|
||||
{latestValueTimestampMap[currentVar.id] && (
|
||||
{!!latestValueTimestampMap[currentVar.id] && (
|
||||
<div className="system-xs-regular shrink-0 text-text-tertiary">
|
||||
{t('chatVariable.updatedAt', { ns: 'workflow' })}
|
||||
{formatTime(latestValueTimestampMap[currentVar.id], t('dateTimeFormat', { ns: 'appLog' }) as string)}
|
||||
|
||||
@@ -79,7 +79,7 @@ const AgentLogItem = ({
|
||||
{label}
|
||||
</div>
|
||||
{
|
||||
metadata?.elapsed_time && (
|
||||
!!metadata?.elapsed_time && (
|
||||
<div className="system-xs-regular mr-2 shrink-0 text-text-tertiary">
|
||||
{metadata?.elapsed_time?.toFixed(3)}
|
||||
s
|
||||
|
||||
@@ -5,7 +5,7 @@ import { defineConfig, importESLintRules } from '@tsslint/config'
|
||||
export default defineConfig({
|
||||
rules: {
|
||||
...await importESLintRules({
|
||||
'react-x/no-leaked-conditional-rendering': 'warn',
|
||||
'react-x/no-leaked-conditional-rendering': 'error',
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user