Skip to content

Commit

Permalink
Decrease size of widget pagination (#4120)
Browse files Browse the repository at this point in the history
* Added tests

* Perhaps this would trigger percy

* Decrease size of widget pagination

* Removed unused attr

* Updated tests
  • Loading branch information
ranbena authored and arikfr committed Oct 27, 2019
1 parent 4a74263 commit c74ece4
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 26 deletions.
4 changes: 4 additions & 0 deletions client/app/assets/less/ant.less
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
border-color: transparent;
color: @pagination-color;
line-height: @pagination-item-size - 2px;

.@{pagination-prefix-cls}.mini & {
line-height: @pagination-item-size-sm - 2px;
}
}

&:focus .@{pagination-prefix-cls}-item-link,
Expand Down
17 changes: 0 additions & 17 deletions client/app/assets/less/inc/misc.less
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,4 @@
.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;
}
}
}
2 changes: 1 addition & 1 deletion client/app/components/dashboards/widget-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
</div>
<div class="modal-body">
<visualization-renderer visualization="$ctrl.widget.visualization" query-result="$ctrl.widget.getQueryResult()" class="t-body"></visualization-renderer>
<visualization-renderer visualization="$ctrl.widget.visualization" query-result="$ctrl.widget.getQueryResult()" class="t-body" context="'widget'"></visualization-renderer>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="$ctrl.dismiss()">Close</button>
Expand Down
1 change: 1 addition & 0 deletions client/app/components/dashboards/widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
visualization="$ctrl.widget.visualization"
query-result="$ctrl.widget.getQueryResult()"
filters="$ctrl.filters"
context="'widget'"
></visualization-renderer>
</div>
<div ng-switch-default class="body-row-auto spinner-container">
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/queries/visualization-embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3>
<div class="alert alert-danger" data-test="ErrorMessage">Error: {{$ctrl.error}}</div>
</div>

<visualization-renderer visualization="$ctrl.visualization" query-result="$ctrl.queryResult" class="t-body" ng-if="$ctrl.queryResult">
<visualization-renderer visualization="$ctrl.visualization" query-result="$ctrl.queryResult" class="t-body" ng-if="$ctrl.queryResult" context="'widget'">
</visualization-renderer>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h3>
</li>
</ul>
<div ng-if="selectedVisualization && queryResult" class="query__vis m-t-15 p-b-15 scrollbox" data-test="QueryPageVisualization{{ selectedVisualization.id }}">
<visualization-renderer visualization="selectedVisualization" query-result="queryResult"></visualization-renderer>
<visualization-renderer visualization="selectedVisualization" query-result="queryResult" context="'query'"></visualization-renderer>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/app/visualizations/VisualizationRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ VisualizationRenderer.propTypes = {
queryResult: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
filters: FiltersType,
showFilters: PropTypes.bool,
context: PropTypes.oneOf(['query', 'widget']).isRequired,
};

VisualizationRenderer.defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions client/app/visualizations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const RendererPropTypes = {
data: Data.isRequired,
options: VisualizationOptions.isRequired,
onOptionsChange: PropTypes.func, // (newOptions) => void
context: PropTypes.oneOf(['query', 'widget']).isRequired,
};

// For each visualization's editor
Expand Down
3 changes: 2 additions & 1 deletion client/app/visualizations/table/Renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { prepareColumns, filterRows, sortRows } from './utils';

import './renderer.less';

export default function Renderer({ options, data }) {
export default function Renderer({ options, data, context }) {
const [rowKeyPrefix, setRowKeyPrefix] = useState(`row:1:${options.itemsPerPage}:`);
const [searchTerm, setSearchTerm] = useState('');
const [orderBy, setOrderBy] = useState([]);
Expand Down Expand Up @@ -67,6 +67,7 @@ export default function Renderer({ options, data }) {
dataSource={preparedRows}
rowKey={(record, index) => rowKeyPrefix + index}
pagination={{
size: context === 'widget' ? 'small' : '',
position: 'bottom',
pageSize: options.itemsPerPage,
hideOnSinglePage: true,
Expand Down
14 changes: 9 additions & 5 deletions client/cypress/integration/dashboard/widget_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('Widget', () => {
});
});

it('shows horizontal scrollbar for overflowing tabular content', function () {
it('sets the correct height of table visualization', function () {
const queryData = {
query: `select '${'loremipsum'.repeat(15)}' FROM generate_series(1,15)`,
};
Expand All @@ -149,8 +149,10 @@ describe('Widget', () => {

createQueryAndAddWidget(this.dashboardId, queryData, widgetOptions).then(() => {
cy.visit(this.dashboardUrl);
cy.getByTestId('TableVisualization').should('exist');
cy.percySnapshot('Shows horizontal scrollbar for overflowing tabular content');
cy.getByTestId('TableVisualization')
.its('0.offsetHeight')
.should('eq', 381);
cy.percySnapshot('Shows correct height of table visualization');
});
});

Expand All @@ -163,8 +165,10 @@ describe('Widget', () => {

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

0 comments on commit c74ece4

Please sign in to comment.