Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tabs in column #16593

Merged
merged 24 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6eb04b1
fix:fix get permission function
simcha90 Apr 13, 2021
5e9a1d8
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 18, 2021
2c5800a
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 20, 2021
ea9aa8b
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 25, 2021
402918a
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 27, 2021
1a3cc39
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 28, 2021
f6d4590
Merge branch 'master' of github.com:apache/superset
simcha90 May 10, 2021
97f2c15
Merge branch 'master' of github.com:apache/superset
simcha90 May 24, 2021
1f31df7
Merge branch 'master' of github.com:apache/superset
simcha90 May 24, 2021
dce7b7a
Merge branch 'master' of github.com:apache/superset
simcha90 May 26, 2021
0334f35
Merge branch 'master' of github.com:apache/superset
simcha90 May 30, 2021
f6dd314
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 17, 2021
64267e1
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 20, 2021
385eddc
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 24, 2021
51a00a3
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 1, 2021
4e94cb5
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 4, 2021
e7fa0a6
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 7, 2021
c3d24d7
Merge branch 'master' of github.com:apache/superset
simcha90 Aug 31, 2021
f36add0
feat: add tabs inside column
simcha90 Sep 4, 2021
e8d870c
lint: fix lint
simcha90 Sep 5, 2021
a6fca50
test: fix test
simcha90 Sep 5, 2021
b2d3a1a
test: fix tests
simcha90 Sep 5, 2021
bd06c98
test: fix tests
simcha90 Sep 5, 2021
3956885
fix: pass onChangeTab function through layout
simcha90 Sep 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('isValidChild', () => {
[ROOT, TABS, TAB, ROW, COLUMN, ROW, COLUMN, CHART],
[ROOT, TABS, TAB, ROW, COLUMN, ROW, COLUMN, MARKDOWN],
[ROOT, TABS, TAB, TABS, TAB, ROW, COLUMN, ROW, COLUMN, MARKDOWN],
[ROOT, GRID, ROW, COLUMN, TABS],
];

validExamples.forEach((example, exampleIdx) => {
Expand Down Expand Up @@ -127,7 +128,6 @@ describe('isValidChild', () => {
[ROOT, GRID, ROW, [TABS]],
[ROOT, GRID, ROW, [TAB]],
[ROOT, GRID, ROW, [DIVIDER]],
[ROOT, GRID, ROW, COLUMN, [TABS]],
[ROOT, GRID, ROW, COLUMN, [TAB]],
[ROOT, GRID, ROW, COLUMN, ROW, [DIVIDER]],
[ROOT, GRID, ROW, COLUMN, ROW, COLUMN, [ROW]], // too nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const propTypes = {
dashboardId: PropTypes.number.isRequired,
component: componentShape.isRequired,
parentComponent: componentShape.isRequired,
getComponentById: PropTypes.func.isRequired,
index: PropTypes.number.isRequired,
depth: PropTypes.number.isRequired,
editMode: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -268,16 +269,22 @@ class ChartHolder extends React.Component {
isComponentVisible,
dashboardId,
fullSizeChartId,
getComponentById = () => undefined,
} = this.props;

const { chartId } = component.meta;
const isFullSize = fullSizeChartId === chartId;

// inherit the size of parent columns
const widthMultiple =
parentComponent.type === COLUMN_TYPE
? parentComponent.meta.width || GRID_MIN_COLUMN_COUNT
: component.meta.width || GRID_MIN_COLUMN_COUNT;
const columnParentWidth = getComponentById(
parentComponent.parents?.find(parent => parent.startsWith(COLUMN_TYPE)),
)?.meta?.width;
let widthMultiple = component.meta.width || GRID_MIN_COLUMN_COUNT;
if (parentComponent.type === COLUMN_TYPE) {
widthMultiple = parentComponent.meta.width || GRID_MIN_COLUMN_COUNT;
} else if (columnParentWidth && widthMultiple > columnParentWidth) {
widthMultiple = columnParentWidth;
}

let chartWidth = 0;
let chartHeight = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Column extends React.PureComponent {
onResizeStop,
handleComponentDrop,
editMode,
onChangeTab,
isComponentVisible,
} = this.props;

Expand Down Expand Up @@ -191,6 +192,7 @@ class Column extends React.PureComponent {
onResize={onResize}
onResizeStop={onResizeStop}
isComponentVisible={isComponentVisible}
onChangeTab={onChangeTab}
/>
))}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Row extends React.PureComponent {
onResizeStop,
handleComponentDrop,
editMode,
onChangeTab,
isComponentVisible,
} = this.props;

Expand Down Expand Up @@ -176,6 +177,7 @@ class Row extends React.PureComponent {
onResize={onResize}
onResizeStop={onResizeStop}
isComponentVisible={isComponentVisible}
onChangeTab={onChangeTab}
/>
))}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function mapStateToProps(
const component = dashboardLayout[id];
const props = {
component,
getComponentById: id => dashboardLayout[id],
parentComponent: dashboardLayout[parentId],
editMode: dashboardState.editMode,
filters: getActiveFilters(),
Expand Down
19 changes: 10 additions & 9 deletions superset-frontend/src/dashboard/util/isValidChild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
import { DASHBOARD_ROOT_DEPTH as rootDepth } from './constants';

const depthOne = rootDepth + 1;
const depthTwo = rootDepth + 2;
// const depthTwo = rootDepth + 2; // Meantime no need
const depthThree = rootDepth + 3;
const depthFour = rootDepth + 4;
const depthFive = rootDepth + 5;
Expand Down Expand Up @@ -77,17 +77,17 @@ const parentMaxDepthLookup = {
},

[TABS_TYPE]: {
[TAB_TYPE]: depthTwo,
[TAB_TYPE]: depthThree,
},

[TAB_TYPE]: {
[CHART_TYPE]: depthTwo,
[MARKDOWN_TYPE]: depthTwo,
[COLUMN_TYPE]: depthTwo,
[DIVIDER_TYPE]: depthTwo,
[HEADER_TYPE]: depthTwo,
[ROW_TYPE]: depthTwo,
[TABS_TYPE]: depthTwo,
[CHART_TYPE]: depthFive,
[MARKDOWN_TYPE]: depthFive,
[COLUMN_TYPE]: depthThree,
[DIVIDER_TYPE]: depthFive,
[HEADER_TYPE]: depthFive,
[ROW_TYPE]: depthThree,
[TABS_TYPE]: depthThree,
},

[COLUMN_TYPE]: {
Expand All @@ -96,6 +96,7 @@ const parentMaxDepthLookup = {
[MARKDOWN_TYPE]: depthFive,
[ROW_TYPE]: depthThree,
[DIVIDER_TYPE]: depthThree,
[TABS_TYPE]: depthThree,
},

// these have no valid children
Expand Down