Skip to content

Commit 4eba79a

Browse files
Optimize deps-table package and version filtering (#14)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 6c6a8fa commit 4eba79a

8 files changed

Lines changed: 118 additions & 94 deletions

File tree

src/components/main-layout.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
ReadOutlined,
88
UserOutlined,
99
} from '@ant-design/icons';
10-
import { Button, Dropdown, Grid, Layout, Menu, message } from 'antd';
1110
import type { MenuProps } from 'antd';
11+
import { Button, Dropdown, Grid, Layout, Menu, message } from 'antd';
1212
import type { ReactNode } from 'react';
1313
import { useEffect, useState } from 'react';
1414
import { Outlet } from 'react-router-dom';
@@ -57,7 +57,9 @@ const MainLayout = () => {
5757
{
5858
key: 'about',
5959
icon: <InfoCircleOutlined />,
60-
label: <ExtLink href="https://reactnative.cn/about.html">关于我们</ExtLink>,
60+
label: (
61+
<ExtLink href="https://reactnative.cn/about.html">关于我们</ExtLink>
62+
),
6163
},
6264
...(user
6365
? [
@@ -103,9 +105,7 @@ const MainLayout = () => {
103105
onClick={() => setMobileNavOpen(true)}
104106
/>
105107
)}
106-
{isMobile && (
107-
<LogoH className="h-6 w-auto max-w-[140px]" />
108-
)}
108+
{isMobile && <LogoH className="h-6 w-auto max-w-[140px]" />}
109109
</div>
110110
<div className="flex items-center">
111111
{isMobile ? (
@@ -117,7 +117,11 @@ const MainLayout = () => {
117117
<Button type="text" icon={<MoreOutlined />} />
118118
</Dropdown>
119119
) : (
120-
<Menu mode="horizontal" selectable={false} items={headerItems} />
120+
<Menu
121+
mode="horizontal"
122+
selectable={false}
123+
items={headerItems}
124+
/>
121125
)}
122126
</div>
123127
</div>

src/components/sider.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ const SiderMenu = ({ selectedKeys, onNavigate }: SiderMenuProps) => {
250250
{
251251
key: 'realtime-metrics',
252252
icon: <LineChartOutlined />,
253-
label: (
254-
<Link to={rootRouterPath.realtimeMetrics}>实时数据</Link>
255-
),
253+
label: <Link to={rootRouterPath.realtimeMetrics}>实时数据</Link>,
256254
},
257255
{
258256
key: 'apps',

src/pages/admin-apps.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
Card,
66
Form,
77
Input,
8-
message,
98
Modal,
9+
message,
1010
Select,
1111
Space,
1212
Spin,
@@ -126,10 +126,15 @@ export const Component = () => {
126126
key: 'platform',
127127
width: 80,
128128
render: (platform: string) => (
129-
<span className={
130-
platform === 'ios' ? 'text-blue-600' :
131-
platform === 'android' ? 'text-green-600' : 'text-orange-600'
132-
}>
129+
<span
130+
className={
131+
platform === 'ios'
132+
? 'text-blue-600'
133+
: platform === 'android'
134+
? 'text-green-600'
135+
: 'text-orange-600'
136+
}
137+
>
133138
{platform}
134139
</span>
135140
),
@@ -231,7 +236,12 @@ export const Component = () => {
231236
>
232237
<Form form={form} layout="vertical" className="mt-4">
233238
<Space className="w-full" direction="vertical" size="middle">
234-
<Form.Item name="name" label="名称" className="mb-0!" rules={[{ required: true }]}>
239+
<Form.Item
240+
name="name"
241+
label="名称"
242+
className="mb-0!"
243+
rules={[{ required: true }]}
244+
>
235245
<Input />
236246
</Form.Item>
237247
<Form.Item name="appKey" label="App Key" className="mb-0!">
@@ -255,7 +265,11 @@ export const Component = () => {
255265
<Form.Item name="status" label="状态" className="mb-0!">
256266
<Input placeholder="自定义状态" />
257267
</Form.Item>
258-
<Form.Item name="ignoreBuildTime" label="忽略构建时间" className="mb-0!">
268+
<Form.Item
269+
name="ignoreBuildTime"
270+
label="忽略构建时间"
271+
className="mb-0!"
272+
>
259273
<Select
260274
allowClear
261275
options={[

src/pages/admin-config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import {
55
Card,
66
Form,
77
Input,
8-
message,
98
Modal,
9+
message,
1010
Popconfirm,
1111
Space,
1212
Spin,
1313
Table,
1414
Typography,
1515
} from 'antd';
1616
import { useCallback, useEffect, useRef, useState } from 'react';
17-
import { JSONEditor, type Content, type OnChange } from 'vanilla-jsoneditor';
17+
import { type Content, JSONEditor, type OnChange } from 'vanilla-jsoneditor';
1818
import { adminApi } from '@/services/admin-api';
1919

2020
const { Title } = Typography;

src/pages/admin-users.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
DatePicker,
77
Form,
88
Input,
9-
message,
109
Modal,
10+
message,
1111
Select,
1212
Space,
1313
Spin,
@@ -16,7 +16,7 @@ import {
1616
} from 'antd';
1717
import dayjs from 'dayjs';
1818
import { useEffect, useRef, useState } from 'react';
19-
import { JSONEditor, type Content, type OnChange } from 'vanilla-jsoneditor';
19+
import { type Content, JSONEditor, type OnChange } from 'vanilla-jsoneditor';
2020
import { adminApi } from '@/services/admin-api';
2121

2222
const { Title } = Typography;
@@ -177,7 +177,9 @@ export const Component = () => {
177177
key: 'status',
178178
width: 100,
179179
render: (status: string) => (
180-
<span className={status === 'normal' ? 'text-green-600' : 'text-orange-500'}>
180+
<span
181+
className={status === 'normal' ? 'text-green-600' : 'text-orange-500'}
182+
>
181183
{status === 'normal' ? '正常' : '未验证'}
182184
</span>
183185
),
@@ -293,10 +295,17 @@ export const Component = () => {
293295
]}
294296
/>
295297
</Form.Item>
296-
<Form.Item name="tierExpiresAt" label="套餐过期时间" className="mb-0!">
298+
<Form.Item
299+
name="tierExpiresAt"
300+
label="套餐过期时间"
301+
className="mb-0!"
302+
>
297303
<DatePicker showTime className="w-full" />
298304
</Form.Item>
299-
<Form.Item label="自定义配额 (JSON,留空则使用默认配额)" className="mb-0!">
305+
<Form.Item
306+
label="自定义配额 (JSON,留空则使用默认配额)"
307+
className="mb-0!"
308+
>
300309
<JsonEditorWrapper value={quotaValue} onChange={setQuotaValue} />
301310
</Form.Item>
302311
</Space>

src/pages/manage/components/bind-package.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,18 @@ const BindPackage = ({
373373
key: 'gray',
374374
label: '灰度',
375375
icon: <ExperimentOutlined />,
376-
children: [1, 2, 5, 10, 20, 50].reduce<NonNullable<MenuProps['items']>>(
377-
(acc, percentage) => {
378-
if (percentage > rolloutConfigNumber) {
379-
acc.push({
380-
key: `${percentage}`,
381-
label: `${percentage}%`,
382-
onClick: () => publishToPackage(p, percentage),
383-
});
384-
}
385-
return acc;
386-
},
387-
[],
388-
),
376+
children: [1, 2, 5, 10, 20, 50].reduce<
377+
NonNullable<MenuProps['items']>
378+
>((acc, percentage) => {
379+
if (percentage > rolloutConfigNumber) {
380+
acc.push({
381+
key: `${percentage}`,
382+
label: `${percentage}%`,
383+
onClick: () => publishToPackage(p, percentage),
384+
});
385+
}
386+
return acc;
387+
}, []),
389388
});
390389
}
391390
if (items.length > 0) {

src/pages/manage/components/publish-feature-table.tsx

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Table, Tag } from "antd";
1+
import { Table, Tag } from 'antd';
22

33
/**
44
* 发布功能支持情况表格组件
@@ -12,25 +12,25 @@ export default function PublishFeatureTable() {
1212
pagination={false}
1313
dataSource={[
1414
{
15-
key: "1",
16-
version: "< v10.15.0",
17-
fullRelease: "✓ 支持",
18-
grayRelease: "✗ 不支持",
19-
bothRelease: "⚠ 灰度被忽略",
15+
key: '1',
16+
version: '< v10.15.0',
17+
fullRelease: '✓ 支持',
18+
grayRelease: '✗ 不支持',
19+
bothRelease: '⚠ 灰度被忽略',
2020
},
2121
{
22-
key: "2",
23-
version: "v10.15.0 - v10.31.3",
24-
fullRelease: "✓ 支持",
25-
grayRelease: "✓ 支持",
26-
bothRelease: "⚠ 灰度被忽略",
22+
key: '2',
23+
version: 'v10.15.0 - v10.31.3',
24+
fullRelease: '✓ 支持',
25+
grayRelease: '✓ 支持',
26+
bothRelease: '⚠ 灰度被忽略',
2727
},
2828
{
29-
key: "3",
30-
version: "≥ v10.32.0",
31-
fullRelease: "✓ 支持",
32-
grayRelease: "✓ 支持",
33-
bothRelease: "✓ 支持(cli >= 2.4.0)",
29+
key: '3',
30+
version: '≥ v10.32.0',
31+
fullRelease: '✓ 支持',
32+
grayRelease: '✓ 支持',
33+
bothRelease: '✓ 支持(cli >= 2.4.0)',
3434
},
3535
]}
3636
columns={[
@@ -42,47 +42,47 @@ export default function PublishFeatureTable() {
4242
(用户端)
4343
</span>
4444
),
45-
dataIndex: "version",
46-
key: "version",
45+
dataIndex: 'version',
46+
key: 'version',
4747
width: 200,
4848
},
4949
{
50-
title: "仅全量发布",
51-
dataIndex: "fullRelease",
52-
key: "fullRelease",
53-
align: "center",
50+
title: '仅全量发布',
51+
dataIndex: 'fullRelease',
52+
key: 'fullRelease',
53+
align: 'center',
5454
render: (text: string) => {
5555
return (
56-
<Tag color={text.includes("✓") ? "success" : "error"}>
56+
<Tag color={text.includes('✓') ? 'success' : 'error'}>
5757
{text}
5858
</Tag>
5959
);
6060
},
6161
},
6262
{
63-
title: "仅灰度发布",
64-
dataIndex: "grayRelease",
65-
key: "grayRelease",
66-
align: "center",
63+
title: '仅灰度发布',
64+
dataIndex: 'grayRelease',
65+
key: 'grayRelease',
66+
align: 'center',
6767
render: (text: string) => {
6868
return (
69-
<Tag color={text.includes("✓") ? "success" : "error"}>
69+
<Tag color={text.includes('✓') ? 'success' : 'error'}>
7070
{text}
7171
</Tag>
7272
);
7373
},
7474
},
7575
{
76-
title: "同时发布",
77-
dataIndex: "bothRelease",
78-
key: "bothRelease",
79-
align: "center",
76+
title: '同时发布',
77+
dataIndex: 'bothRelease',
78+
key: 'bothRelease',
79+
align: 'center',
8080
render: (text: string) => {
81-
const color = text.includes("✓")
82-
? "success"
83-
: text.includes("⚠")
84-
? "warning"
85-
: "error";
81+
const color = text.includes('✓')
82+
? 'success'
83+
: text.includes('⚠')
84+
? 'warning'
85+
: 'error';
8686
return <Tag color={color}>{text}</Tag>;
8787
},
8888
},

src/utils/helper.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import { expect, test, describe } from "bun:test";
2-
import { isExpVersion } from "./helper";
1+
import { describe, expect, test } from 'bun:test';
2+
import { isExpVersion } from './helper';
33

4-
describe("isExpVersion", () => {
5-
test("should return false when config is null", () => {
6-
expect(isExpVersion(null, "1.0.0")).toBe(false);
4+
describe('isExpVersion', () => {
5+
test('should return false when config is null', () => {
6+
expect(isExpVersion(null, '1.0.0')).toBe(false);
77
});
88

9-
test("should return false when config is undefined", () => {
10-
expect(isExpVersion(undefined, "1.0.0")).toBe(false);
9+
test('should return false when config is undefined', () => {
10+
expect(isExpVersion(undefined, '1.0.0')).toBe(false);
1111
});
1212

13-
test("should return false when config.rollout is missing", () => {
14-
// @ts-ignore
15-
expect(isExpVersion({}, "1.0.0")).toBe(false);
13+
test('should return false when config.rollout is missing', () => {
14+
// @ts-expect-error
15+
expect(isExpVersion({}, '1.0.0')).toBe(false);
1616
});
1717

18-
test("should return false when rollout config for version is missing", () => {
19-
expect(isExpVersion({ rollout: {} }, "1.0.0")).toBe(false);
18+
test('should return false when rollout config for version is missing', () => {
19+
expect(isExpVersion({ rollout: {} }, '1.0.0')).toBe(false);
2020
});
2121

22-
test("should return false when rollout config for version is null", () => {
23-
expect(isExpVersion({ rollout: { "1.0.0": null } }, "1.0.0")).toBe(false);
22+
test('should return false when rollout config for version is null', () => {
23+
expect(isExpVersion({ rollout: { '1.0.0': null } }, '1.0.0')).toBe(false);
2424
});
2525

26-
test("should return true when rollout is less than 100", () => {
27-
expect(isExpVersion({ rollout: { "1.0.0": 50 } }, "1.0.0")).toBe(true);
28-
expect(isExpVersion({ rollout: { "1.0.0": 0 } }, "1.0.0")).toBe(true);
26+
test('should return true when rollout is less than 100', () => {
27+
expect(isExpVersion({ rollout: { '1.0.0': 50 } }, '1.0.0')).toBe(true);
28+
expect(isExpVersion({ rollout: { '1.0.0': 0 } }, '1.0.0')).toBe(true);
2929
});
3030

31-
test("should return false when rollout is 100", () => {
32-
expect(isExpVersion({ rollout: { "1.0.0": 100 } }, "1.0.0")).toBe(false);
31+
test('should return false when rollout is 100', () => {
32+
expect(isExpVersion({ rollout: { '1.0.0': 100 } }, '1.0.0')).toBe(false);
3333
});
3434

35-
test("should return false when rollout is greater than 100", () => {
36-
expect(isExpVersion({ rollout: { "1.0.0": 110 } }, "1.0.0")).toBe(false);
35+
test('should return false when rollout is greater than 100', () => {
36+
expect(isExpVersion({ rollout: { '1.0.0': 110 } }, '1.0.0')).toBe(false);
3737
});
3838
});

0 commit comments

Comments
 (0)