mirror of
https://github.com/apache/superset.git
synced 2024-09-16 02:29:39 -04:00
fix: Logic for showing extension in Global Nav (#19158)
* fix logic for checking extensions * add specific types * fix lint
This commit is contained in:
parent
bb618a47ff
commit
181ecf4509
@ -412,12 +412,11 @@ export const hasTerminalValidation = (errors: Record<string, any>[]) =>
|
||||
);
|
||||
|
||||
export const checkUploadExtensions = (
|
||||
perm: Array<any> | string | undefined | boolean,
|
||||
cons: Array<any>,
|
||||
perm: Array<string>,
|
||||
cons: Array<string>,
|
||||
) => {
|
||||
if (perm !== undefined) {
|
||||
if (typeof perm === 'boolean') return perm;
|
||||
return intersection(perm, cons).length;
|
||||
return intersection(perm, cons).length > 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ interface MenuObjectChildProps {
|
||||
index?: number;
|
||||
url?: string;
|
||||
isFrontendRoute?: boolean;
|
||||
perm?: string | Array<any> | boolean;
|
||||
perm?: string | boolean;
|
||||
view?: string;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,6 @@ const RightMenu = ({
|
||||
ALLOWED_EXTENSIONS,
|
||||
HAS_GSHEETS_INSTALLED,
|
||||
} = useSelector<any, ExtentionConfigs>(state => state.common.conf);
|
||||
|
||||
const [showModal, setShowModal] = useState<boolean>(false);
|
||||
const [engine, setEngine] = useState<string>('');
|
||||
const canSql = findPermission('can_sqllab', 'Superset', roles);
|
||||
@ -124,19 +123,25 @@ const RightMenu = ({
|
||||
label: t('Upload CSV to database'),
|
||||
name: 'Upload a CSV',
|
||||
url: '/csvtodatabaseview/form',
|
||||
perm: CSV_EXTENSIONS && canUploadCSV,
|
||||
perm:
|
||||
checkUploadExtensions(CSV_EXTENSIONS, ALLOWED_EXTENSIONS) &&
|
||||
canUploadCSV,
|
||||
},
|
||||
{
|
||||
label: t('Upload columnar file to database'),
|
||||
name: 'Upload a Columnar file',
|
||||
url: '/columnartodatabaseview/form',
|
||||
perm: COLUMNAR_EXTENSIONS && canUploadColumnar,
|
||||
perm:
|
||||
checkUploadExtensions(COLUMNAR_EXTENSIONS, ALLOWED_EXTENSIONS) &&
|
||||
canUploadColumnar,
|
||||
},
|
||||
{
|
||||
label: t('Upload Excel file to database'),
|
||||
name: 'Upload Excel',
|
||||
url: '/exceltodatabaseview/form',
|
||||
perm: EXCEL_EXTENSIONS && canUploadExcel,
|
||||
perm:
|
||||
checkUploadExtensions(EXCEL_EXTENSIONS, ALLOWED_EXTENSIONS) &&
|
||||
canUploadExcel,
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -209,9 +214,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 && <Menu.Divider />}
|
||||
<Menu.Item key={item.name}>
|
||||
|
@ -71,7 +71,7 @@ class AsyncQueryManager:
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self._redis: redis.Redis # type: ignore
|
||||
self._redis: redis.Redis
|
||||
self._stream_prefix: str = ""
|
||||
self._stream_limit: Optional[int]
|
||||
self._stream_limit_firehose: Optional[int]
|
||||
|
Loading…
Reference in New Issue
Block a user