villebro commented on code in PR #19866:
URL: https://github.com/apache/superset/pull/19866#discussion_r859791883
##########
superset-frontend/src/explore/components/RowCountLabel/index.tsx:
##########
@@ -17,36 +17,43 @@
* under the License.
*/
import React from 'react';
-import { getNumberFormatter, t } from '@superset-ui/core';
+import { getNumberFormatter, t, tn } from '@superset-ui/core';
import Label from 'src/components/Label';
import { Tooltip } from 'src/components/Tooltip';
type RowCountLabelProps = {
- rowcount: number;
+ rowcount?: number;
limit?: number;
- suffix?: string;
loading?: boolean;
};
export default function RowCountLabel(props: RowCountLabelProps) {
- const { rowcount = 0, limit, suffix = t('rows'), loading } = props;
+ const { rowcount = 0, limit, loading } = props;
const limitReached = rowcount === limit;
const type =
limitReached || (rowcount === 0 && !loading) ? 'danger' : 'default';
const formattedRowCount = getNumberFormatter()(rowcount);
- const tooltip = (
- <span>
- {limitReached && <div>{t('Limit reached')}</div>}
- {loading ? 'Loading' : rowcount}
- </span>
+ const label = (
+ <Label type={type} data-test="row-count-label">
+ {loading
+ ? 'Loading...'
+ : tn('%s row', '%s rows', rowcount, formattedRowCount)}
+ </Label>
);
- return (
- <Tooltip id="tt-rowcount-tooltip" title={tooltip}>
- <Label type={type} data-test="row-count-label">
- {loading ? 'Loading...' : `${formattedRowCount} ${suffix}`}
- </Label>
+ return limitReached ? (
+ <Tooltip
+ id="tt-rowcount-tooltip"
+ title={
+ <span>
Review Comment:
`span` is probably sufficient, but I didn't want to change this to avoid
potential regressions. @kgabryje WDYT?
##########
superset-frontend/src/explore/components/RowCountLabel/index.tsx:
##########
@@ -17,36 +17,43 @@
* under the License.
*/
import React from 'react';
-import { getNumberFormatter, t } from '@superset-ui/core';
+import { getNumberFormatter, t, tn } from '@superset-ui/core';
import Label from 'src/components/Label';
import { Tooltip } from 'src/components/Tooltip';
type RowCountLabelProps = {
- rowcount: number;
+ rowcount?: number;
limit?: number;
- suffix?: string;
loading?: boolean;
};
export default function RowCountLabel(props: RowCountLabelProps) {
- const { rowcount = 0, limit, suffix = t('rows'), loading } = props;
+ const { rowcount = 0, limit, loading } = props;
const limitReached = rowcount === limit;
const type =
limitReached || (rowcount === 0 && !loading) ? 'danger' : 'default';
const formattedRowCount = getNumberFormatter()(rowcount);
- const tooltip = (
- <span>
- {limitReached && <div>{t('Limit reached')}</div>}
- {loading ? 'Loading' : rowcount}
- </span>
+ const label = (
+ <Label type={type} data-test="row-count-label">
+ {loading
+ ? 'Loading...'
Review Comment:
Nice catch!
--
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]