diff --git a/superset-frontend/src/views/CRUD/utils.test.tsx b/superset-frontend/src/views/CRUD/utils.test.tsx index 68d377e3102cf..ce7139e82a99a 100644 --- a/superset-frontend/src/views/CRUD/utils.test.tsx +++ b/superset-frontend/src/views/CRUD/utils.test.tsx @@ -23,7 +23,6 @@ import { getPasswordsNeeded, getAlreadyExists, hasTerminalValidation, - checkUploadExtensions, } from 'src/views/CRUD/utils'; const terminalErrors = { @@ -187,19 +186,3 @@ test('successfully modified rison to encode correctly', () => { expect(rison.decode(actualEncoding)).toEqual(testObject); }); }); - -test('checkUploadExtenssions should return valid upload extensions', () => { - const uploadExtensionTest = ['a', 'b', 'c']; - const randomExtension = ['a', 'c']; - const randomExtensionTwo = ['c']; - const randomExtensionThree: Array = []; - expect( - checkUploadExtensions(randomExtension, uploadExtensionTest), - ).toBeTruthy(); - expect( - checkUploadExtensions(randomExtensionTwo, uploadExtensionTest), - ).toBeTruthy(); - expect( - checkUploadExtensions(randomExtensionThree, uploadExtensionTest), - ).toBeFalsy(); -}); diff --git a/superset-frontend/src/views/CRUD/utils.tsx b/superset-frontend/src/views/CRUD/utils.tsx index d9d21c8565d17..174e1aa493108 100644 --- a/superset-frontend/src/views/CRUD/utils.tsx +++ b/superset-frontend/src/views/CRUD/utils.tsx @@ -27,7 +27,6 @@ import { css, } from '@superset-ui/core'; import Chart from 'src/types/Chart'; -import { intersection } from 'lodash'; import rison from 'rison'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import { FetchDataConfig } from 'src/components/ListView'; @@ -410,14 +409,3 @@ export const hasTerminalValidation = (errors: Record[]) => isNeedsPassword(payload) || isAlreadyExists(payload), ), ); - -export const checkUploadExtensions = ( - perm: Array | string | undefined | boolean, - cons: Array, -) => { - if (perm !== undefined) { - if (typeof perm === 'boolean') return perm; - return intersection(perm, cons).length; - } - return false; -}; diff --git a/superset-frontend/src/views/components/Menu.tsx b/superset-frontend/src/views/components/Menu.tsx index 3c51beef66f49..47414ba09993f 100644 --- a/superset-frontend/src/views/components/Menu.tsx +++ b/superset-frontend/src/views/components/Menu.tsx @@ -74,7 +74,7 @@ interface MenuObjectChildProps { index?: number; url?: string; isFrontendRoute?: boolean; - perm?: string | Array | boolean; + perm?: string | boolean; view?: string; } diff --git a/superset-frontend/src/views/components/MenuRight.tsx b/superset-frontend/src/views/components/MenuRight.tsx index 60fd4565ac1f7..7f8adce6bf931 100644 --- a/superset-frontend/src/views/components/MenuRight.tsx +++ b/superset-frontend/src/views/components/MenuRight.tsx @@ -26,7 +26,6 @@ import { useSelector } from 'react-redux'; import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes'; import LanguagePicker from './LanguagePicker'; import DatabaseModal from '../CRUD/data/database/DatabaseModal'; -import { checkUploadExtensions } from '../CRUD/utils'; import { ExtentionConfigs, GlobalMenuDataOptions, @@ -76,7 +75,6 @@ const RightMenu = ({ CSV_EXTENSIONS, COLUMNAR_EXTENSIONS, EXCEL_EXTENSIONS, - ALLOWED_EXTENSIONS, HAS_GSHEETS_INSTALLED, } = useSelector(state => state.common.conf); @@ -190,9 +188,7 @@ const RightMenu = ({ title={menuIconAndLabel(menu)} > {menu.childs.map((item, idx) => - typeof item !== 'string' && - item.name && - checkUploadExtensions(item.perm, ALLOWED_EXTENSIONS) ? ( + typeof item !== 'string' && item.name && item.perm ? ( <> {idx === 2 && } diff --git a/superset-frontend/src/views/components/types.ts b/superset-frontend/src/views/components/types.ts index d46c2e1619132..0eff33390a727 100644 --- a/superset-frontend/src/views/components/types.ts +++ b/superset-frontend/src/views/components/types.ts @@ -20,10 +20,9 @@ import { NavBarProps, MenuObjectProps } from './Menu'; export interface ExtentionConfigs { - ALLOWED_EXTENSIONS: Array; - CSV_EXTENSIONS: Array; - COLUMNAR_EXTENSIONS: Array; - EXCEL_EXTENSIONS: Array; + CSV_EXTENSIONS: boolean; + COLUMNAR_EXTENSIONS: boolean; + EXCEL_EXTENSIONS: boolean; HAS_GSHEETS_INSTALLED: boolean; } export interface RightMenuProps { diff --git a/superset/views/base.py b/superset/views/base.py index 1249bc43cc4fb..067e8d74a727a 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -104,10 +104,6 @@ "GLOBAL_ASYNC_QUERIES_WEBSOCKET_URL", "DASHBOARD_AUTO_REFRESH_MODE", "SCHEDULED_QUERIES", - "EXCEL_EXTENSIONS", - "CSV_EXTENSIONS", - "COLUMNAR_EXTENSIONS", - "ALLOWED_EXTENSIONS", ) logger = logging.getLogger(__name__) @@ -351,10 +347,16 @@ def common_bootstrap_payload() -> Dict[str, Any]: locale = str(get_locale()) # should not expose API TOKEN to frontend - frontend_config = { - k: (list(conf.get(k)) if isinstance(conf.get(k), set) else conf.get(k)) - for k in FRONTEND_CONF_KEYS - } + frontend_config = {k: conf.get(k) for k in FRONTEND_CONF_KEYS} + frontend_config["EXCEL_EXTENSIONS"] = bool( + bool(conf["EXCEL_EXTENSIONS"].intersection(conf["ALLOWED_EXTENSIONS"])), + ) + frontend_config["CSV_EXTENSIONS"] = bool( + bool(conf["CSV_EXTENSIONS"].intersection(conf["ALLOWED_EXTENSIONS"])), + ) + frontend_config["COLUMNAR_EXTENSIONS"] = bool( + bool(conf["COLUMNAR_EXTENSIONS"].intersection(conf["ALLOWED_EXTENSIONS"])), + ) if conf.get("SLACK_API_TOKEN"): frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [