Skip to content

Commit

Permalink
fix(core): missing translation (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
maltoze authored and zhaoyongjie committed Nov 26, 2021
1 parent 25ec1e3 commit 9227b1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { CSSProperties, useMemo } from 'react';
import { t } from '../../translation';

const MESSAGE_STYLES: CSSProperties = { maxWidth: 800 };
const TITLE_STYLES: CSSProperties = { fontSize: 16, fontWeight: 'bold', paddingBottom: 8 };
const BODY_STYLES: CSSProperties = { fontSize: 14 };
const MIN_WIDTH_FOR_BODY = 250;
const BODY_STRING =
'No results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.';

const generateContainerStyles: (
height: number | string,
Expand Down Expand Up @@ -34,6 +33,10 @@ const NoResultsComponent = ({ className, height, id, width }: Props) => {
// render the body if the width is auto/100% or greater than 250 pixels
const shouldRenderBody = typeof width === 'string' || width > MIN_WIDTH_FOR_BODY;

const BODY_STRING = t(
'No results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.',
);

return (
<div
className={className}
Expand All @@ -42,7 +45,7 @@ const NoResultsComponent = ({ className, height, id, width }: Props) => {
title={shouldRenderBody ? undefined : BODY_STRING}
>
<div style={MESSAGE_STYLES}>
<div style={TITLE_STYLES}>No Results</div>
<div style={TITLE_STYLES}>{t('No Results')}</div>
{shouldRenderBody && <div style={BODY_STYLES}>{BODY_STRING}</div>}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { shallow } from 'enzyme';
import NoResultsComponent from '@superset-ui/core/src/chart/components/NoResultsComponent';
import { configure } from '@superset-ui/core/src';

configure();

describe('NoResultsComponent', () => {
it('renders the no results error', () => {
Expand Down

0 comments on commit 9227b1e

Please sign in to comment.