Skip to content

Commit 6a87aef

Browse files
authored
Merge pull request #1218 from merico-dev/1217-able-to-set-panel-titles-visibility
1217 able to set panel titles visibility
2 parents e3bb64e + 9cff6bc commit 6a87aef

File tree

36 files changed

+221
-193
lines changed

36 files changed

+221
-193
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/api",
3-
"version": "10.40.0",
3+
"version": "10.41.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function upgradePanels(panels: Record<string, any>[]) {
2+
return panels.map((p) => {
3+
const { title, ...rest } = p;
4+
if (typeof title !== 'string') {
5+
console.log(p);
6+
throw new Error(`Unexpected type of panel.title: ${typeof title}`);
7+
}
8+
const name = title ? title : p.id;
9+
return {
10+
...rest,
11+
name,
12+
title: {
13+
show: !!title,
14+
},
15+
};
16+
});
17+
}
18+
19+
/**
20+
* https://github.com/merico-dev/table/issues/1217
21+
*/
22+
export function main({ panels, ...rest }: Record<string, any>) {
23+
const finalPanels = upgradePanels(panels);
24+
return {
25+
...rest,
26+
panels: finalPanels,
27+
version: '10.41.0',
28+
};
29+
}

api/src/dashboard_migration/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const versions = [
2424
'8.57.0',
2525
'9.11.0',
2626
'9.19.0',
27+
'10.41.0',
2728
// ... future versions
2829
];
2930

dashboard/cypress/component/viz-table.cy.tsx

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { get, set } from 'lodash';
1+
import { set } from 'lodash';
22
import {
33
IViewPanelInfo,
44
IVizManager,
5-
pluginManager,
65
VizConfigComponent,
76
VizManager,
87
VizViewComponent,
8+
pluginManager,
99
} from '~/components/plugins';
10-
import { PanelContextProvider } from '~/contexts';
1110
import { ITableConf, ValueType } from '~/components/plugins/viz-components/table/type';
12-
import { IPanelInfoEditor } from '~/types/plugin';
11+
import { PanelContextProvider } from '~/contexts';
1312

