mirror of
https://github.com/apache/superset.git
synced 2026-05-02 22:44:28 +00:00
Compare commits
6 Commits
fix_sqllab
...
db-upload-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b51ae8bdc | ||
|
|
22b3cc0480 | ||
|
|
604d72cc98 | ||
|
|
913e068113 | ||
|
|
1a4e2173f5 | ||
|
|
c49789167b |
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-image: &superset-image apachesuperset.docker.scarf.sh/apache/superset:${TAG:-latest-dev}
|
||||
x-superset-volumes:
|
||||
|
||||
157
docker-compose-light.yml
Normal file
157
docker-compose-light.yml
Normal file
@@ -0,0 +1,157 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Lightweight docker-compose for running multiple Superset instances
|
||||
# This includes only essential services: database, Redis, and Superset app
|
||||
#
|
||||
# IMPORTANT: To run multiple instances in parallel:
|
||||
# - Use different project names: docker-compose -p project1 -f docker-compose-light.yml up
|
||||
# - Use different NODE_PORT values: NODE_PORT=9002 docker-compose -p project2 -f docker-compose-light.yml up
|
||||
# - Volumes are isolated by project name (e.g., project1_db_home_light, project2_db_home_light)
|
||||
# - Database name is intentionally different (superset_light) to prevent accidental cross-connections
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-user: &superset-user root
|
||||
x-superset-volumes: &superset-volumes
|
||||
# /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
|
||||
- ./docker:/app/docker
|
||||
- ./superset:/app/superset
|
||||
- ./superset-frontend:/app/superset-frontend
|
||||
- superset_home_light:/app/superset_home
|
||||
- ./tests:/app/tests
|
||||
x-common-build: &common-build
|
||||
context: .
|
||||
target: ${SUPERSET_BUILD_TARGET:-dev} # can use `dev` (default) or `lean`
|
||||
cache_from:
|
||||
- apache/superset-cache:3.10-slim-bookworm
|
||||
args:
|
||||
DEV_MODE: "true"
|
||||
INCLUDE_CHROMIUM: ${INCLUDE_CHROMIUM:-false}
|
||||
INCLUDE_FIREFOX: ${INCLUDE_FIREFOX:-false}
|
||||
BUILD_TRANSLATIONS: ${BUILD_TRANSLATIONS:-false}
|
||||
|
||||
services:
|
||||
db-light:
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
image: postgres:16
|
||||
restart: unless-stopped
|
||||
# No host port mapping - only accessible within Docker network
|
||||
volumes:
|
||||
- db_home_light:/var/lib/postgresql/data
|
||||
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
||||
environment:
|
||||
# Override database name to avoid conflicts
|
||||
POSTGRES_DB: superset_light
|
||||
|
||||
superset-light:
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
build:
|
||||
<<: *common-build
|
||||
command: ["/app/docker/docker-bootstrap.sh", "app"]
|
||||
restart: unless-stopped
|
||||
# No host port mapping - accessed via webpack dev server proxy
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
user: *superset-user
|
||||
depends_on:
|
||||
superset-init-light:
|
||||
condition: service_completed_successfully
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
# Override DB connection for light service
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
# Use light-specific config that disables Redis
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
|
||||
superset-init-light:
|
||||
build:
|
||||
<<: *common-build
|
||||
command: ["/app/docker/docker-init.sh"]
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
depends_on:
|
||||
db-light:
|
||||
condition: service_started
|
||||
user: *superset-user
|
||||
volumes: *superset-volumes
|
||||
environment:
|
||||
# Override DB connection for light service
|
||||
DATABASE_HOST: db-light
|
||||
DATABASE_DB: superset_light
|
||||
POSTGRES_DB: superset_light
|
||||
EXAMPLES_HOST: db-light
|
||||
EXAMPLES_DB: superset_light
|
||||
EXAMPLES_USER: superset
|
||||
EXAMPLES_PASSWORD: superset
|
||||
# Use light-specific config that disables Redis
|
||||
SUPERSET_CONFIG_PATH: /app/docker/pythonpath_dev/superset_config_docker_light.py
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
superset-node-light:
|
||||
build:
|
||||
context: .
|
||||
target: superset-node
|
||||
args:
|
||||
# This prevents building the frontend bundle since we'll mount local folder
|
||||
# and build it on startup while firing docker-frontend.sh in dev mode, where
|
||||
# it'll mount and watch local files and rebuild as you update them
|
||||
DEV_MODE: "true"
|
||||
BUILD_TRANSLATIONS: ${BUILD_TRANSLATIONS:-false}
|
||||
environment:
|
||||
# set this to false if you have perf issues running the npm i; npm run dev in-docker
|
||||
# if you do so, you have to run this manually on the host, which should perform better!
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER: true
|
||||
NPM_RUN_PRUNE: false
|
||||
SCARF_ANALYTICS: "${SCARF_ANALYTICS:-}"
|
||||
# configuring the dev-server to use the host.docker.internal to connect to the backend
|
||||
superset: "http://superset-light:8088"
|
||||
ports:
|
||||
- "127.0.0.1:${NODE_PORT:-9001}:9000" # Parameterized port
|
||||
command: ["/app/docker/docker-frontend.sh"]
|
||||
env_file:
|
||||
- path: docker/.env # default
|
||||
required: true
|
||||
- path: docker/.env-local # optional override
|
||||
required: false
|
||||
volumes: *superset-volumes
|
||||
|
||||
volumes:
|
||||
superset_home_light:
|
||||
external: false
|
||||
db_home_light:
|
||||
external: false
|
||||
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-volumes:
|
||||
&superset-volumes # /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
# If you choose to use this type of deployment make sure to
|
||||
# create you own docker environment file (docker/.env) with your own
|
||||
# unique random secure passwords and SECRET_KEY.
|
||||
#
|
||||
# For verbose logging during development:
|
||||
# - Set SUPERSET_LOG_LEVEL=debug in docker/.env-local for detailed Superset logs
|
||||
# -----------------------------------------------------------------------
|
||||
x-superset-user: &superset-user root
|
||||
x-superset-volumes: &superset-volumes
|
||||
|
||||
@@ -53,7 +53,12 @@ PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
# Development and logging configuration
|
||||
# FLASK_DEBUG: Enables Flask dev features (auto-reload, better error pages) - keep 'true' for development
|
||||
FLASK_DEBUG=true
|
||||
# SUPERSET_LOG_LEVEL: Controls Superset application logging verbosity (debug, info, warning, error, critical)
|
||||
SUPERSET_LOG_LEVEL=info
|
||||
|
||||
SUPERSET_APP_ROOT="/"
|
||||
SUPERSET_ENV=development
|
||||
SUPERSET_LOAD_EXAMPLES=yes
|
||||
@@ -66,4 +71,3 @@ SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
||||
ENABLE_PLAYWRIGHT=false
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
BUILD_SUPERSET_FRONTEND_IN_DOCKER=true
|
||||
SUPERSET_LOG_LEVEL=info
|
||||
|
||||
1
docker/pythonpath_dev/.gitignore
vendored
1
docker/pythonpath_dev/.gitignore
vendored
@@ -20,4 +20,5 @@
|
||||
# DON'T ignore the .gitignore
|
||||
!.gitignore
|
||||
!superset_config.py
|
||||
!superset_config_docker_light.py
|
||||
!superset_config_local.example
|
||||
|
||||
@@ -129,7 +129,7 @@ if os.getenv("CYPRESS_CONFIG") == "true":
|
||||
#
|
||||
try:
|
||||
import superset_config_docker
|
||||
from superset_config_docker import * # noqa
|
||||
from superset_config_docker import * # noqa: F403
|
||||
|
||||
logger.info(
|
||||
f"Loaded your Docker configuration at [{superset_config_docker.__file__}]"
|
||||
|
||||
37
docker/pythonpath_dev/superset_config_docker_light.py
Normal file
37
docker/pythonpath_dev/superset_config_docker_light.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
#
|
||||
# Configuration for docker-compose-light.yml - disables Redis and uses minimal services
|
||||
|
||||
# Import all settings from the main config first
|
||||
from flask_caching.backends.filesystemcache import FileSystemCache
|
||||
from superset_config import * # noqa: F403
|
||||
|
||||
# Override caching to use simple in-memory cache instead of Redis
|
||||
RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab")
|
||||
|
||||
CACHE_CONFIG = {
|
||||
"CACHE_TYPE": "SimpleCache",
|
||||
"CACHE_DEFAULT_TIMEOUT": 300,
|
||||
"CACHE_KEY_PREFIX": "superset_light_",
|
||||
}
|
||||
DATA_CACHE_CONFIG = CACHE_CONFIG
|
||||
THUMBNAIL_CACHE_CONFIG = CACHE_CONFIG
|
||||
|
||||
|
||||
# Disable Celery entirely for lightweight mode
|
||||
CELERY_CONFIG = None # type: ignore[assignment,misc]
|
||||
@@ -26,11 +26,14 @@ Superset locally is using Docker Compose on a Linux or Mac OSX
|
||||
computer. Superset does not have official support for Windows. It's also the easiest
|
||||
way to launch a fully functioning **development environment** quickly.
|
||||
|
||||
Note that there are 3 major ways we support to run `docker compose`:
|
||||
Note that there are 4 major ways we support to run `docker compose`:
|
||||
|
||||
1. **docker-compose.yml:** for interactive development, where we mount your local folder with the
|
||||
frontend/backend files that you can edit and experience the changes you
|
||||
make in the app in real time
|
||||
1. **docker-compose-light.yml:** a lightweight configuration with minimal services (database,
|
||||
Superset app, and frontend dev server) for development. Uses in-memory caching instead of Redis
|
||||
and is designed for running multiple instances simultaneously
|
||||
1. **docker-compose-non-dev.yml** where we just build a more immutable image based on the
|
||||
local branch and get all the required images running. Changes in the local branch
|
||||
at the time you fire this up will be reflected, but changes to the code
|
||||
@@ -44,7 +47,7 @@ Note that there are 3 major ways we support to run `docker compose`:
|
||||
The `dev` builds include the `psycopg2-binary` required to connect
|
||||
to the Postgres database launched as part of the `docker compose` builds.
|
||||
|
||||
More on these two approaches after setting up the requirements for either.
|
||||
More on these approaches after setting up the requirements for either.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -103,13 +106,36 @@ and help you start fresh. In the context of `docker compose` setting
|
||||
from within docker. This will slow down the startup, but will fix various npm-related issues.
|
||||
:::
|
||||
|
||||
### Option #2 - build a set of immutable images from the local branch
|
||||
### Option #2 - lightweight development with multiple instances
|
||||
|
||||
For a lighter development setup that uses fewer resources and supports running multiple instances:
|
||||
|
||||
```bash
|
||||
# Single lightweight instance (default port 9001)
|
||||
docker compose -f docker-compose-light.yml up
|
||||
|
||||
# Multiple instances with different ports
|
||||
NODE_PORT=9001 docker compose -p superset-1 -f docker-compose-light.yml up
|
||||
NODE_PORT=9002 docker compose -p superset-2 -f docker-compose-light.yml up
|
||||
NODE_PORT=9003 docker compose -p superset-3 -f docker-compose-light.yml up
|
||||
```
|
||||
|
||||
This configuration includes:
|
||||
- PostgreSQL database (internal network only)
|
||||
- Superset application server
|
||||
- Frontend development server with webpack hot reloading
|
||||
- In-memory caching (no Redis)
|
||||
- Isolated volumes and networks per instance
|
||||
|
||||
Access each instance at `http://localhost:{NODE_PORT}` (e.g., `http://localhost:9001`).
|
||||
|
||||
### Option #3 - build a set of immutable images from the local branch
|
||||
|
||||
```bash
|
||||
docker compose -f docker-compose-non-dev.yml up
|
||||
```
|
||||
|
||||
### Option #3 - boot up an official release
|
||||
### Option #4 - boot up an official release
|
||||
|
||||
```bash
|
||||
# Set the version you want to run
|
||||
|
||||
@@ -111,7 +111,7 @@ athena = ["pyathena[pandas]>=2, <3"]
|
||||
aurora-data-api = ["preset-sqlalchemy-aurora-data-api>=0.2.8,<0.3"]
|
||||
bigquery = [
|
||||
"pandas-gbq>=0.19.1",
|
||||
"sqlalchemy-bigquery>=1.6.1",
|
||||
"sqlalchemy-bigquery>=1.15.0",
|
||||
"google-cloud-bigquery>=3.10.0",
|
||||
]
|
||||
clickhouse = ["clickhouse-connect>=0.5.14, <1.0"]
|
||||
|
||||
@@ -795,7 +795,7 @@ sqlalchemy==1.4.54
|
||||
# shillelagh
|
||||
# sqlalchemy-bigquery
|
||||
# sqlalchemy-utils
|
||||
sqlalchemy-bigquery==1.12.0
|
||||
sqlalchemy-bigquery==1.15.0
|
||||
# via apache-superset
|
||||
sqlalchemy-utils==0.38.3
|
||||
# via
|
||||
|
||||
@@ -149,7 +149,12 @@ export default styled.div`
|
||||
.dt-pagination {
|
||||
text-align: right;
|
||||
/* use padding instead of margin so clientHeight can capture it */
|
||||
padding-top: 0.5em;
|
||||
padding: ${theme.paddingXXS}px 0px;
|
||||
}
|
||||
|
||||
.dt-pagination .pagination > li {
|
||||
display: inline;
|
||||
margin: 0 ${theme.marginXXS}px;
|
||||
}
|
||||
|
||||
.dt-pagination .pagination > li > a,
|
||||
@@ -157,6 +162,8 @@ export default styled.div`
|
||||
background-color: ${theme.colorBgBase};
|
||||
color: ${theme.colorText};
|
||||
border-color: ${theme.colorBorderSecondary};
|
||||
padding: ${theme.paddingXXS}px ${theme.paddingXS}px;
|
||||
border-radius: ${theme.borderRadius}px;
|
||||
}
|
||||
|
||||
.dt-pagination .pagination > li.active > a,
|
||||
|
||||
@@ -96,7 +96,6 @@ const StyledTabsContainer = styled.div`
|
||||
|
||||
.ant-tabs-content-holder {
|
||||
overflow: visible;
|
||||
padding-top: ${theme.sizeUnit * 4}px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import { memo, useMemo } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { css, SupersetTheme } from '@superset-ui/core';
|
||||
import { Icons } from '@superset-ui/core/components/Icons';
|
||||
import { Flex, Icons } from '@superset-ui/core/components';
|
||||
import { getChartKey } from 'src/explore/exploreUtils';
|
||||
import { ExplorePageState } from 'src/explore/types';
|
||||
import { FastVizSwitcherProps } from './types';
|
||||
@@ -79,14 +79,7 @@ export const FastVizSwitcher = memo(
|
||||
}, [currentSelection, currentViz]);
|
||||
|
||||
return (
|
||||
<div
|
||||
css={(theme: SupersetTheme) => css`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
column-gap: ${theme.sizeUnit}px;
|
||||
`}
|
||||
data-test="fast-viz-switcher"
|
||||
>
|
||||
<Flex justify="space-between" gap={4} data-test="fast-viz-switcher">
|
||||
{vizTiles.map(vizMeta => (
|
||||
<VizTile
|
||||
vizMeta={vizMeta}
|
||||
@@ -96,7 +89,7 @@ export const FastVizSwitcher = memo(
|
||||
key={vizMeta.name}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Flex>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -124,7 +124,7 @@ export const VizTile = ({
|
||||
>
|
||||
<span
|
||||
css={css`
|
||||
padding: 0px ${theme.sizeUnit}px;
|
||||
padding: 0px ${theme.sizeUnit * 1.25}px;
|
||||
`}
|
||||
>
|
||||
{vizMeta.icon}
|
||||
@@ -136,6 +136,7 @@ export const VizTile = ({
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
min-width: 0;
|
||||
padding-right: ${theme.sizeUnit}px;
|
||||
line-height: 1;
|
||||
`}
|
||||
ref={chartNameRef}
|
||||
>
|
||||
|
||||
@@ -50,6 +50,7 @@ const ExtraOptions = ({
|
||||
onExtraInputChange,
|
||||
onExtraEditorChange,
|
||||
extraExtension,
|
||||
testedEngineInfo,
|
||||
}: {
|
||||
db: DatabaseObject | null;
|
||||
onInputChange: (
|
||||
@@ -62,13 +63,14 @@ const ExtraOptions = ({
|
||||
) => void;
|
||||
onExtraEditorChange: Function;
|
||||
extraExtension: DatabaseConnectionExtension | undefined;
|
||||
testedEngineInfo?: any;
|
||||
}) => {
|
||||
const expandableModalIsOpen = !!db?.expose_in_sqllab;
|
||||
const createAsOpen = !!(db?.allow_ctas || db?.allow_cvas);
|
||||
const isFileUploadSupportedByEngine =
|
||||
db?.engine_information?.supports_file_upload;
|
||||
const supportsDynamicCatalog =
|
||||
db?.engine_information?.supports_dynamic_catalog;
|
||||
// Use tested engine info if available, otherwise fall back to initial engine info
|
||||
const engineInfo = testedEngineInfo || db?.engine_information;
|
||||
const isFileUploadSupportedByEngine = engineInfo?.supports_file_upload;
|
||||
const supportsDynamicCatalog = engineInfo?.supports_dynamic_catalog;
|
||||
|
||||
// JSON.parse will deep parse engine_params
|
||||
// if it's an object, and we want to keep it a string
|
||||
@@ -528,23 +530,29 @@ const ExtraOptions = ({
|
||||
/>
|
||||
</div>
|
||||
</StyledInputContainer>
|
||||
{isFileUploadSupportedByEngine && (
|
||||
<StyledInputContainer
|
||||
css={!db?.allow_file_upload ? no_margin_bottom : {}}
|
||||
>
|
||||
<div className="input-container">
|
||||
<Checkbox
|
||||
id="allow_file_upload"
|
||||
name="allow_file_upload"
|
||||
indeterminate={false}
|
||||
checked={!!db?.allow_file_upload}
|
||||
onChange={onInputChange}
|
||||
>
|
||||
{t('Allow file uploads to database')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
</StyledInputContainer>
|
||||
)}
|
||||
<StyledInputContainer
|
||||
css={!db?.allow_file_upload ? no_margin_bottom : {}}
|
||||
>
|
||||
<div className="input-container">
|
||||
<Checkbox
|
||||
id="allow_file_upload"
|
||||
name="allow_file_upload"
|
||||
indeterminate={false}
|
||||
checked={!!db?.allow_file_upload}
|
||||
disabled={!isFileUploadSupportedByEngine}
|
||||
onChange={onInputChange}
|
||||
>
|
||||
{t('Allow file uploads to database')}
|
||||
</Checkbox>
|
||||
{!isFileUploadSupportedByEngine && (
|
||||
<InfoTooltip
|
||||
tooltip={t(
|
||||
'File upload is not supported for this database engine'
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</StyledInputContainer>
|
||||
{isFileUploadSupportedByEngine && !!db?.allow_file_upload && (
|
||||
<StyledInputContainer css={no_margin_bottom}>
|
||||
<div className="control-label">
|
||||
|
||||
@@ -607,6 +607,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
const [editNewDb, setEditNewDb] = useState<boolean>(false);
|
||||
const [isLoading, setLoading] = useState<boolean>(false);
|
||||
const [testInProgress, setTestInProgress] = useState<boolean>(false);
|
||||
const [testedEngineInfo, setTestedEngineInfo] = useState<any>(null);
|
||||
const [passwords, setPasswords] = useState<Record<string, string>>({});
|
||||
const [sshTunnelPasswords, setSSHTunnelPasswords] = useState<
|
||||
Record<string, string>
|
||||
@@ -735,6 +736,9 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
addSuccessToast(errorMsg);
|
||||
setHasValidated(true);
|
||||
},
|
||||
(engineInfo: any) => {
|
||||
setTestedEngineInfo(engineInfo);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -797,6 +801,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
setSSHTunnelPrivateKeyPasswords({});
|
||||
setConfirmedOverwrite(false);
|
||||
setUseSSHTunneling(undefined);
|
||||
setTestedEngineInfo(null);
|
||||
onHide();
|
||||
};
|
||||
|
||||
@@ -1771,6 +1776,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
<ExtraOptions
|
||||
extraExtension={dbConfigExtraExtension}
|
||||
db={db as DatabaseObject}
|
||||
testedEngineInfo={testedEngineInfo}
|
||||
onInputChange={(
|
||||
e: CheckboxChangeEvent | React.ChangeEvent<HTMLInputElement>,
|
||||
) => {
|
||||
@@ -2020,6 +2026,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||
<ExtraOptions
|
||||
extraExtension={dbConfigExtraExtension}
|
||||
db={db as DatabaseObject}
|
||||
testedEngineInfo={testedEngineInfo}
|
||||
onInputChange={(e: CheckboxChangeEvent) => {
|
||||
const { target } = e;
|
||||
onChange(ActionType.InputChange, {
|
||||
|
||||
@@ -612,3 +612,42 @@ test('should render an extension component if one is supplied', async () => {
|
||||
|
||||
expect(extension[0]).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should render the brand text if available', async () => {
|
||||
useSelectorMock.mockReturnValue({ roles: [] });
|
||||
|
||||
const modifiedProps = {
|
||||
...mockedProps,
|
||||
data: {
|
||||
...mockedProps.data,
|
||||
brand: {
|
||||
...mockedProps.data.brand,
|
||||
text: 'Welcome to Superset',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
render(<Menu {...modifiedProps} />, {
|
||||
useRouter: true,
|
||||
useQueryParams: true,
|
||||
useRedux: true,
|
||||
useTheme: true,
|
||||
});
|
||||
|
||||
const brandText = await screen.findByText('Welcome to Superset');
|
||||
expect(brandText).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should not render the brand text if not available', async () => {
|
||||
useSelectorMock.mockReturnValue({ roles: [] });
|
||||
const text = 'Welcome to Superset';
|
||||
render(<Menu {...mockedProps} />, {
|
||||
useRouter: true,
|
||||
useQueryParams: true,
|
||||
useRedux: true,
|
||||
useTheme: true,
|
||||
});
|
||||
|
||||
const brandText = screen.queryByText(text);
|
||||
expect(brandText).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -52,6 +52,8 @@ const StyledHeader = styled.header`
|
||||
display: none;
|
||||
}
|
||||
& .ant-image{
|
||||
display: contents;
|
||||
height: 100%;
|
||||
padding: ${theme.sizeUnit}px
|
||||
${theme.sizeUnit * 2}px
|
||||
${theme.sizeUnit}px
|
||||
@@ -87,7 +89,7 @@ const StyledHeader = styled.header`
|
||||
padding-left: ${theme.sizeUnit * 4}px;
|
||||
padding-right: ${theme.sizeUnit * 4}px;
|
||||
margin-right: ${theme.sizeUnit * 6}px;
|
||||
font-size: ${theme.sizeUnit * 4}px;
|
||||
font-size: ${theme.fontSizeLG}px;
|
||||
float: left;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -322,6 +324,11 @@ export function Menu({
|
||||
>
|
||||
{renderBrand()}
|
||||
</Tooltip>
|
||||
{brand.text && (
|
||||
<div className="navbar-brand-text">
|
||||
<span>{brand.text}</span>
|
||||
</div>
|
||||
)}
|
||||
<MainNav
|
||||
mode={showMenu}
|
||||
data-test="navbar-top"
|
||||
|
||||
@@ -712,14 +712,18 @@ export const testDatabaseConnection = (
|
||||
connection: Partial<DatabaseObject>,
|
||||
handleErrorMsg: (errorMsg: string) => void,
|
||||
addSuccessToast: (arg0: string) => void,
|
||||
onEngineInfo?: (engineInfo: any) => void,
|
||||
) => {
|
||||
SupersetClient.post({
|
||||
endpoint: 'api/v1/database/test_connection/',
|
||||
body: JSON.stringify(connection),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}).then(
|
||||
() => {
|
||||
(response) => {
|
||||
addSuccessToast(t('Connection looks good!'));
|
||||
if (onEngineInfo && response?.json?.engine_information) {
|
||||
onEngineInfo(response.json.engine_information);
|
||||
}
|
||||
},
|
||||
createErrorHandler((errMsg: Record<string, string[] | string> | string) => {
|
||||
handleErrorMsg(t('ERROR: %s', parsedErrorMessage(errMsg)));
|
||||
|
||||
@@ -53,6 +53,7 @@ const {
|
||||
measure = false,
|
||||
nameChunks = false,
|
||||
} = parsedArgs;
|
||||
|
||||
const isDevMode = mode !== 'production';
|
||||
const isDevServer = process.argv[1].includes('webpack-dev-server');
|
||||
|
||||
@@ -535,6 +536,11 @@ if (isDevMode) {
|
||||
runtimeErrors: error => !/ResizeObserver/.test(error.message),
|
||||
},
|
||||
logging: 'error',
|
||||
webSocketURL: {
|
||||
hostname: '0.0.0.0',
|
||||
pathname: '/ws',
|
||||
port: 0,
|
||||
},
|
||||
},
|
||||
static: {
|
||||
directory: path.join(process.cwd(), '../static/assets'),
|
||||
|
||||
@@ -91,7 +91,7 @@ class TestConnectionDatabaseCommand(BaseCommand):
|
||||
|
||||
def run( # noqa: C901
|
||||
self,
|
||||
) -> None: # pylint: disable=too-many-statements,too-many-branches
|
||||
) -> Database: # pylint: disable=too-many-statements,too-many-branches
|
||||
self.validate()
|
||||
ex_str = ""
|
||||
ssh_tunnel = self._properties.get("ssh_tunnel")
|
||||
@@ -168,6 +168,8 @@ class TestConnectionDatabaseCommand(BaseCommand):
|
||||
action=get_log_connection_action("test_connection_success", ssh_tunnel),
|
||||
engine=database.db_engine_spec.__name__,
|
||||
)
|
||||
|
||||
return database
|
||||
|
||||
except (NoSuchModuleError, ModuleNotFoundError) as ex:
|
||||
event_logger.log_with_context(
|
||||
|
||||
@@ -1155,7 +1155,7 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
|
||||
}
|
||||
|
||||
|
||||
CELERY_CONFIG: type[CeleryConfig] = CeleryConfig
|
||||
CELERY_CONFIG: type[CeleryConfig] | None = CeleryConfig
|
||||
|
||||
# Set celery config to None to disable all the above configuration
|
||||
# CELERY_CONFIG = None
|
||||
|
||||
@@ -1258,6 +1258,17 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
engine_information:
|
||||
type: object
|
||||
properties:
|
||||
supports_file_upload:
|
||||
type: boolean
|
||||
disable_ssh_tunneling:
|
||||
type: boolean
|
||||
supports_dynamic_catalog:
|
||||
type: boolean
|
||||
supports_oauth2:
|
||||
type: boolean
|
||||
400:
|
||||
$ref: '#/components/responses/400'
|
||||
422:
|
||||
@@ -1271,8 +1282,9 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
||||
except ValidationError as error:
|
||||
return self.response_400(message=error.messages)
|
||||
try:
|
||||
TestConnectionDatabaseCommand(item).run()
|
||||
return self.response(200, message="OK")
|
||||
database = TestConnectionDatabaseCommand(item).run()
|
||||
engine_information = database.db_engine_spec.get_public_information()
|
||||
return self.response(200, message="OK", engine_information=engine_information)
|
||||
except (SSHTunnelingNotEnabledError, SSHTunnelDatabasePortError) as ex:
|
||||
return self.response_400(message=str(ex))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user