msyavuz commented on code in PR #43296:
URL: https://github.com/apache/superset/pull/43296#discussion_r3829646006
##########
superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx:
##########
@@ -111,14 +112,18 @@ export const TableControls = ({
value={rowLimit}
onChange={onRowLimitChange}
options={rowLimitOptions ?? []}
+ // Labelled as the applied limit to avoid a second row count next
to RowCountLabel.
+ prefix={t('Limit')}
css={css`
- min-width: 110px;
+ min-width: 160px;
`}
/>
)}
- {(!onRowLimitChange || rowcount < (rowLimit ?? Infinity)) && (
- <RowCountLabel rowcount={rowcount} loading={isLoading} />
- )}
+ <RowCountLabel
+ rowcount={rowcount}
+ limit={effectiveRowLimit ?? rowLimit}
Review Comment:
`SamplesPane` passes its page size as `rowLimit` (it becomes `per_page` in
`getDatasourceSamples`), so any datasource larger than the page now hits
`limitReached` and shows "The row limit set for the chart was reached. The
chart may show partial data." for a sample with no chart `row_limit` involved —
is that copy intended there?
##########
superset-frontend/src/explore/components/DataTablesPane/test/DataTableControls.test.tsx:
##########
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render, screen, userEvent } from 'spec/helpers/testing-library';
+import { GenericDataType } from '@apache-superset/core/common';
+import {
+ TableControls,
+ ROW_LIMIT_OPTIONS,
+} from '../components/DataTableControls';
+import { TableControlsProps } from '../types';
+
+const setup = (overrides: Partial<TableControlsProps> = {}) =>
+ render(
+ <TableControls
+ data={[]}
+ columnNames={['name']}
+ columnTypes={[GenericDataType.String]}
+ rowcount={0}
+ onInputChange={jest.fn()}
+ isLoading={false}
+ canDownload
+ rowLimit={100}
+ rowLimitOptions={ROW_LIMIT_OPTIONS}
+ onRowLimitChange={jest.fn()}
+ {...overrides}
+ />,
+ { useRedux: true },
+ );
+
+test('shows the row count when the result fills the selected row limit', () =>
{
+ setup({ rowcount: 100, rowLimit: 100 });
+
+ expect(screen.getByTestId('row-count-label')).toHaveTextContent('100 rows');
+});
+
+test('warns that the row limit was reached when the result fills it', async ()
=> {
+ setup({ rowcount: 100, rowLimit: 100 });
+
+ userEvent.hover(screen.getByTestId('row-count-label'));
+
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'The row limit set for the chart was reached',
+ );
+});
+
+test('does not warn when the result is smaller than the selected row limit',
() => {
+ setup({ rowcount: 42, rowLimit: 100 });
+
+ expect(screen.getByTestId('row-count-label')).toHaveTextContent('42 rows');
+ userEvent.hover(screen.getByTestId('row-count-label'));
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
Review Comment:
This assertion can't fail: antd's 0.1s `mouseEnterDelay` means no tooltip is
in the DOM synchronously after `hover`, so a regression that made the warning
fire at `rowcount: 42, rowLimit: 100` would still pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]