1413
const mockQueryID = 'queryID-01';
1514
const defaultConfig = {
@@ -84,42 +83,18 @@ describe('viz-table.cy.ts', () => {
8483
});
8584
describe('config panel', () => {
8685
it('render config panel', () => {
87-
const panelEditor: IPanelInfoEditor = {
88-
setDescription: cy.spy(),
89-
addQueryID: cy.spy(),
90-
removeQueryID: cy.spy(),
91-
setTitle: cy.spy(),
92-
};
9386
cy.mount(
9487
<PanelContextProvider value={{ panel: mockPanel, data: mockData, loading: false, errors: [] }}>
95-
<VizConfigComponent
96-
panel={mockPanel}
97-
data={mockData}
98-
vizManager={vizManager}
99-
variables={[]}
100-
panelInfoEditor={panelEditor}
101-
/>
88+
<VizConfigComponent panel={mockPanel} data={mockData} vizManager={vizManager} variables={[]} />
10289
</PanelContextProvider>,
10390
);
10491
cy.findByText('Table Config');
10592
});
10693
it('update config', () => {
107-
const panelEditor: IPanelInfoEditor = {
108-
setDescription: cy.spy(),
109-
addQueryID: cy.spy(),
110-
removeQueryID: cy.spy(),
111-
setTitle: cy.spy(),
112-
};
11394
const instance = vizManager.getOrCreateInstance(mockPanel);
11495
cy.mount(
11596
<PanelContextProvider value={{ panel: mockPanel, data: mockData, loading: false, errors: [] }}>
116-
<VizConfigComponent
117-
panel={mockPanel}
118-
data={mockData}
119-
vizManager={vizManager}
120-
variables={[]}
121-
panelInfoEditor={panelEditor}
122-
/>
97+
<VizConfigComponent panel={mockPanel} data={mockData} vizManager={vizManager} variables={[]} />
12398
</PanelContextProvider>,
12499
);
125100
cy.findByLabelText('Use Original Data Columns').click({ force: true });

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/dashboard",
3-
"version": "10.40.0",
3+
"version": "10.41.0",
44
"license": "Apache-2.0",
55
"publishConfig": {
66
"access": "public",

dashboard/src/components/panel/panel-render/description-popover/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const DescriptionPopover = observer(() => {
2424
<Modal
2525
opened={opened}
2626
onClose={() => setOpened(false)}
27-
title={panel.title}
27+
title={panel.name}
2828
withCloseButton={false}
2929
withinPortal
3030
zIndex={310}

dashboard/src/components/panel/panel-render/panel-render-base.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ const baseStyle: Sx = { border: '1px solid #e9ecef' };
1919

2020
export const PanelRenderBase = observer(({ panel, panelStyle, dropdownContent }: IPanelBase) => {
2121
const { ref, downloadPanelScreenshot } = useDownloadPanelScreenshot(panel);
22-
const showTitle = !!panel.title;
23-
const titleHeight = showTitle ? '60px' : '28px';
24-
const contentHeight = !panel.title ? '100%' : `calc(100% - ${titleHeight})`;
22+
const titleHeight = panel.title.show ? '60px' : '28px';
2523
return (
2624
<PanelContextProvider
2725
value={{
@@ -33,7 +31,7 @@ export const PanelRenderBase = observer(({ panel, panelStyle, dropdownContent }:
3331
}}
3432
>
3533
<Box
36-
className={`panel-root ${showTitle ? 'panel-root--show-title' : ''}`}
34+
className={`panel-root ${panel.title.show ? 'panel-root--show-title' : ''}`}
3735
ref={ref}
3836
p={0}
3937
sx={{

dashboard/src/components/panel/panel-render/title-bar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { useRenderPanelContext } from '~/contexts';
44

55
export const PanelTitleBar = observer(function _PanelTitleBar() {
66
const { panel } = useRenderPanelContext();
7-
const { title } = panel;
7+
const { name, title } = panel;
88

9-
if (!title) {
9+
if (!title.show) {
1010
return null;
1111
}
1212
return (
1313
<Group grow position="center" className="panel-title-wrapper" sx={{ flexGrow: 1 }}>
1414
<Text align="center" lineClamp={1} className="panel-title-text">
15-
{title}
15+
{name}
1616
</Text>
1717
</Group>
1818
);

dashboard/src/components/panel/panel-render/viz/viz.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import { Box } from '@mantine/core';
1515
function usePluginViz(data: TPanelData, layout: IViewPanelInfo['layout']): ReactNode | null {
1616
const { vizManager } = useContext(PluginContext);
1717
const {
18-
panel: { viz, title, id, description, queryIDs, variables },
18+
panel: { viz, title, id, name, description, queryIDs, variables },
1919
} = useRenderPanelContext();
2020
const panel: IViewPanelInfo = {
21-
title,
2221
id,
22+
name,
23+
title,
2324
description,
2425
queryIDs,
2526
viz,

dashboard/src/components/panel/plugin-adaptor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function PluginVizConfigComponent({ setVizConf, ...props }: IConfigCompon
6161

6262
const migrated = usePluginMigration(() => {
6363
showNotification({
64-
title: `${panel.title} - Updated`,
64+
title: `${panel.name} - Updated`,
6565
message: 'Your plugin configuration has been migrated to the latest version',
6666
});
6767
});
@@ -87,7 +87,7 @@ export function PluginVizViewComponent(props: IViewComponentProps & SetVizConfTy
8787
}
8888

8989
showNotification({
90-
title: `${panel.title} - Updated`,
90+
title: `${panel.name} - Updated`,
9191
message: 'Your plugin configuration has been migrated to the latest version',
9292
});
9393
});

0 commit comments

Comments
 (0)