Skip to content

Commit

Permalink
fix table name types and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Nov 22, 2021
1 parent 0e80918 commit 031e14e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
: isEditMode
? t('Edit Alert')
: isReport
? 'Add Report'
: 'Add Alert'}
? t('Add Report')
: t('Add Alert')}
</h4>
}
>
Expand Down
49 changes: 30 additions & 19 deletions superset-frontend/src/views/CRUD/welcome/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ import React from 'react';
import Button from 'src/components/Button';
import { Empty } from 'src/common/components';
import { t, styled } from '@superset-ui/core';
import { WelcomeTable } from './types';

const welcomeTableLabels: Record<WelcomeTable, string> = {
[WelcomeTable.Charts]: t('charts'),
[WelcomeTable.Dashboards]: t('dashboards'),
[WelcomeTable.Recents]: t('recents'),
[WelcomeTable.SavedQueries]: t('saved queries'),
};

interface EmptyStateProps {
tableName: string;
tableName: WelcomeTable;
tab?: string;
}
const EmptyContainer = styled.div`
Expand All @@ -39,28 +47,31 @@ const ButtonContainer = styled.div`
}
`;

type Redirects = Record<
WelcomeTable.Charts | WelcomeTable.Dashboards | WelcomeTable.SavedQueries,
string
>;

export default function EmptyState({ tableName, tab }: EmptyStateProps) {
const mineRedirects = {
DASHBOARDS: '/dashboard/new',
CHARTS: '/chart/add',
SAVED_QUERIES: '/superset/sqllab?new=true',
const mineRedirects: Redirects = {
[WelcomeTable.Charts]: '/chart/add',
[WelcomeTable.Dashboards]: '/dashboard/new',
[WelcomeTable.SavedQueries]: '/superset/sqllab?new=true',
};
const favRedirects = {
DASHBOARDS: '/dashboard/list/',
CHARTS: '/chart/list',
SAVED_QUERIES: '/savedqueryview/list/',
const favRedirects: Redirects = {
[WelcomeTable.Charts]: '/chart/list',
[WelcomeTable.Dashboards]: '/dashboard/list/',
[WelcomeTable.SavedQueries]: '/savedqueryview/list/',
};
const tableIcon = {
RECENTS: 'union.svg',
DASHBOARDS: 'empty-dashboard.svg',
CHARTS: 'empty-charts.svg',
SAVED_QUERIES: 'empty-queries.svg',
const tableIcon: Record<WelcomeTable, string> = {
[WelcomeTable.Charts]: 'empty-charts.svg',
[WelcomeTable.Dashboards]: 'empty-dashboard.svg',
[WelcomeTable.Recents]: 'union.svg',
[WelcomeTable.SavedQueries]: 'empty-queries.svg',
};
const mine = (
<span>
{tableName === 'SAVED_QUERIES'
? t('No saved queries yet')
: t('No %(tableName)s yet', { tableName: tableName.toLowerCase() })}
{t('No %(tableName)s yet', { tableName: welcomeTableLabels[tableName] })}
</span>
);
const recent = (
Expand Down Expand Up @@ -105,7 +116,7 @@ export default function EmptyState({ tableName, tab }: EmptyStateProps) {
<Button
buttonStyle="primary"
onClick={() => {
window.location = mineRedirects[tableName];
window.location.href = mineRedirects[tableName];
}}
>
<i className="fa fa-plus" />
Expand Down Expand Up @@ -137,7 +148,7 @@ export default function EmptyState({ tableName, tab }: EmptyStateProps) {
<Button
buttonStyle="primary"
onClick={() => {
window.location = favRedirects[tableName];
window.location.href = favRedirects[tableName];
}}
>
See all{' '}
Expand Down
25 changes: 25 additions & 0 deletions superset-frontend/src/views/CRUD/welcome/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.
*/

export enum WelcomeTable {
Charts = 'CHARTS',
Dashboards = 'DASHBOARDS',
Recents = 'RECENTS',
SavedQueries = 'SAVED_QUERIES',
}

0 comments on commit 031e14e

Please sign in to comment.