Skip to content

Commit ed252fa

Browse files
liujupingJackLian
authored andcommitted
fix: fix composeTitle returns redundant icons
1 parent e1864fd commit ed252fa

File tree

7 files changed

+121
-2
lines changed

7 files changed

+121
-2
lines changed

.github/workflows/test packages.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,20 @@ jobs:
4141
run: npm i && npm run setup:skip-build
4242

4343
- name: test
44-
run: cd packages/designer && npm test
44+
run: cd packages/designer && npm test
45+
46+
editor-skeleton:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: checkout
50+
uses: actions/checkout@v2
51+
52+
- uses: actions/setup-node@v2
53+
with:
54+
node-version: '14'
55+
56+
- name: install
57+
run: npm i && npm run setup:skip-build
58+
59+
- name: test
60+
run: cd packages/editor-skeleton && npm test
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": [
3+
"build-plugin-component",
4+
"@alilc/lowcode-test-mate/plugin/index.ts"
5+
],
6+
"babelPlugins": [
7+
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
8+
]
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require('fs');
2+
const { join } = require('path');
3+
const esModules = [].join('|');
4+
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
5+
6+
const jestConfig = {
7+
// transform: {
8+
// '^.+\\.[jt]sx?$': 'babel-jest',
9+
// // '^.+\\.(ts|tsx)$': 'ts-jest',
10+
// // '^.+\\.(js|jsx)$': 'babel-jest',
11+
// },
12+
transformIgnorePatterns: [
13+
`/node_modules/(?!${esModules})/`,
14+
],
15+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
16+
collectCoverage: false,
17+
collectCoverageFrom: [
18+
'src/**/*.ts',
19+
'!src/**/*.d.ts',
20+
'!**/node_modules/**',
21+
'!**/vendor/**',
22+
],
23+
};
24+
25+
// 只对本仓库内的 pkg 做 mapping
26+
jestConfig.moduleNameMapper = {};
27+
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
28+
29+
module.exports = jestConfig;

packages/editor-skeleton/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"es"
1111
],
1212
"scripts": {
13+
"test": "build-scripts test --config build.test.json",
1314
"build": "build-scripts build --skip-demo"
1415
},
1516
"keywords": [

packages/editor-skeleton/src/widget/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function composeTitle(title?: IPublicTypeTitleContent, icon?: IPublicType
4545
}
4646
}
4747
if (isTitleConfig(_title) && noIcon) {
48-
if (!isValidElement(title)) {
48+
if (!isValidElement(_title)) {
4949
_title.icon = undefined;
5050
}
5151
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { composeTitle } from '../../src/widget/utils';
2+
import * as React from 'react';
3+
4+
const label = React.createElement('div');
5+
6+
describe('composeTitle 测试', () => {
7+
it('基础能力测试', () => {
8+
expect(composeTitle(undefined)).toEqual({
9+
label: undefined,
10+
});
11+
12+
expect(composeTitle(undefined, undefined, 'tips', true, true)).toEqual({
13+
icon: undefined,
14+
label: 'tips',
15+
});
16+
17+
expect(composeTitle(undefined, undefined, label, true, true)).toEqual({
18+
icon: undefined,
19+
label,
20+
});
21+
22+
expect(composeTitle({
23+
icon: undefined,
24+
label,
25+
}, undefined, '')).toEqual({
26+
icon: undefined,
27+
label,
28+
});
29+
30+
expect(composeTitle('settingsPane')).toEqual('settingsPane');
31+
32+
expect(composeTitle(label, undefined, '物料面板', true, true)).toEqual({
33+
icon: undefined,
34+
label,
35+
tip: '物料面板',
36+
});
37+
38+
expect(composeTitle(label, undefined, label, true, true)).toEqual({
39+
icon: undefined,
40+
label,
41+
tip: label,
42+
});
43+
44+
expect(composeTitle({
45+
label: "物料面板",
46+
icon: undefined,
47+
tip: null,
48+
})).toEqual({
49+
label: "物料面板",
50+
icon: undefined,
51+
tip: null,
52+
})
53+
});
54+
})

packages/types/src/shell/type/widget-base-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export interface IPublicTypePanelDockConfig extends IPublicTypeWidgetBaseConfig
2323
panelProps?: IPublicTypePanelDockPanelProps;
2424

2525
props?: IPublicTypePanelDockProps;
26+
27+
/** 面板 name, 当没有 props.title 时, 会使用 name 作为标题 */
28+
name?: string;
2629
}
2730

2831
export interface IPublicTypePanelDockProps {
@@ -32,12 +35,19 @@ export interface IPublicTypePanelDockProps {
3235

3336
className?: string;
3437

38+
/** 详细描述,hover 时在标题上方显示的 tips 内容 */
3539
description?: TipContent;
3640

3741
onClick?: () => void;
3842

43+
/**
44+
* 面板标题前的 icon
45+
*/
3946
icon?: IPublicTypeIconType;
4047

48+
/**
49+
* 面板标题
50+
*/
4151
title?: IPublicTypeTitleContent;
4252
}
4353

0 commit comments

Comments
 (0)