This commit is contained in:
Joel
2024-12-04 16:05:11 +08:00
15 changed files with 75 additions and 86 deletions

View File

@ -25,7 +25,7 @@ import AnnotationFullModal from '@/app/components/billing/annotation-full/modal'
import { Settings04 } from '@/app/components/base/icons/src/vender/line/general' import { Settings04 } from '@/app/components/base/icons/src/vender/line/general'
import type { App } from '@/types/app' import type { App } from '@/types/app'
interface Props { type Props = {
appDetail: App appDetail: App
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable multiline-ternary */
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'

View File

@ -114,35 +114,12 @@ const Logs: FC<ILogsProps> = ({ appDetail }) => {
{/* Show Pagination only if the total is more than the limit */} {/* Show Pagination only if the total is more than the limit */}
{(total && total > APP_PAGE_LIMIT) {(total && total > APP_PAGE_LIMIT)
? <Pagination ? <Pagination
className="flex items-center w-full h-10 text-sm select-none mt-8" current={currPage}
currentPage={currPage} onChange={setCurrPage}
edgePageCount={2} total={total}
middlePagesSiblingCount={1} limit={limit}
setCurrentPage={setCurrPage} onLimitChange={setLimit}
totalPages={Math.ceil(total / APP_PAGE_LIMIT)} />
truncableClassName="w-8 px-0.5 text-center"
truncableText="..."
>
<Pagination.PrevButton
disabled={currPage === 0}
className={`flex items-center mr-2 text-gray-500 focus:outline-none ${currPage === 0 ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:text-gray-600 dark:hover:text-gray-200'}`} >
<ArrowLeftIcon className="mr-3 h-3 w-3" />
{t('appLog.table.pagination.previous')}
</Pagination.PrevButton>
<div className={`flex items-center justify-center grow ${s.pagination}`}>
<Pagination.PageButton
activeClassName="bg-primary-50 dark:bg-opacity-0 text-primary-600 dark:text-white"
className="flex items-center justify-center h-8 w-8 rounded-full cursor-pointer"
inactiveClassName="text-gray-500"
/>
</div>
<Pagination.NextButton
disabled={currPage === Math.ceil(total / APP_PAGE_LIMIT) - 1}
className={`flex items-center mr-2 text-gray-500 focus:outline-none ${currPage === Math.ceil(total / APP_PAGE_LIMIT) - 1 ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:text-gray-600 dark:hover:text-gray-200'}`} >
{t('appLog.table.pagination.next')}
<ArrowRightIcon className="ml-3 h-3 w-3" />
</Pagination.NextButton>
</Pagination>
: null} : null}
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@ const Badge = ({
return ( return (
<div <div
className={cn( className={cn(
'relative inline-flex items-center px-[5px] h-5 rounded-[5px] border border-divider-deep leading-3 text-text-tertiary', 'inline-flex items-center px-[5px] h-5 rounded-[5px] border border-divider-deep leading-3 text-text-tertiary',
uppercase ? 'system-2xs-medium-uppercase' : 'system-xs-medium', uppercase ? 'system-2xs-medium-uppercase' : 'system-xs-medium',
className, className,
)} )}

View File

@ -10,7 +10,7 @@ const usePagination = ({
edgePageCount, edgePageCount,
middlePagesSiblingCount, middlePagesSiblingCount,
}: IPaginationProps): IUsePagination => { }: IPaginationProps): IUsePagination => {
const pages = Array(totalPages) const pages = new Array(totalPages)
.fill(0) .fill(0)
.map((_, i) => i + 1) .map((_, i) => i + 1)

View File

@ -33,20 +33,20 @@ const CustomizedPagination: FC<Props> = ({
const [showPerPageTip, setShowPerPageTip] = React.useState(false) const [showPerPageTip, setShowPerPageTip] = React.useState(false)
const { run: handlePaging } = useDebounceFn((value: string) => { const { run: handlePaging } = useDebounceFn((value: string) => {
if (parseInt(value) > totalPages) { if (Number.parseInt(value) > totalPages) {
setInputValue(totalPages) setInputValue(totalPages)
onChange(totalPages - 1) onChange(totalPages - 1)
setShowInput(false) setShowInput(false)
return return
} }
if (parseInt(value) < 1) { if (Number.parseInt(value) < 1) {
setInputValue(1) setInputValue(1)
onChange(0) onChange(0)
setShowInput(false) setShowInput(false)
return return
} }
onChange(parseInt(value) - 1) onChange(Number.parseInt(value) - 1)
setInputValue(parseInt(value)) setInputValue(Number.parseInt(value))
setShowInput(false) setShowInput(false)
}, { wait: 500 }) }, { wait: 500 })
@ -54,9 +54,9 @@ const CustomizedPagination: FC<Props> = ({
const value = e.target.value const value = e.target.value
if (!value) if (!value)
return setInputValue('') return setInputValue('')
if (isNaN(parseInt(value))) if (isNaN(Number.parseInt(value)))
return setInputValue('') return setInputValue('')
setInputValue(parseInt(value)) setInputValue(Number.parseInt(value))
handlePaging(value) handlePaging(value)
} }

View File

@ -675,7 +675,7 @@ const StepTwo = ({
value={maxChunkLength} value={maxChunkLength}
max={limitMaxChunkLength} max={limitMaxChunkLength}
min={1} min={1}
onChange={e => setMaxChunkLength(parseInt(e.target.value.replace(/^0+/, ''), 10))} onChange={e => setMaxChunkLength(Number.parseInt(e.target.value.replace(/^0+/, ''), 10))}
/> />
</div> </div>
</div> </div>

View File

@ -41,9 +41,11 @@ const WorkplaceSelector = () => {
group hover:bg-state-base-hover cursor-pointer ${open && 'bg-state-base-hover'} rounded-[10px] group hover:bg-state-base-hover cursor-pointer ${open && 'bg-state-base-hover'} rounded-[10px]
`, `,
)}> )}>
<div className='flex items-center justify-center w-7 h-7 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600'>{currentWorkspace?.name[0].toLocaleUpperCase()}</div> <div className='flex items-center justify-center w-7 h-7 bg-[#EFF4FF] rounded-lg text-xs font-medium text-primary-600'>{currentWorkspace?.name[0].toLocaleUpperCase()}</div>
<div className={'truncate max-w-[80px] text-text-secondary system-sm-medium'}>{currentWorkspace?.name}</div> <div className='flex flex-row'>
<RiArrowDownSLine className='w-4 h-4 text-text-secondary' /> <div className={'truncate max-w-[80px] text-text-secondary system-sm-medium'}>{currentWorkspace?.name}</div>
<RiArrowDownSLine className='w-4 h-4 text-text-secondary' />
</div>
</Menu.Button> </Menu.Button>
<Transition <Transition
as={Fragment} as={Fragment}
@ -68,7 +70,7 @@ const WorkplaceSelector = () => {
{ {
workspaces.map(workspace => ( workspaces.map(workspace => (
<div className='flex py-1 pl-3 pr-2 items-center gap-2 self-stretch hover:bg-state-base-hover rounded-lg' key={workspace.id} onClick={() => handleSwitchWorkspace(workspace.id)}> <div className='flex py-1 pl-3 pr-2 items-center gap-2 self-stretch hover:bg-state-base-hover rounded-lg' key={workspace.id} onClick={() => handleSwitchWorkspace(workspace.id)}>
<div className='flex items-center justify-center w-7 h-7 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600'>{workspace.name[0].toLocaleUpperCase()}</div> <div className='flex items-center justify-center w-6 h-6 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600'>{workspace.name[0].toLocaleUpperCase()}</div>
<div className='line-clamp-1 grow overflow-hidden text-text-secondary text-ellipsis system-md-regular cursor-pointer'>{workspace.name}</div> <div className='line-clamp-1 grow overflow-hidden text-text-secondary text-ellipsis system-md-regular cursor-pointer'>{workspace.name}</div>
{ {
<PremiumBadge size='s' color='gray' allowHover={false}> <PremiumBadge size='s' color='gray' allowHover={false}>

View File

@ -13,10 +13,9 @@ import EnvNav from './env-nav'
import PluginsNav from './plugins-nav' import PluginsNav from './plugins-nav'
import ExploreNav from './explore-nav' import ExploreNav from './explore-nav'
import ToolsNav from './tools-nav' import ToolsNav from './tools-nav'
import GithubStar from './github-star'
import LicenseNav from './license-env' import LicenseNav from './license-env'
import { WorkspaceProvider } from '@/context/workspace-context' import { WorkspaceProvider } from '@/context/workspace-context'
import AppContext, { useAppContext } from '@/context/app-context' import { useAppContext } from '@/context/app-context'
import LogoSite from '@/app/components/base/logo/logo-site' import LogoSite from '@/app/components/base/logo/logo-site'
import WorkplaceSelector from '@/app/components/header/account-dropdown/workplace-selector' import WorkplaceSelector from '@/app/components/header/account-dropdown/workplace-selector'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
@ -61,7 +60,8 @@ const Header = () => {
> >
<Bars3Icon className="h-4 w-4 text-gray-500" /> <Bars3Icon className="h-4 w-4 text-gray-500" />
</div>} </div>}
{!isMobile {
!isMobile
&& <div className='flex w-64 p-2 pl-3 gap-1.5 items-center shrink-0 self-stretch'> && <div className='flex w-64 p-2 pl-3 gap-1.5 items-center shrink-0 self-stretch'>
<Link href="/apps" className='flex w-8 h-8 items-center justify-center gap-2 shrink-0'> <Link href="/apps" className='flex w-8 h-8 items-center justify-center gap-2 shrink-0'>
<LogoSite className='object-contain' /> <LogoSite className='object-contain' />
@ -93,29 +93,32 @@ const Header = () => {
<LogoSite /> <LogoSite />
</Link> </Link>
<div className='font-light text-divider-deep'>/</div> <div className='font-light text-divider-deep'>/</div>
{enableBilling && ( {
<div className='select-none'> enableBilling && (
<PremiumBadge color='blue' allowHover={true} onClick={handlePlanClick}> <div className='select-none'>
<SparklesSoft className='flex items-center py-[1px] pl-[3px] w-3.5 h-3.5 text-components-premium-badge-indigo-text-stop-0' /> <PremiumBadge color='blue' allowHover={true} onClick={handlePlanClick}>
<div className='system-xs-medium'> <SparklesSoft className='flex items-center py-[1px] pl-[3px] w-3.5 h-3.5 text-components-premium-badge-indigo-text-stop-0' />
<span className='p-1'> <div className='system-xs-medium'>
{t('billing.upgradeBtn.encourageShort')} <span className='p-1'>
</span> {t('billing.upgradeBtn.encourageShort')}
</div> </span>
</PremiumBadge> </div>
</div> </PremiumBadge>
)} </div>
<GithubStar /> )
</div> }
)} </div >
{!isMobile && (
<div className='flex items-center'>
{!isCurrentWorkspaceDatasetOperator && <ExploreNav className={navClassName} />}
{!isCurrentWorkspaceDatasetOperator && <AppNav />}
{(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && <DatasetNav />}
{!isCurrentWorkspaceDatasetOperator && <ToolsNav className={navClassName} />}
</div>
)} )}
{
!isMobile && (
<div className='flex items-center'>
{!isCurrentWorkspaceDatasetOperator && <ExploreNav className={navClassName} />}
{!isCurrentWorkspaceDatasetOperator && <AppNav />}
{(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && <DatasetNav />}
{!isCurrentWorkspaceDatasetOperator && <ToolsNav className={navClassName} />}
</div>
)
}
<div className='flex items-center shrink-0'> <div className='flex items-center shrink-0'>
<LicenseNav /> <LicenseNav />
<EnvNav /> <EnvNav />
@ -124,15 +127,17 @@ const Header = () => {
</div> </div>
<AccountDropdown isMobile={isMobile} /> <AccountDropdown isMobile={isMobile} />
</div> </div>
{(isMobile && isShowNavMenu) && ( {
<div className='w-full flex flex-col p-2 gap-y-1'> (isMobile && isShowNavMenu) && (
{!isCurrentWorkspaceDatasetOperator && <ExploreNav className={navClassName} />} <div className='w-full flex flex-col p-2 gap-y-1'>
{!isCurrentWorkspaceDatasetOperator && <AppNav />} {!isCurrentWorkspaceDatasetOperator && <ExploreNav className={navClassName} />}
{(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && <DatasetNav />} {!isCurrentWorkspaceDatasetOperator && <AppNav />}
{!isCurrentWorkspaceDatasetOperator && <ToolsNav className={navClassName} />} {(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && <DatasetNav />}
</div> {!isCurrentWorkspaceDatasetOperator && <ToolsNav className={navClassName} />}
)} </div>
</div> )
}
</div >
) )
} }
export default Header export default Header

View File

@ -51,7 +51,7 @@ const Field: FC<Props> = ({
<div className='flex'> <div className='flex'>
{operations && <div>{operations}</div>} {operations && <div>{operations}</div>}
{supportFold && ( {supportFold && (
<RiArrowDownSLine className='w-4 h-4 text-text-tertiary cursor-pointer transform transition-transform' style={{ transform: fold ? 'rotate(-90deg)' : 'rotate(0deg)' }} /> <RiArrowDownSLine className='w-4 h-4 text-text-tertiary cursor-pointer transition-transform' style={{ transform: fold ? 'rotate(-90deg)' : 'rotate(0deg)' }} />
)} )}
</div> </div>
</div> </div>

View File

@ -108,7 +108,7 @@ const OperationSelector: FC<OperationSelectorProps> = ({
}} }}
> >
<div className='flex min-h-5 px-1 items-center gap-1 grow'> <div className='flex min-h-5 px-1 items-center gap-1 grow'>
<span className={'flex flex-grow text-text-secondary system-sm-medium'}>{t(`${i18nPrefix}.operations.${item.name}`)}</span> <span className={'flex grow text-text-secondary system-sm-medium'}>{t(`${i18nPrefix}.operations.${item.name}`)}</span>
</div> </div>
{item.value === value && ( {item.value === value && (
<div className='flex justify-center items-center'> <div className='flex justify-center items-center'>

View File

@ -128,7 +128,7 @@ const VarList: FC<Props> = ({
return ( return (
<div className='flex items-start gap-1 self-stretch' key={index}> <div className='flex items-start gap-1 self-stretch' key={index}>
<div className='flex flex-col items-start gap-1 flex-grow'> <div className='flex flex-col items-start gap-1 grow'>
<div className='flex items-center gap-1 self-stretch'> <div className='flex items-center gap-1 self-stretch'>
<VarReferencePicker <VarReferencePicker
readonly={readonly} readonly={readonly}
@ -212,7 +212,7 @@ const VarList: FC<Props> = ({
</div> </div>
<ActionButton <ActionButton
size='l' size='l'
className='flex-shrink-0 group hover:!bg-state-destructive-hover' className='shrink-0 group hover:!bg-state-destructive-hover'
onClick={handleVarRemove(index)} onClick={handleVarRemove(index)}
> >
<RiDeleteBinLine className='text-text-tertiary w-4 h-4 group-hover:text-text-destructive' /> <RiDeleteBinLine className='text-text-tertiary w-4 h-4 group-hover:text-text-destructive' />

View File

@ -7,11 +7,9 @@ import {
import VarList from './components/var-list' import VarList from './components/var-list'
import useConfig from './use-config' import useConfig from './use-config'
import type { AssignerNodeType } from './types' import type { AssignerNodeType } from './types'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import type { NodePanelProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
import cn from '@/utils/classnames'
import ActionButton from '@/app/components/base/action-button'
import { useHandleAddOperationItem } from './hooks' import { useHandleAddOperationItem } from './hooks'
import ActionButton from '@/app/components/base/action-button'
const i18nPrefix = 'workflow.nodes.assigner' const i18nPrefix = 'workflow.nodes.assigner'
@ -42,7 +40,7 @@ const Panel: FC<NodePanelProps<AssignerNodeType>> = ({
<div className='flex py-2 flex-col items-start self-stretch'> <div className='flex py-2 flex-col items-start self-stretch'>
<div className='flex flex-col justify-center items-start gap-1 px-4 py-2 w-full self-stretch'> <div className='flex flex-col justify-center items-start gap-1 px-4 py-2 w-full self-stretch'>
<div className='flex items-start gap-2 self-stretch'> <div className='flex items-start gap-2 self-stretch'>
<div className='flex flex-col justify-center items-start flex-grow text-text-secondary system-sm-semibold-uppercase'>{t(`${i18nPrefix}.variables`)}</div> <div className='flex flex-col justify-center items-start grow text-text-secondary system-sm-semibold-uppercase'>{t(`${i18nPrefix}.variables`)}</div>
<ActionButton onClick={handleAddOperation}> <ActionButton onClick={handleAddOperation}>
<RiAddLine className='w-4 h-4 shrink-0 text-text-tertiary' /> <RiAddLine className='w-4 h-4 shrink-0 text-text-tertiary' />
</ActionButton> </ActionButton>

View File

@ -0,0 +1,4 @@
const translation = {
}
export default translation

4
web/i18n/th-TH/plugin.ts Normal file
View File

@ -0,0 +1,4 @@
const translation = {
}
export default translation