mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
feat: list res
This commit is contained in:
parent
d454214ddc
commit
859b4cd6cc
@ -3,43 +3,51 @@ import type { FC } from 'react'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import AppIcon from '@/app/components/base/app-icon'
|
||||||
|
|
||||||
|
const i18nPrefix = 'app.checkLegacy.list'
|
||||||
type Props = {
|
type Props = {
|
||||||
|
className?: string
|
||||||
list: any[]
|
list: any[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const List: FC<Props> = ({
|
const List: FC<Props> = ({
|
||||||
|
className,
|
||||||
list,
|
list,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className='grow'>
|
||||||
{list.length > 0 ? (
|
{list.length > 0 ? (
|
||||||
<table className={cn('mt-2 w-full min-w-[440px] border-collapse border-0')}>
|
<table className={cn('mt-2 w-full min-w-[440px] border-collapse border-0')}>
|
||||||
<thead className='system-xs-medium-uppercase text-text-tertiary'>
|
<thead className='system-xs-medium-uppercase text-text-tertiary'>
|
||||||
<tr>
|
<tr>
|
||||||
<td className='whitespace-nowrap rounded-l-lg bg-background-section-burn pl-3 pr-1'>xxx</td>
|
<td className='whitespace-nowrap rounded-l-lg bg-background-section-burn pl-3 pr-1'>{t(`${i18nPrefix}.appName`)}</td>
|
||||||
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t('appLog.table.header.endUser')}</td>
|
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t(`${i18nPrefix}.published`)}</td>
|
||||||
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t('appLog.table.header.userRate')}</td>
|
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t(`${i18nPrefix}.createBy`)}</td>
|
||||||
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t('appLog.table.header.time')}</td>
|
<td className='whitespace-nowrap bg-background-section-burn py-1.5 pl-3'>{t(`${i18nPrefix}.lastRequest`)}</td>
|
||||||
<td className='whitespace-nowrap rounded-r-lg bg-background-section-burn py-1.5 pl-3'>{t('appLog.table.header.time')}</td>
|
<td className='whitespace-nowrap rounded-r-lg bg-background-section-burn py-1.5 pl-3'>{t(`${i18nPrefix}.createAt`)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="system-sm-regular text-text-secondary"></tbody>
|
<tbody className="system-sm-regular text-text-secondary">
|
||||||
{list.map((item, index) => (
|
{list.map((item, index) => (
|
||||||
<tr key={index} className='hover:bg-background-section-hover'>
|
<tr key={index} className='cursor-pointer border-b border-divider-subtle hover:bg-background-default-hover'>
|
||||||
<td className='w-5 whitespace-nowrap rounded-l-lg pl-3 pr-1'>
|
<td className='whitespace-nowrap rounded-l-lg py-2 pl-3 pr-1'>
|
||||||
Python bug fixer
|
<div className='flex items-center space-x-2'>
|
||||||
|
<AppIcon size='tiny' />
|
||||||
|
<div>Python bug fixer</div>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className='whitespace-nowrap py-1.5 pl-3'>Yes</td>
|
<td className='whitespace-nowrap py-1.5 pl-3'>{t('app.checkLegacy.yes')}</td>
|
||||||
<td className='whitespace-nowrap py-1.5 pl-3'>Evan · evan@dify.ai</td>
|
<td className='whitespace-nowrap py-1.5 pl-3'>Evan · evan@dify.ai</td>
|
||||||
<td className='whitespace-nowrap py-1.5 pl-3'>2023-03-21 10:25</td>
|
<td className='whitespace-nowrap py-1.5 pl-3'>2023-03-21 10:25</td>
|
||||||
<td className='whitespace-nowrap rounded-r-lg py-1.5 pl-3'>2023-03-21 10:25</td>
|
<td className='whitespace-nowrap rounded-r-lg py-1.5 pl-3'>2023-03-21 10:25</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
) : (
|
) : (
|
||||||
<div className='system-md-regular text-text-secondary'>No items found</div>
|
<div className='system-md-regular flex items-center justify-center text-text-secondary'>{t(`${i18nPrefix}.noData`)}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,12 +8,16 @@ import { RiFilter3Line, RiLoopLeftLine } from '@remixicon/react'
|
|||||||
import { useCallback } from 'react'
|
import { 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/button'
|
||||||
|
import Pagination from '@/app/components/base/pagination'
|
||||||
|
import { APP_PAGE_LIMIT } from '@/config'
|
||||||
|
import { noop } from 'lodash'
|
||||||
|
|
||||||
const i18nPrefix = 'app.checkLegacy'
|
const i18nPrefix = 'app.checkLegacy'
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const {
|
const {
|
||||||
list,
|
list,
|
||||||
|
total,
|
||||||
sort_by,
|
sort_by,
|
||||||
setOrderBy,
|
setOrderBy,
|
||||||
published,
|
published,
|
||||||
@ -37,43 +41,55 @@ const Page = () => {
|
|||||||
}, [published, t])
|
}, [published, t])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='h-full rounded-t-2xl border-t border-effects-highlight bg-background-default-subtle px-6 pt-4'>
|
<div className='flex grow flex-col rounded-t-2xl border-t border-effects-highlight bg-background-default-subtle px-6 pt-4'>
|
||||||
<Header appNum={5} publishedNum={3}/>
|
<Header appNum={5} publishedNum={3}/>
|
||||||
{/* Filter */}
|
<div className='flex grow'>
|
||||||
<div className='mb-2 mt-4 flex items-center justify-between'>
|
<div className='flex flex-col'>
|
||||||
<div className='flex items-center gap-2'>
|
{/* Filter */}
|
||||||
<Chip
|
<div className='mb-2 mt-4 flex items-center justify-between'>
|
||||||
className='min-w-[150px]'
|
<div className='flex items-center gap-2'>
|
||||||
panelClassName='w-[270px]'
|
<Chip
|
||||||
leftIcon={<RiFilter3Line className='h-4 w-4 text-text-secondary' />}
|
className='min-w-[150px]'
|
||||||
value={published}
|
panelClassName='w-[270px]'
|
||||||
renderTriggerContent={renderTriggerContent}
|
leftIcon={<RiFilter3Line className='h-4 w-4 text-text-secondary' />}
|
||||||
onSelect={handleSelectPublished}
|
value={published}
|
||||||
onClear={clearPublished}
|
renderTriggerContent={renderTriggerContent}
|
||||||
items={[
|
onSelect={handleSelectPublished}
|
||||||
{ value: 1, name: t(`${i18nPrefix}.yes`) },
|
onClear={clearPublished}
|
||||||
{ value: 0, name: t(`${i18nPrefix}.no`) },
|
items={[
|
||||||
]}
|
{ value: 1, name: t(`${i18nPrefix}.yes`) },
|
||||||
/>
|
{ value: 0, name: t(`${i18nPrefix}.no`) },
|
||||||
<div className='h-3.5 w-px bg-divider-regular'></div>
|
]}
|
||||||
<Sort
|
/>
|
||||||
// '-' means descending order
|
<div className='h-3.5 w-px bg-divider-regular'></div>
|
||||||
order={sort_by?.startsWith('-') ? '-' : ''}
|
<Sort
|
||||||
value={sort_by?.replace('-', '') || 'created_at'}
|
// '-' means descending order
|
||||||
items={[
|
order={sort_by?.startsWith('-') ? '-' : ''}
|
||||||
{ value: 'created_at', name: t(`${i18nPrefix}.createAt`) },
|
value={sort_by?.replace('-', '') || 'created_at'}
|
||||||
{ value: 'last_request', name: t(`${i18nPrefix}.lastRequest`) },
|
items={[
|
||||||
]}
|
{ value: 'created_at', name: t(`${i18nPrefix}.createAt`) },
|
||||||
onSelect={setOrderBy}
|
{ value: 'last_request', name: t(`${i18nPrefix}.lastRequest`) },
|
||||||
/>
|
]}
|
||||||
|
onSelect={setOrderBy}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Button >
|
||||||
|
<RiLoopLeftLine className='mr-1 h-4 w-4' />
|
||||||
|
{t('common.operation.reset')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<List list={list} />
|
||||||
|
{(total && total > APP_PAGE_LIMIT)
|
||||||
|
? <Pagination
|
||||||
|
className='shrink-0'
|
||||||
|
current={1}
|
||||||
|
onChange={noop}
|
||||||
|
total={total}
|
||||||
|
limit={10}
|
||||||
|
onLimitChange={noop}
|
||||||
|
/>
|
||||||
|
: null}
|
||||||
</div>
|
</div>
|
||||||
<Button >
|
|
||||||
<RiLoopLeftLine className='mr-1 h-4 w-4' />
|
|
||||||
{t('common.operation.reset')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<List list={list} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -30,6 +30,7 @@ const useLegacyList = () => {
|
|||||||
}, [queryParams])
|
}, [queryParams])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
total: 100,
|
||||||
list,
|
list,
|
||||||
sort_by,
|
sort_by,
|
||||||
setOrderBy,
|
setOrderBy,
|
||||||
|
|||||||
@ -241,6 +241,14 @@ const translation = {
|
|||||||
no: 'No',
|
no: 'No',
|
||||||
createAt: 'Created At',
|
createAt: 'Created At',
|
||||||
lastRequest: 'Last Request',
|
lastRequest: 'Last Request',
|
||||||
|
list: {
|
||||||
|
appName: 'App Name',
|
||||||
|
published: 'Published',
|
||||||
|
createBy: 'Created By',
|
||||||
|
lastRequest: 'Last Request',
|
||||||
|
createAt: 'Created At',
|
||||||
|
noData: 'No items found',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -242,6 +242,14 @@ const translation = {
|
|||||||
no: '否',
|
no: '否',
|
||||||
createAt: '创建时间',
|
createAt: '创建时间',
|
||||||
lastRequest: '最后请求',
|
lastRequest: '最后请求',
|
||||||
|
list: {
|
||||||
|
appName: '应用名称',
|
||||||
|
published: '已发布',
|
||||||
|
createBy: '创建者',
|
||||||
|
lastRequest: '最后请求时间',
|
||||||
|
createAt: '创建时间',
|
||||||
|
noData: '暂无数据',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user