Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Feb 15, 2024
1 parent 95ea90e commit 04c969b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
6 changes: 4 additions & 2 deletions packages/canyon-platform/locales/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"reported_details": "上报细节",
"reporter": "上报人",
"search_keywords": "搜索关键字",
"overview_search_keywords": "搜索关键字"
"overview_search_keywords": "搜索关键字",
"coverage_details": "覆盖率详情"
},
"settings": {
"desc": "设置您的账户信息",
Expand All @@ -55,7 +56,8 @@
"search": "搜索",
"no_data": "暂无数据",
"no_result": "暂无结果",
"created_at": "创建时间"
"created_at": "创建时间",
"total_items": "共计 {{total}} 项"
},
"app": {
"logout": "退出登录",
Expand Down
14 changes: 9 additions & 5 deletions packages/canyon-platform/src/layouts/genBreadcrumbItems.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { useNavigate } from 'react-router-dom';
import {useTranslation} from "react-i18next";
function matchPattern(str) {
return /^\/projects\/\d+(?!(\/\d+))$/.test(str);
}

export function genBreadcrumbItems(pathname:string) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const {t} = useTranslation();
// eslint-disable-next-line react-hooks/rules-of-hooks
const nav = useNavigate();
if (matchPattern(pathname)) {
return [
{
title: <span className={'cursor-pointer'}>Projects</span>,
title: <span className={'cursor-pointer'}>{t('menus.projects')}</span>,
onClick() {
nav('/projects');
},
},
{
title: 'Overview',
title: t('projects.overview'),
},
];
} else if (pathname.includes('commits')) {
return [
{
title: <span className={'cursor-pointer'}>Projects</span>,
title: <span className={'cursor-pointer'}>{t('menus.projects')}</span>,
onClick() {
nav('/projects');
},
},
{
title: <span className={'cursor-pointer'}>Overview</span>,
title: <span className={'cursor-pointer'}>{t('projects.overview')}</span>,
onClick() {
const regex = /\/projects\/(\d+)\//;
const match = pathname.match(regex);
Expand All @@ -40,7 +43,8 @@ export function genBreadcrumbItems(pathname:string) {
},
},
{
title: 'Coverage Details',
title: t('projects.coverage_details'),
// title: 'Coverage Details',
},
];
} else {
Expand Down
24 changes: 12 additions & 12 deletions packages/canyon-platform/src/pages/index/projects/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ const ProjectOverviewPage = () => {
},
},
{
title: 'Branch',
title: t('projects.branch'),
dataIndex: 'branch',
width: '160px',
ellipsis: true,
},
{
title: 'Compare Target',
title: t('projects.compare_target'),
dataIndex: 'compareTarget',
width: '160px',
render(_, { compareUrl }): JSX.Element {
Expand All @@ -101,13 +101,13 @@ const ProjectOverviewPage = () => {
},
},
{
title: 'Message',
title: t('projects.message'),
dataIndex: 'message',
width: '160px',
ellipsis: true,
},
{
title: 'Statements',
title: t('projects.statements'),
dataIndex: 'statements',
render(_, { sha }) {
return (
Expand All @@ -125,7 +125,7 @@ const ProjectOverviewPage = () => {
},
},
{
title: 'New Lines',
title: t('projects.newlines'),
dataIndex: 'newlines',
render(_, { sha }) {
return (
Expand All @@ -142,19 +142,19 @@ const ProjectOverviewPage = () => {
},
},
{
title: 'Times',
title: t('projects.report_times'),
dataIndex: 'times',
},
{
title: 'Last Report',
title: t('projects.latest_report_time'),
dataIndex: 'lastReportTime',
width: '120px',
render(_) {
return <span>{dayjs(_).format('MM-DD HH:mm')}</span>;
},
},
{
title: 'Option',
title: t('common.option'),
render(_): JSX.Element {
return (
<div className={'w-[100px]'}>
Expand All @@ -164,7 +164,7 @@ const ProjectOverviewPage = () => {
setSha(_.sha);
}}
>
Logs
{t('projects.reported_details')}
</a>
</div>
);
Expand Down Expand Up @@ -242,7 +242,7 @@ const ProjectOverviewPage = () => {
borderRadius: `${token.borderRadius}px`,
}}
>
<Title level={4}>Trends in coverage</Title>
<Title level={4}>{t('projects.trends_in_coverage')}</Title>
<ReactECharts
theme={
localStorage.getItem('theme') === 'dark'
Expand All @@ -263,7 +263,7 @@ const ProjectOverviewPage = () => {
{t('projects.records')}
</Text>
<Input.Search
placeholder={'Enter the "Commit Sha" or "Branch" or "Compare Target" keyword for search'}
placeholder={t('projects.overview_search_keywords')}
onSearch={(value) => {
// setSearchValue(value);
setKeyword(value);
Expand All @@ -282,7 +282,7 @@ const ProjectOverviewPage = () => {
rowKey={'sha'}
columns={columns}
pagination={{
showTotal: (total) => `Total ${total} items`,
showTotal: (total) => t('common.total_items', { total }),
total: projectsData?.getProjectRecords?.total,
current,
pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const ProjectPage = () => {
rowKey={'id'}
pagination={{
total: projectsData?.getProjects?.total,
showTotal: (total) => `Total ${total} items`,
showTotal: (total) => t('common.total_items', { total }),
current,
pageSize,
}}
Expand Down

0 comments on commit 04c969b

Please sign in to comment.