Skip to content

Commit f0bea11

Browse files
author
昔梦
committed
feat:节点状态增加className,日志code面板增加全屏展示功能,日志面板透出width用户可配置
1 parent 96430c9 commit f0bea11

File tree

9 files changed

+76
-24
lines changed

9 files changed

+76
-24
lines changed

docs/xflow/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ title: API
6969
| logList | 日志面板数据 | [TLogListItem](#tloglistitem) | |
7070
| loading | 日志面板loading效果 | `boolean` | false |
7171
| logWidget | 自定义日志面板展示 | `string` | |
72+
| width | 日志面板宽度 | `number` | 400 |
73+
7274

7375
## TLogListItem
7476

docs/xflow/log.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ group:
3434
{value: 'warning',color: '#faad14',name: '告警'}
3535
]
3636
```
37-
- **自定义状态**:可通过`globalConfig.nodeView.status`自定义节点状态,同名可覆盖内置状态颜色。
37+
- **自定义状态**:可通过`globalConfig.nodeView.status`自定义节点状态,同名可覆盖内置状态颜色。注意:`value`只能为`string`类型!
3838
```js
3939
globalConfig={{
4040
nodeView: {

packages/x-flow/src/components/CustomNode/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export default memo((props: any) => {
247247
['xflow-node-container-selected']: !!selected,
248248
['xflow-node-container-tb']: layout === 'TB',
249249
['xflow-node-container-note']: isNote,
250+
[`xflow-node-container-status-${status}`]: status,
250251
})}
251252
onMouseEnter={() => setIsHovered(true)}
252253
onMouseLeave={() => setIsHovered(false)}

packages/x-flow/src/components/NodeLogPanel/components/CodePanel.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { CheckOutlined, CopyOutlined } from '@ant-design/icons';
1+
import {
2+
ArrowsAltOutlined,
3+
CheckOutlined,
4+
CopyOutlined,
5+
ShrinkOutlined,
6+
} from '@ant-design/icons';
27
import { json } from '@codemirror/lang-json';
38
import { EditorView } from '@codemirror/view';
49
import CodeMirror from '@uiw/react-codemirror';
10+
import classNames from 'classnames';
511
import { isString } from 'lodash';
612
import React, { memo, useState } from 'react';
713
import TextEllipsis from '../../TextEllipsis';
814

915
export default memo((props: any) => {
10-
const { codeData } = props;
16+
const { codeData, onFullScreenChange } = props;
1117
const [isCopy, setIsCopy] = useState(false);
1218
const isRenderTitle = isString(codeData?.title);
19+
const [isFullScreen, setIsFullScreen] = useState(false);
1320

1421
const copyCode = () => {
1522
navigator.clipboard
@@ -26,7 +33,7 @@ export default memo((props: any) => {
2633
};
2734

2835
return (
29-
<div className="log-code-panel">
36+
<div className={classNames('log-code-panel', { ['log-code-panel-full']: isFullScreen })}>
3037
<div className="log-code-title">
3138
{isRenderTitle ? (
3239
<TextEllipsis
@@ -36,18 +43,37 @@ export default memo((props: any) => {
3643
) : (
3744
<>{codeData?.title}</>
3845
)}
39-
{isCopy ? (
40-
<CheckOutlined className="log-code-copy" />
41-
) : (
42-
<CopyOutlined className="log-code-copy" onClick={copyCode} />
43-
)}
46+
<div>
47+
{isCopy ? (
48+
<CheckOutlined className="log-code-copy" />
49+
) : (
50+
<CopyOutlined className="log-code-copy" onClick={copyCode} />
51+
)}
52+
{isFullScreen ? (
53+
<ShrinkOutlined
54+
onClick={() => {
55+
setIsFullScreen(false);
56+
onFullScreenChange(false);
57+
}}
58+
className="log-code-copy"
59+
/>
60+
) : (
61+
<ArrowsAltOutlined
62+
onClick={() => {
63+
setIsFullScreen(true);
64+
onFullScreenChange(true);
65+
}}
66+
className="log-code-copy"
67+
/>
68+
)}
69+
</div>
4470
</div>
4571
<CodeMirror
4672
value={codeData?.code}
4773
className="log-code-editor"
4874
extensions={[json(), EditorView.lineWrapping]}
49-
height="172px"
5075
minHeight="172px"
76+
maxHeight="58vh"
5177
width="100%"
5278
theme="none"
5379
readOnly={true}

packages/x-flow/src/components/NodeLogPanel/components/DetailPanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import { isEmpty, isObject } from 'lodash-es';
2-
import React, { memo } from 'react';
2+
import React, { memo, useState } from 'react';
33
import CodePanel from './CodePanel';
44
import StatusPanel from './StatusPanel';
5+
import classNames from 'classnames';
56

67
export default memo((props: any) => {
78
const { detailData, currentStatus } = props;
89
const isRenderStatus =
910
isObject(detailData?.statusPanel) && !isEmpty(detailData?.statusPanel);
11+
const [isFullScreen, setIsFullScreen] = useState(false);
1012

1113
return (
12-
<div className="log-detail-panel">
14+
<div className={classNames("log-detail-panel", { ['log-detail-panel-code-full']: isFullScreen })}>
1315
{isRenderStatus && (
1416
<StatusPanel
1517
currentStatus={currentStatus}
1618
statusPanelData={detailData?.statusPanel}
1719
/>
1820
)}
1921
{(detailData?.codePanel || [])?.map((item, index) => (
20-
<CodePanel codeData={item} key={index} />
22+
<CodePanel codeData={item} key={index} onFullScreenChange={(isFullScreen) => {
23+
setIsFullScreen(isFullScreen)
24+
} } />
2125
))}
2226
</div>
2327
);

packages/x-flow/src/components/NodeLogPanel/index.less

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
.node-log-container {
22
.log-header-tab {
3-
43
.ant-tabs-nav,
54
.ant-tabs-content-holder {
65
padding-left: 16px;
76
padding-right: 16px;
87
}
8+
9+
.log-detail-panel-code-full {
10+
height: 0;
11+
}
912
}
1013

1114
.log-status-panel {
@@ -80,11 +83,12 @@
8083
.log-code-copy {
8184
cursor: pointer;
8285
font-size: 12px;
86+
margin-left: 8px;
8387
}
8488
}
8589

8690
.log-code-editor {
87-
height: 172px;
91+
min-height: 172px;
8892
border-radius: 6px;
8993

9094
.cm-focused {
@@ -94,12 +98,17 @@
9498
.cm-content {
9599
font-size: 12px;
96100
}
97-
98101
}
99102
}
100103

101-
.log-track-panel {
104+
.log-code-panel-full {
105+
position: absolute;
106+
z-index: 1000;
107+
top: 38px;
108+
margin-right: 16px;
109+
}
102110

111+
.log-track-panel {
103112
.log-track-node {
104113
margin-bottom: 10px;
105114

@@ -115,7 +124,7 @@
115124

116125
.ant-collapse-expand-icon {
117126
height: 20px;
118-
padding-inline-end: 6px
127+
padding-inline-end: 6px;
119128
}
120129

121130
.ant-collapse-arrow {

packages/x-flow/src/components/PanelContainer/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Divider, Drawer, Input, Space } from 'antd';
22
import produce from 'immer';
3-
import { debounce } from 'lodash';
3+
import { debounce, isNumber } from 'lodash';
44
import React, { FC, useContext, useEffect, useMemo, useState } from 'react';
55
import { shallow } from 'zustand/shallow';
66
import { useStore } from '../../hooks/useStore';
@@ -40,7 +40,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
4040
openLogPanel,
4141
} = props;
4242
// 1.获取节点配置信息
43-
const { settingMap, iconFontUrl, globalConfig, antdVersion, readOnly }: any =
43+
const { settingMap, iconFontUrl, globalConfig, antdVersion, readOnly, logPanel }: any =
4444
useContext(ConfigContext);
4545
const nodeSetting = settingMap[nodeType] || {};
4646
const { nodes, setNodes } = useStore(
@@ -57,6 +57,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
5757
const hideDesc =
5858
nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
5959
const isShowStatusPanel = Boolean(node?._status && openLogPanel);
60+
const offsetRightStatus = isNumber(logPanel?.width) ? Number(logPanel?.width + 10) : 410;
6061

6162
const handleNodeValueChange = debounce((data: any) => {
6263
const newNodes = produce(nodes, draft => {
@@ -108,7 +109,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
108109
headerStyle={{ paddingBottom: '12px' }}
109110
style={{
110111
position: 'absolute',
111-
right: isShowStatusPanel ? 410 : 0,
112+
right: isShowStatusPanel ? offsetRightStatus : 0,
112113
}}
113114
title={
114115
<>

packages/x-flow/src/components/PanelStatusLogContainer/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Drawer, Popover } from 'antd';
22
import classNames from 'classnames';
3+
import { isNumber } from 'lodash';
34
import React, { FC, useContext, useMemo } from 'react';
45
import { ConfigContext } from '../../models/context';
56
import createIconFont from '../../utils/createIconFont';
@@ -18,14 +19,21 @@ interface IPanelProps {
1819
const PanelStatusLogContainer: FC<IPanelProps> = (props: IPanelProps) => {
1920
const { onClose, children, nodeType } = props;
2021
// 1.获取节点配置信息
21-
const { settingMap, iconFontUrl, globalConfig, logPanel, widgets, antdVersion }: any =
22-
useContext(ConfigContext);
22+
const {
23+
settingMap,
24+
iconFontUrl,
25+
globalConfig,
26+
logPanel,
27+
widgets,
28+
antdVersion,
29+
}: any = useContext(ConfigContext);
2330
const nodeSetting = settingMap[nodeType] || {};
2431
const { nodePanel, iconSvg } = nodeSetting;
2532

2633
const Icon = useMemo(() => createIconFont(iconFontUrl), [iconFontUrl]);
2734
const CustomWidget = widgets[logPanel?.logWidget]; // 内置setting组件
2835
const isCustomWidget = !Boolean(logPanel?.logWidget && CustomWidget);
36+
const width =isNumber(logPanel?.width) ? logPanel?.width : 400;
2937

3038
const drawerVersionProps = useMemo(() => {
3139
if (antdVersion === 'V5') {
@@ -49,7 +57,7 @@ const PanelStatusLogContainer: FC<IPanelProps> = (props: IPanelProps) => {
4957
<Drawer
5058
{...drawerVersionProps}
5159
getContainer={false}
52-
width={400}
60+
width={width}
5361
mask={false}
5462
onClose={onClose}
5563
headerStyle={{

packages/x-flow/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export interface TLogPanel {
7878
logList: Array<TLogListItem>; // 日志面板的所有数据===》默认能拿到页面所有节点的日志数据
7979
loading?: boolean; // 日志面板loading
8080
logWidget?: string; // 自定义日志面板组件
81+
width?: number;// 日志面板宽度
8182
}
8283

8384
export interface TNodeView {

0 commit comments

Comments
 (0)