Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { Dataset } from '../types';
import TableControls from './DrillDetailTableControls';
import { getDrillPayload } from './utils';
import { ResultsPage } from './types';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

const PAGE_SIZE = 50;

Expand Down Expand Up @@ -303,7 +304,7 @@ export default function DrillDetailPane({
tableContent = <Loading />;
} else if (resultsPage?.total === 0) {
// Render empty state if no results are returned for page
const title = t('No rows were returned for this dataset');
const title = t('No rows were returned for this %s', datasetLabelLower());
tableContent = <EmptyState image="document.svg" title={title} />;
} else {
// Render table if at least one page has successfully loaded
Expand Down
24 changes: 20 additions & 4 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import type {
DatabaseObject,
} from './types';
import { StyledFormLabel } from './styles';
import {
databaseLabel,
databasesLabelLower,
} from 'src/utils/semanticLayerLabels';

const DatabaseSelectorWrapper = styled.div<{ horizontal?: boolean }>`
${({ theme, horizontal }) =>
Expand Down Expand Up @@ -431,7 +435,11 @@ export function DatabaseSelector({
function renderDatabaseSelect() {
if (sqlLabMode) {
return renderSelectRow(
t('Select database or type to search databases'),
t(
'Select %s or type to search %s',
databaseLabel().toLowerCase(),
databasesLabelLower(),
),
null,
null,
{
Expand All @@ -448,16 +456,24 @@ export function DatabaseSelector({
return (
<div>
{renderSelectRow(
t('Database'),
databaseLabel(),
<AsyncSelect
ariaLabel={t('Select database or type to search databases')}
ariaLabel={t(
'Select %s or type to search %s',
databaseLabel().toLowerCase(),
databasesLabelLower(),
)}
optionFilterProps={['database_name', 'value']}
data-test="select-database"
lazyLoading={false}
notFoundContent={emptyState}
onChange={changeDatabase}
value={currentDb}
placeholder={t('Select database or type to search databases')}
placeholder={t(
'Select %s or type to search %s',
databaseLabel().toLowerCase(),
databasesLabelLower(),
)}
disabled={!isDatabaseSelectEnabled || readOnly}
options={loadDatabases}
sortComparator={sortComparator}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
import withToasts from 'src/components/MessageToasts/withToasts';
import { InputRef } from 'antd';
import type { Datasource, ChangeDatasourceModalProps } from '../types';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

const CONFIRM_WARNING_MESSAGE = t(
'Warning! Changing the dataset may break the chart if the metadata does not exist.',
Expand Down Expand Up @@ -109,7 +110,11 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
const {
state: { loading, resourceCollection, resourceCount },
fetchData,
} = useListViewResource<Dataset>('dataset', t('dataset'), addDangerToast);
} = useListViewResource<Dataset>(
'dataset',
datasetLabelLower(),
addDangerToast,
);

const selectDatasource = useCallback((datasource: Datasource) => {
setConfirmChange(true);
Expand Down Expand Up @@ -187,7 +192,7 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
);
});
onHide();
addSuccessToast(t('Successfully changed dataset!'));
addSuccessToast(t('Successfully changed %s!', datasetLabelLower()));
};

const handlerCancelConfirm = () => {
Expand Down Expand Up @@ -253,7 +258,7 @@ const ChangeDatasourceModal: FunctionComponent<ChangeDatasourceModalProps> = ({
onHide={onHide}
responsive
name="Swap dataset"
title={t('Swap dataset')}
title={t('Swap %s', datasetLabelLower())}
width={confirmChange ? '432px' : ''}
height={confirmChange ? 'auto' : '540px'}
hideFooter={!confirmChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { t } from '@apache-superset/core/translation';

import type { ErrorMessageComponentProps } from './types';
import { ErrorAlert } from './ErrorAlert';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

export function DatasetNotFoundErrorMessage({
error,
Expand All @@ -29,7 +30,7 @@ export function DatasetNotFoundErrorMessage({
const { level, message } = error;
return (
<ErrorAlert
errorType={t('Missing dataset')}
errorType={t('Missing %s', datasetLabelLower())}
message={subtitle}
description={message}
type={level}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Tooltip, ImageLoader } from '@superset-ui/core/components';
import { GenericLink, usePluginContext } from 'src/components';
import { assetUrl } from 'src/utils/assetUrl';
import { Theme } from '@emotion/react';
import { datasetLabel } from 'src/utils/semanticLayerLabels';

const FALLBACK_THUMBNAIL_URL = assetUrl(
'/static/assets/images/chart-card-fallback.svg',
Expand Down Expand Up @@ -283,7 +284,7 @@ const AddSliceCard: FC<{
>
<MetadataItem label={t('Viz type')} value={vizName} />
<MetadataItem
label={t('Dataset')}
label={datasetLabel()}
value={
datasourceUrl ? (
<GenericLink to={datasourceUrl}>
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/src/dashboard/components/SliceAdder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import type { ConnectDragSource } from 'react-dnd';
import AddSliceCard from './AddSliceCard';
import AddSliceDragPreview from './dnd/AddSliceDragPreview';
import { DragDroppable } from './dnd/DragDroppable';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

export type SliceAdderProps = {
theme: Theme;
Expand Down Expand Up @@ -88,7 +89,7 @@ const KEYS_TO_FILTERS = ['slice_name', 'viz_type', 'datasource_name'];
const KEYS_TO_SORT = {
slice_name: t('name'),
viz_type: t('viz type'),
datasource_name: t('dataset'),
datasource_name: datasetLabelLower(),
changed_on: t('recent'),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { addDangerToast } from 'src/components/MessageToasts/actions';
import { cachedSupersetGet } from 'src/utils/cachedSupersetGet';
import { dispatchChartCustomizationHoverAction } from './utils';
import { mergeExtraFormData } from '../../utils';
import { datasetLabel as getDatasetLabel, datasetLabelLower } from 'src/utils/semanticLayerLabels';

interface ColumnApiResponse {
column_name?: string;
Expand Down Expand Up @@ -262,7 +263,7 @@ const GroupByFilterCardContent: FC<{
</Row>

<Row>
<RowLabel>{t('Dataset')}</RowLabel>
<RowLabel>{getDatasetLabel()}</RowLabel>
<RowValue>
{typeof datasetLabel === 'string' ? datasetLabel : 'Dataset'}
</RowValue>
Expand Down Expand Up @@ -475,7 +476,13 @@ const GroupByFilterCard: FC<GroupByFilterCardProps> = ({
} catch (error) {
setColumnOptions([]);
dispatch(
addDangerToast(t('Failed to load columns for dataset %s', datasetId)),
addDangerToast(
t(
'Failed to load columns for %s %s',
datasetLabelLower(),
datasetId,
),
),
);
} finally {
setLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import {
Dataset,
DatasetSelectLabel,
} from 'src/features/datasets/DatasetSelectLabel';
import {
datasetLabel,
datasetLabelLower,
datasetsLabelLower,
} from 'src/utils/semanticLayerLabels';

interface DatasetSelectProps {
onChange: (value: { label: string | ReactNode; value: number }) => void;
Expand Down Expand Up @@ -101,13 +106,13 @@ const DatasetSelect = ({

return (
<AsyncSelect
ariaLabel={t('Dataset')}
ariaLabel={datasetLabel()}
value={value}
options={loadDatasetOptionsCallback}
onChange={onChange}
optionFilterProps={['table_name']}
notFoundContent={t('No compatible datasets found')}
placeholder={t('Select a dataset')}
notFoundContent={t('No compatible %s found', datasetsLabelLower())}
placeholder={t('Select a %s', datasetLabelLower())}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import {
INPUT_WIDTH,
} from './constants';
import DependencyList from './DependencyList';
import { datasetLabel } from 'src/utils/semanticLayerLabels';

const FORM_ITEM_WIDTH = 260;

Expand Down Expand Up @@ -972,7 +973,7 @@ const FiltersConfigForm = (
<StyledFormItem
expanded={expanded}
name={['filters', filterId, 'dataset']}
label={<StyledLabel>{t('Dataset')}</StyledLabel>}
label={<StyledLabel>{datasetLabel()}</StyledLabel>}
initialValue={
datasetDetails
? {
Expand All @@ -992,7 +993,7 @@ const FiltersConfigForm = (
rules={[
{
required: !isRemoved,
message: t('Dataset is required'),
message: t('%s is required', datasetLabel()),
},
]}
{...getFiltersConfigModalTestId('datasource-input')}
Expand All @@ -1018,7 +1019,7 @@ const FiltersConfigForm = (
) : (
<StyledFormItem
expanded={expanded}
label={<StyledLabel>{t('Dataset')}</StyledLabel>}
label={<StyledLabel>{datasetLabel()}</StyledLabel>}
>
<Loading position="inline-centered" />
</StyledFormItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { useState, useEffect, useMemo, useCallback } from 'react';
import { t } from '@apache-superset/core/translation';
import { ensureIsArray } from '@superset-ui/core';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';
import { styled } from '@apache-superset/core/theme';
import {
TableView,
Expand Down Expand Up @@ -135,7 +136,10 @@ export const SamplesPane = ({
}

if (data.length === 0) {
const title = t('No samples were returned for this dataset');
const title = t(
'No samples were returned for this %s',
datasetLabelLower(),
);
return <EmptyState image="document.svg" title={title} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { Icons } from '@superset-ui/core/components/Icons';
import WarningIconWithTooltip from '@superset-ui/core/components/WarningIconWithTooltip';
import { URL_PARAMS } from 'src/constants';
import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';
import {
userHasPermission,
isUserAdmin,
Expand Down Expand Up @@ -375,7 +376,7 @@ class DatasourceControl extends PureComponent<

const canAccessSqlLab = userHasPermission(user, 'SQL Lab', 'menu_access');

const editText = t('Edit dataset');
const editText = t('Edit %s', datasetLabelLower());
const requestedQuery = {
datasourceKey: `${datasource.id}__${datasource.type}`,
sql: datasource.sql,
Expand All @@ -387,7 +388,9 @@ class DatasourceControl extends PureComponent<
label: !allowEdit ? (
<Tooltip
title={t(
'You must be a dataset owner in order to edit. Please reach out to a dataset owner to request modifications or edit access.',
'You must be a %s owner in order to edit. Please reach out to a %s owner to request modifications or edit access.',
datasetLabelLower(),
datasetLabelLower(),
)}
>
{editText}
Expand All @@ -402,7 +405,7 @@ class DatasourceControl extends PureComponent<

defaultDatasourceMenuItems.push({
key: CHANGE_DATASET,
label: t('Swap dataset'),
label: t('Swap %s', datasetLabelLower()),
});

if (!isMissingDatasource && canAccessSqlLab) {
Expand Down Expand Up @@ -481,7 +484,7 @@ class DatasourceControl extends PureComponent<

queryDatasourceMenuItems.push({
key: SAVE_AS_DATASET,
label: <span>{t('Save as dataset')}</span>,
label: <span>{t('Save as %s', datasetLabelLower())}</span>,
});

const queryDatasourceMenu = (
Expand All @@ -495,7 +498,7 @@ class DatasourceControl extends PureComponent<

const titleText =
isMissingDatasource && !datasource.name
? t('Missing dataset')
? t('Missing %s', datasetLabelLower())
: getDatasourceTitle(datasource);

const tooltip = titleText;
Expand Down Expand Up @@ -561,14 +564,15 @@ class DatasourceControl extends PureComponent<
) : (
<ErrorAlert
type="warning"
message={t('Missing dataset')}
message={t('Missing %s', datasetLabelLower())}
descriptionPre={false}
descriptionDetailsCollapsed={false}
descriptionDetails={
<>
<p>
{t(
'The dataset linked to this chart may have been deleted.',
'The %s linked to this chart may have been deleted.',
datasetLabelLower(),
)}
</p>
<p>
Expand All @@ -578,7 +582,7 @@ class DatasourceControl extends PureComponent<
this.handleMenuItemClick({ key: CHANGE_DATASET })
}
>
{t('Swap dataset')}
{t('Swap %s', datasetLabelLower())}
</Button>
</p>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import AdhocFilter from 'src/explore/components/controls/FilterControl/AdhocFilt
import { OptionSortType } from 'src/explore/types';
import { useGetTimeRangeLabel } from 'src/explore/components/controls/FilterControl/utils';
import OptionWrapper from './OptionWrapper';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

export interface DndAdhocFilterOptionProps {
adhocFilter: AdhocFilter;
Expand Down Expand Up @@ -68,7 +69,10 @@ export default function DndAdhocFilterOption({
isExtra={adhocFilter.isExtra}
datasourceWarningMessage={
adhocFilter.datasourceWarning
? t('This filter might be incompatible with current dataset')
? t(
'This filter might be incompatible with current %s',
datasetLabelLower(),
)
: undefined
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetr
import MetricDefinitionValue from 'src/explore/components/controls/MetricControl/MetricDefinitionValue';
import ColumnSelectPopoverTrigger from './ColumnSelectPopoverTrigger';
import { DndControlProps } from './types';
import { datasetLabelLower } from 'src/utils/semanticLayerLabels';

const AGGREGATED_DECK_GL_CHART_TYPES = [
'deck_screengrid',
Expand Down Expand Up @@ -326,7 +327,10 @@ function DndColumnMetricSelect(props: DndColumnMetricSelectProps) {
typeof item === 'object' &&
'error_text' in item &&
item.error_text)
? t('This metric might be incompatible with current dataset')
? t(
'This metric might be incompatible with current %s',
datasetLabelLower(),
)
: undefined;

return (
Expand Down
Loading
Loading