Skip to content

Commit

Permalink
Widget table scroll-x visible (getredash#4101)
Browse files Browse the repository at this point in the history
* Table viz horizontal scroll made visible

* Added tests

* Fixed snapshot pre-condition

* Perhaps this would trigger percy
  • Loading branch information
ranbena authored and harveyrendell committed Nov 14, 2019
1 parent c8bfed0 commit 7eaeb31
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 16 deletions.
17 changes: 17 additions & 0 deletions client/app/assets/less/inc/misc.less
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,21 @@
.hide-in-percy, .pace {
visibility: hidden;
}

[data-percy="show-scrollbars"] {
overflow: scroll;

&::-webkit-scrollbar {
width: 10px;
height: 10px;
}

&::-webkit-scrollbar-track {
background: green;
}

&::-webkit-scrollbar-thumb {
background: red;
}
}
}
7 changes: 0 additions & 7 deletions client/app/assets/less/redash/query.less
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,6 @@ edit-in-place p.editable:hover {
}
}

.visualization-renderer {
.pagination,
.ant-pagination {
margin-top: 10px;
}
}

.embed__vis {
display: flex;
flex-flow: column;
Expand Down
15 changes: 7 additions & 8 deletions client/app/visualizations/VisualizationRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ export function VisualizationRenderer(props) {
return (
<React.Fragment>
{showFilters && <Filters filters={filters} onChange={setFilters} />}
<div>
<Renderer
key={`visualization${visualization.id}`}
options={options}
data={filteredData}
visualizationName={visualization.name}
/>
</div>
<Renderer
key={`visualization${visualization.id}`}
options={options}
data={filteredData}
visualizationName={visualization.name}
context={props.context}
/>
</React.Fragment>
);
}
Expand Down
1 change: 1 addition & 0 deletions client/app/visualizations/table/Renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function Renderer({ options, data }) {
return (
<div className="table-visualization-container">
<Table
data-percy="show-scrollbars"
data-test="TableVisualization"
columns={tableColumns}
dataSource={preparedRows}
Expand Down
21 changes: 20 additions & 1 deletion client/app/visualizations/table/renderer.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
margin-bottom: 0;
}

.ant-table-body {
.ant-table {
overflow-x: auto;
}

Expand Down Expand Up @@ -100,4 +100,23 @@
}
}
}

/* START table x scroll */
.dashboard-widget-wrapper:not(.widget-auto-height-enabled) & {
height: 100%;

& div {
height: inherit;
}

.ant-spin-container {
display: flex;
flex-direction: column;

.ant-table {
flex-grow: 1;
}
}
}
/* END */
}
28 changes: 28 additions & 0 deletions client/cypress/integration/dashboard/widget_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,32 @@ describe('Widget', () => {
});
});
});

it('shows horizontal scrollbar for overflowing tabular content', function () {
const queryData = {
query: `select '${'loremipsum'.repeat(15)}' FROM generate_series(1,15)`,
};

const widgetOptions = { position: { col: 0, row: 0, sizeX: 3, sizeY: 10, autoHeight: false } };

createQueryAndAddWidget(this.dashboardId, queryData, widgetOptions).then(() => {
cy.visit(this.dashboardUrl);
cy.getByTestId('TableVisualization').should('exist');
cy.percySnapshot('Shows horizontal scrollbar for overflowing tabular content');
});
});

it('shows fixed pagination for overflowing tabular content ', function () {
const queryData = {
query: 'select \'lorem ipsum\' FROM generate_series(1,50)',
};

const widgetOptions = { position: { col: 0, row: 0, sizeX: 3, sizeY: 10, autoHeight: false } };

createQueryAndAddWidget(this.dashboardId, queryData, widgetOptions).then(() => {
cy.visit(this.dashboardUrl);
cy.getByTestId('TableVisualization').should('exist');
cy.percySnapshot('Shows fixed pagination for overflowing tabular content');
});
});
});

0 comments on commit 7eaeb31

Please sign in to comment.