From c360413fc29c0faedbf6e78c63bef08d5d48e4bd Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 20 Oct 2020 21:33:28 -0700 Subject: [PATCH] style(menu): clean up right menu - leaving only "Settings" (#11227) * style(menu): clean up right menu - leaving only settings * bring pre-commit back * fix frontend tests * pre-commit * re-introduce subtle '+' --- .pre-commit-config.yaml | 2 +- UPDATING.md | 4 ++ setup.cfg | 1 + .../spec/javascripts/components/Menu_spec.jsx | 2 +- .../src/components/Menu/Menu.tsx | 63 ++++++++++++++----- .../src/components/Menu/NewMenu.tsx | 22 ++++--- .../src/components/Menu/UserMenu.tsx | 56 ----------------- superset/config.py | 3 + superset/views/utils.py | 10 +-- 9 files changed, 76 insertions(+), 87 deletions(-) delete mode 100644 superset-frontend/src/components/Menu/UserMenu.tsx diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9de04e4de..54d03a9cf3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.770 + rev: v0.790 hooks: - id: mypy - repo: https://github.com/peterdemin/pip-compile-multi diff --git a/UPDATING.md b/UPDATING.md index 3bfd9c0ccf..556ab8ac67 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -29,6 +29,10 @@ assists people when migrating to a new version. * [11244](https://github.com/apache/incubator-superset/pull/11244): The `REDUCE_DASHBOARD_BOOTSTRAP_PAYLOAD` feature flag has been removed after being set to True for multiple months. * [11098](https://github.com/apache/incubator-superset/pull/11098): includes a database migration that adds a `uuid` column to most models, and updates `Dashboard.position_json` to include chart UUIDs. Depending on number of objects, the migration may take up to 5 minutes, requiring planning for downtime. +* [11172](https://github.com/apache/incubator-superset/pull/11172): Turning + off language selectors by default as i18n is incomplete in most languages + and requires more work. You can easily turn on the languages you want + to expose in your environment in superset_config.py * [11172](https://github.com/apache/incubator-superset/pull/11172): Breaking change: SQL templating is turned off be default. To turn it on set `ENABLE_TEMPLATE_PROCESSING` to True on `DEFAULT_FEATURE_FLAGS` diff --git a/setup.cfg b/setup.cfg index 80b13d611a..44f7e0d146 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,6 +44,7 @@ warn_unused_ignores = true check_untyped_defs = true disallow_untyped_calls = true disallow_untyped_defs = true +warn_unused_ignores = false [mypy-superset.migrations.versions.*] ignore_errors = true diff --git a/superset-frontend/spec/javascripts/components/Menu_spec.jsx b/superset-frontend/spec/javascripts/components/Menu_spec.jsx index c0a10ea72a..15c9255416 100644 --- a/superset-frontend/spec/javascripts/components/Menu_spec.jsx +++ b/superset-frontend/spec/javascripts/components/Menu_spec.jsx @@ -173,6 +173,6 @@ describe('Menu', () => { }); it('renders MenuItems in NavDropdown (settings)', () => { - expect(wrapper.find(NavDropdown).find(MenuItem)).toHaveLength(2); + expect(wrapper.find(NavDropdown).find(MenuItem)).toHaveLength(6); }); }); diff --git a/superset-frontend/src/components/Menu/Menu.tsx b/superset-frontend/src/components/Menu/Menu.tsx index 3883b580be..0497726265 100644 --- a/superset-frontend/src/components/Menu/Menu.tsx +++ b/superset-frontend/src/components/Menu/Menu.tsx @@ -24,9 +24,8 @@ import MenuObject, { MenuObjectProps, MenuObjectChildProps, } from './MenuObject'; -import NewMenu from './NewMenu'; -import UserMenu from './UserMenu'; import LanguagePicker, { Languages } from './LanguagePicker'; +import NewMenu from './NewMenu'; interface BrandProps { path: string; @@ -90,6 +89,10 @@ const StyledHeader = styled.header` .nav > li > a { padding: ${({ theme }) => theme.gridUnit * 4}px; } + .dropdown-header { + text-transform: uppercase; + padding-left: 12px; + } .navbar-nav > li > a { color: ${({ theme }) => theme.colors.grayscale.dark1}; @@ -131,10 +134,6 @@ const StyledHeader = styled.header` .navbar-right { display: flex; align-items: center; - .dropdown:first-of-type { - /* this is the "+ NEW" button. Sweep this up when it's replaced */ - margin-right: ${({ theme }) => theme.gridUnit * 2}px; - } } `; @@ -202,7 +201,7 @@ export function Menu({ } if (section.isHeader) { return ( - + {section.label} ); @@ -218,6 +217,47 @@ export function Menu({ ); })} + + {!navbarRight.user_is_anonymous && ( + <> + + + {t('User')} + + + {t('Profile')} + + + {t('Logout')} + + + )} + {(navbarRight.version_string || navbarRight.version_sha) && ( + <> + + + {t('About')} + +
  • + {navbarRight.version_string && ( +
    Version: {navbarRight.version_string}
    + )} + {navbarRight.version_sha && ( +
    SHA: {navbarRight.version_sha}
    + )} +
  • + + )} )} {navbarRight.documentation_url && ( @@ -246,14 +286,6 @@ export function Menu({ languages={navbarRight.languages} /> )} - {!navbarRight.user_is_anonymous && ( - - )} {navbarRight.user_is_anonymous && ( @@ -280,7 +312,6 @@ export default function MenuWrapper({ data }: MenuProps) { // Cycle through menu.menu to build out cleanedMenu and settings const cleanedMenu: MenuObjectProps[] = []; const settings: MenuObjectProps[] = []; - newMenuData.menu.forEach((item: any) => { if (!item) { return; diff --git a/superset-frontend/src/components/Menu/NewMenu.tsx b/superset-frontend/src/components/Menu/NewMenu.tsx index fc8d41bc22..1c57c0d601 100644 --- a/superset-frontend/src/components/Menu/NewMenu.tsx +++ b/superset-frontend/src/components/Menu/NewMenu.tsx @@ -17,10 +17,11 @@ * under the License. */ import React from 'react'; -import { t } from '@superset-ui/core'; -import Button, { DropdownItemProps } from '../Button'; +import { t, styled } from '@superset-ui/core'; +import { MenuItem } from 'react-bootstrap'; +import NavDropdown from 'src/components/NavDropdown'; -const dropdownItems: DropdownItemProps[] = [ +const dropdownItems = [ { label: t('SQL Query'), url: '/superset/sqllab', @@ -37,13 +38,18 @@ const dropdownItems: DropdownItemProps[] = [ icon: 'fa-fw fa-dashboard', }, ]; +const StyledI = styled.div` + color: ${({ theme }) => theme.colors.primary.dark1}; +`; export default function NewMenu() { return ( -
  • - -
  • + }> + {dropdownItems.map((menu, i) => ( + + {menu.label} + + ))} + ); } diff --git a/superset-frontend/src/components/Menu/UserMenu.tsx b/superset-frontend/src/components/Menu/UserMenu.tsx deleted file mode 100644 index 4483f5112d..0000000000 --- a/superset-frontend/src/components/Menu/UserMenu.tsx +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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 React from 'react'; -import { MenuItem } from 'react-bootstrap'; -import NavDropdown from 'src/components/NavDropdown'; -import { t } from '@superset-ui/core'; - -interface UserMenuProps { - userInfoUrl: string; - userLogoutUrl: string; - versionString?: string; - versionSha?: string; -} - -export default function UserMenu({ - userInfoUrl, - userLogoutUrl, - versionString, - versionSha, -}: UserMenuProps) { - return ( - - - - } - > - {t('Profile')} - {t('Logout')} - {(versionString || versionSha) && ( -
  • - {versionString &&
    Version: {versionString}
    } - {versionSha &&
    SHA: {versionSha}
    } -
  • - )} -
    - ); -} diff --git a/superset/config.py b/superset/config.py index 8554e18d9e..30bd13fec9 100644 --- a/superset/config.py +++ b/superset/config.py @@ -285,6 +285,9 @@ LANGUAGES = { "ru": {"flag": "ru", "name": "Russian"}, "ko": {"flag": "kr", "name": "Korean"}, } +# Turning off i18n by default as translation in most languages are +# incomplete and not well maintained. +LANGUAGES = {} # --------------------------------------------------- # Feature flags diff --git a/superset/views/utils.py b/superset/views/utils.py index d313781456..08de168003 100644 --- a/superset/views/utils.py +++ b/superset/views/utils.py @@ -355,11 +355,11 @@ def build_extra_filters( # pylint: disable=too-many-locals,too-many-nested-bloc for filter_id, columns in default_filters.items(): filter_slice = db.session.query(Slice).filter_by(id=filter_id).one_or_none() - filter_configs = ( - json.loads(filter_slice.params or "{}").get("filter_configs") or [] - if filter_slice - else [] - ) + filter_configs: List[Dict[str, Any]] = [] + if filter_slice: + filter_configs = ( + json.loads(filter_slice.params or "{}").get("filter_configs") or [] + ) scopes_by_filter_field = filter_scopes.get(filter_id, {}) for col, val in columns.items():