Skip to content

Commit deb118a

Browse files
πŸ’₯ feat: add pro-descriptions demos (#7200)
* πŸ’₯ feat: add pro-descriptions demos * add version * better yaml
1 parent 963d2af commit deb118a

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

β€Ž.github/workflows/deploy.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: Deploy CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- master
47

58
jobs:
69
build-and-deploy:
710
runs-on: ubuntu-latest
8-
if: github.ref == 'refs/heads/master'
911
steps:
1012
- name: Checkout
1113
uses: actions/checkout@master

β€Žpackage.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "ant-design-pro",
3-
"version": "4.2.0",
3+
"version": "4.2.1",
44
"private": true,
55
"description": "An out-of-box UI solution for enterprise applications",
66
"scripts": {
7-
"postinstall": "umi g tmp",
87
"analyze": "cross-env ANALYZE=1 umi build",
98
"build": "umi build",
109
"deploy": "npm run site && npm run gh-pages",
10+
"dev": "npm run start:dev",
1111
"docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./",
1212
"docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build",
1313
"docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
@@ -18,17 +18,17 @@
1818
"fetch:blocks": "pro fetch-blocks && npm run prettier",
1919
"gh-pages": "gh-pages -d dist",
2020
"i18n-remove": "pro i18n-remove --locale=zh-CN --write",
21+
"postinstall": "umi g tmp",
2122
"lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier",
22-
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
23-
"precommit": "lint-staged",
2423
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
2524
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
2625
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
26+
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
2727
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
28+
"precommit": "lint-staged",
2829
"prettier": "prettier -c --write \"**/*\"",
2930
"site": "npm run fetch:blocks && npm run build",
3031
"start": "umi dev",
31-
"dev": "npm run start:dev",
3232
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none umi dev",
3333
"start:no-mock": "cross-env MOCK=none umi dev",
3434
"start:no-ui": "cross-env UMI_UI=none umi dev",
@@ -38,7 +38,7 @@
3838
"test": "umi test",
3939
"test:all": "node ./tests/run-tests.js",
4040
"test:component": "umi test ./src/components",
41-
"tsc": "tsc"
41+
"tsc": "tsc --noEmit"
4242
},
4343
"lint-staged": {
4444
"**/*.less": "stylelint --syntax less",
@@ -54,6 +54,7 @@
5454
],
5555
"dependencies": {
5656
"@ant-design/icons": "^4.0.0",
57+
"@ant-design/pro-descriptions": "^1.0.4",
5758
"@ant-design/pro-layout": "^6.4.1",
5859
"@ant-design/pro-table": "^2.5.3",
5960
"antd": "^4.5.3",
@@ -102,7 +103,8 @@
102103
"prettier": "^2.0.1",
103104
"pro-download": "1.0.1",
104105
"puppeteer-core": "^5.0.0",
105-
"stylelint": "^13.0.0"
106+
"stylelint": "^13.0.0",
107+
"typescript": "^3.9.7"
106108
},
107109
"engines": {
108110
"node": ">=10.0.0"

β€Žsrc/pages/ListTableList/index.tsx

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { PlusOutlined } from '@ant-design/icons';
2-
import { Button, Divider, message, Input } from 'antd';
2+
import { Button, Divider, message, Input, Drawer } from 'antd';
33
import React, { useState, useRef } from 'react';
44
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
55
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
6-
6+
import ProDescriptions from '@ant-design/pro-descriptions';
77
import CreateForm from './components/CreateForm';
88
import UpdateForm, { FormValueType } from './components/UpdateForm';
99
import { TableListItem } from './data.d';
@@ -76,6 +76,7 @@ const TableList: React.FC<{}> = () => {
7676
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
7777
const [stepFormValues, setStepFormValues] = useState({});
7878
const actionRef = useRef<ActionType>();
79+
const [row, setRow] = useState<TableListItem>();
7980
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
8081
const columns: ProColumns<TableListItem>[] = [
8182
{
@@ -88,6 +89,9 @@ const TableList: React.FC<{}> = () => {
8889
message: 'θ§„εˆ™εη§°δΈΊεΏ…ε‘«ι‘Ή',
8990
},
9091
],
92+
render: (dom, entity) => {
93+
return <a onClick={() => setRow(entity)}>{dom}</a>;
94+
},
9195
},
9296
{
9397
title: '描述',
@@ -182,7 +186,7 @@ const TableList: React.FC<{}> = () => {
182186
onClick={async () => {
183187
await handleRemove(selectedRowsState);
184188
setSelectedRows([]);
185-
actionRef.current?.reloadAndRest();
189+
actionRef.current?.reloadAndRest?.();
186190
}}
187191
>
188192
ζ‰Ήι‡εˆ ι™€
@@ -204,7 +208,6 @@ const TableList: React.FC<{}> = () => {
204208
rowKey="key"
205209
type="form"
206210
columns={columns}
207-
rowSelection={{}}
208211
/>
209212
</CreateForm>
210213
{stepFormValues && Object.keys(stepFormValues).length ? (
@@ -227,6 +230,29 @@ const TableList: React.FC<{}> = () => {
227230
values={stepFormValues}
228231
/>
229232
) : null}
233+
234+
<Drawer
235+
width={600}
236+
visible={!!row}
237+
onClose={() => {
238+
setRow(undefined);
239+
}}
240+
closable={false}
241+
>
242+
{row?.name && (
243+
<ProDescriptions<TableListItem>
244+
column={2}
245+
title={row?.name}
246+
request={async () => ({
247+
data: row || {},
248+
})}
249+
params={{
250+
id: row?.name,
251+
}}
252+
columns={columns}
253+
/>
254+
)}
255+
</Drawer>
230256
</PageContainer>
231257
);
232258
};

0 commit comments

Comments
Β (0)