Skip to content

Commit

Permalink
refactor(explore): Enhance Dataset and Control panel Collapse compone…
Browse files Browse the repository at this point in the history
…nts (#12218)
  • Loading branch information
geido authored Jan 25, 2021
1 parent 0fed1e0 commit 1b2611c
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Advanced analytics', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('.panel-title').contains('Advanced Analytics').click();
cy.get('.ant-collapse-header').contains('Advanced Analytics').click();

cy.get('[data-test=time_compare]').find('.Select__control').click();
cy.get('[data-test=time_compare]')
Expand All @@ -47,7 +47,7 @@ describe('Advanced analytics', () => {
chartSelector: 'svg',
});

cy.get('.panel-title').contains('Advanced Analytics').click();
cy.get('.ant-collapse-header').contains('Advanced Analytics').click();
cy.get('[data-test=time_compare]')
.find('.Select__multi-value__label')
.contains('28 days');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('VizType control', () => {
// should load mathjs for line chart
cy.get('script[src*="mathjs"]').should('have.length', 1);
cy.get('script').then(nodes => {
expect(nodes.length).to.greaterThan(numScripts);
expect(nodes.length).to.eq(numScripts);
});

cy.get('button[data-test="run-query-button"]').click();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getChartControlPanelRegistry, t } from '@superset-ui/core';
import { defaultControls } from 'src/explore/store';
import { getFormDataFromControls } from 'src/explore/controlUtils';
import { ControlPanelsContainer } from 'src/explore/components/ControlPanelsContainer';
import ControlPanelSection from 'src/explore/components/ControlPanelSection';
import Collapse from 'src/common/components/Collapse';

describe('ControlPanelsContainer', () => {
let wrapper;
Expand Down Expand Up @@ -91,6 +91,6 @@ describe('ControlPanelsContainer', () => {

it('renders ControlPanelSections', () => {
wrapper = shallow(<ControlPanelsContainer {...getDefaultProps()} />);
expect(wrapper.find(ControlPanelSection)).toHaveLength(5);
expect(wrapper.find(Collapse.Panel)).toHaveLength(5);
});
});
36 changes: 35 additions & 1 deletion superset-frontend/src/common/components/Collapse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ interface CollapseProps extends AntdCollapseProps {
light?: boolean;
bigger?: boolean;
bold?: boolean;
animateArrows?: boolean;
}

const Collapse = Object.assign(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
styled(({ light, bigger, bold, ...props }: CollapseProps) => (
styled(({ light, bigger, bold, animateArrows, ...props }: CollapseProps) => (
<AntdCollapse {...props} />
))`
height: 100%;
Expand All @@ -48,6 +49,20 @@ const Collapse = Object.assign(
font-size: ${({ bigger, theme }) =>
bigger ? `${theme.gridUnit * 4}px` : 'inherit'};
.ant-collapse-arrow svg {
transition: ${({ animateArrows }) =>
animateArrows ? 'transform 0.24s' : 'none'};
}
${({ expandIconPosition }) =>
expandIconPosition &&
expandIconPosition === 'right' &&
`
.anticon.anticon-right.ant-collapse-arrow > svg {
transform: rotate(90deg) !important;
}
`}
${({ light, theme }) =>
light &&
`
Expand All @@ -56,6 +71,13 @@ const Collapse = Object.assign(
color: ${theme.colors.grayscale.light4};
}
`}
${({ ghost, bordered, theme }) =>
ghost &&
bordered &&
`
border-bottom: 1px solid ${theme.colors.grayscale.light3};
`}
}
.ant-collapse-content {
height: 100%;
Expand All @@ -68,6 +90,18 @@ const Collapse = Object.assign(
}
}
}
.ant-collapse-item-active {
.ant-collapse-header {
${({ expandIconPosition }) =>
expandIconPosition &&
expandIconPosition === 'right' &&
`
.anticon.anticon-right.ant-collapse-arrow > svg {
transform: rotate(-90deg) !important;
}
`}
}
}
`,
{
Panel: AntdCollapse.Panel,
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/common/components/common.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ export const CollapseTextLight = () => (
</Collapse.Panel>
</Collapse>
);
export const CollapseAnimateArrows = () => (
<Collapse animateArrows defaultActiveKey={['1']}>
<Collapse.Panel header="Hi! I am a header" key="1">
Hi! I am a sample content
</Collapse.Panel>
<Collapse.Panel header="Hi! I am another header" key="2">
Hi! I am another sample content
</Collapse.Panel>
</Collapse>
);
export function StyledCronPicker() {
// @ts-ignore
const inputRef = useRef<Input>(null);
Expand Down
117 changes: 0 additions & 117 deletions superset-frontend/src/explore/components/ControlPanelSection.jsx

This file was deleted.

Loading

0 comments on commit 1b2611c

Please sign in to comment.