GeezerVison is showing github.com — fix: fix composeTitle returns redundant icons · Gpia/lowcode-engine@ed252fa
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test packages.yml +17-1Lines changed: 17 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 41 | 41 | run: npm i && npm run setup:skip-build | 42 | 42 |
| 43 | 43 | - 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 |
Collapse file Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +} |
Collapse file Copy file name to clipboard +29Lines changed: 29 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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; |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/package.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | "es" | 11 | 11 | ], | 12 | 12 | "scripts": { | | 13 | + "test": "build-scripts test --config build.test.json", | 13 | 14 | "build": "build-scripts build --skip-demo" | 14 | 15 | }, | 15 | 16 | "keywords": [ | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/widget/utils.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,7 +45,7 @@ export function composeTitle(title?: IPublicTypeTitleContent, icon?: IPublicType | 45 | 45 | } | 46 | 46 | } | 47 | 47 | if (isTitleConfig(_title) && noIcon) { | 48 | | - if (!isValidElement(title)) { | | 48 | + if (!isValidElement(_title)) { | 49 | 49 | _title.icon = undefined; | 50 | 50 | } | 51 | 51 | } | |
Collapse file Copy file name to clipboard +54Lines changed: 54 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +}) |
Collapse file Copy file name to clipboardExpand all lines: packages/types/src/shell/type/widget-base-config.ts +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,9 @@ export interface IPublicTypePanelDockConfig extends IPublicTypeWidgetBaseConfig | 23 | 23 | panelProps?: IPublicTypePanelDockPanelProps; | 24 | 24 |
| 25 | 25 | props?: IPublicTypePanelDockProps; | | 26 | + | | 27 | + /** 面板 name, 当没有 props.title 时, 会使用 name 作为标题 */ | | 28 | + name?: string; | 26 | 29 | } | 27 | 30 |
| 28 | 31 | export interface IPublicTypePanelDockProps { | @@ -32,12 +35,19 @@ export interface IPublicTypePanelDockProps { | 32 | 35 |
| 33 | 36 | className?: string; | 34 | 37 |
| | 38 | + /** 详细描述,hover 时在标题上方显示的 tips 内容 */ | 35 | 39 | description?: TipContent; | 36 | 40 |
| 37 | 41 | onClick?: () => void; | 38 | 42 |
| | 43 | + /** | | 44 | + * 面板标题前的 icon | | 45 | + */ | 39 | 46 | icon?: IPublicTypeIconType; | 40 | 47 |
| | 48 | + /** | | 49 | + * 面板标题 | | 50 | + */ | 41 | 51 | title?: IPublicTypeTitleContent; | 42 | 52 | } | 43 | 53 |
| |
|