You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2021/08/10 05:01:32 UTC
[superset] 22/25: feat: added google alert to DB Connection Form
(#16095)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 1.3
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 8383b2c03d2f43f97f158f429ff81a264199fd35
Author: AAfghahi <48...@users.noreply.github.com>
AuthorDate: Mon Aug 9 14:08:06 2021 -0400
feat: added google alert to DB Connection Form (#16095)
* added google alert
* using superset_text
* made google alert public and others private
* Hugh revisions
(cherry picked from commit a51851308be5884f60bf758f68c8a58431a10c30)
---
.../CRUD/data/database/DatabaseModal/index.tsx | 48 ++++++++++++++++------
1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index 119f15f..99d9169 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -76,6 +76,18 @@ import {
} from './styles';
import ModalHeader, { DOCUMENTATION_LINK } from './ModalHeader';
+const engineSpecificAlertMapping = {
+ gsheets: {
+ message: 'Why do I need to create a database?',
+ description:
+ 'To begin using your Google Sheets, you need to create a database first. ' +
+ 'Databases are used as a way to identify ' +
+ 'your data so that it can be queried and visualized. This ' +
+ 'database will hold all of your individual Google Sheets ' +
+ 'you choose to connect here.',
+ },
+};
+
const errorAlertMapping = {
CONNECTION_MISSING_PARAMETERS_ERROR: {
message: 'Missing Required Fields',
@@ -454,10 +466,11 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
const sslForced = isFeatureEnabled(
FeatureFlag.FORCE_DATABASE_CONNECTIONS_SSL,
);
+ const hasAlert =
+ connectionAlert || !!(db?.engine && engineSpecificAlertMapping[db.engine]);
const useSqlAlchemyForm =
db?.configuration_method === CONFIGURATION_METHOD.SQLALCHEMY_URI;
const useTabLayout = isEditMode || useSqlAlchemyForm;
-
// Database fetch logic
const {
state: { loading: dbLoading, resource: dbFetched, error: dbErrors },
@@ -834,6 +847,26 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
setTabKey(key);
};
+ const renderStepTwoAlert = () =>
+ db?.engine && (
+ <StyledAlertMargin>
+ <Alert
+ closable={false}
+ css={(theme: SupersetTheme) => antDAlertStyles(theme)}
+ type="info"
+ showIcon
+ message={
+ engineSpecificAlertMapping[db.engine]?.message ||
+ connectionAlert?.DEFAULT?.message
+ }
+ description={
+ engineSpecificAlertMapping[db.engine]?.description ||
+ connectionAlert?.DEFAULT?.description
+ }
+ />
+ </StyledAlertMargin>
+ );
+
const errorAlert = () => {
if (
isEmpty(dbErrors) ||
@@ -1188,18 +1221,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
dbName={dbName}
dbModel={dbModel}
/>
- {connectionAlert && (
- <StyledAlertMargin>
- <Alert
- closable={false}
- css={(theme: SupersetTheme) => antDAlertStyles(theme)}
- type="info"
- showIcon
- message={t('IP Allowlist')}
- description={connectionAlert.ALLOWED_IPS}
- />
- </StyledAlertMargin>
- )}
+ {hasAlert && renderStepTwoAlert()}
<DatabaseConnectionForm
db={db}
sslForced={sslForced}