From fbcbb0e74cae7808c31ae38451245e1b5d707bca Mon Sep 17 00:00:00 2001 From: riahk Date: Fri, 28 Aug 2020 11:18:28 -0700 Subject: [PATCH 01/20] Add test connection button --- .../CRUD/data/database/DatabaseModal.tsx | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index de73614a07c95..254a83a38f4f9 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -16,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -import React, { FunctionComponent, useState } from 'react'; +import React, { FunctionComponent, useState, useEffect } from 'react'; import { styled, t } from '@superset-ui/core'; import withToasts from 'src/messageToasts/enhancers/withToasts'; import Icon from 'src/components/Icon'; import Modal from 'src/common/components/Modal'; import Tabs from 'src/common/components/Tabs'; import { DatabaseObject } from './types'; +import Button from 'src/components/Button'; interface DatabaseModalProps { addDangerToast: (msg: string) => void; @@ -70,6 +71,10 @@ const StyledInputContainer = styled.div` flex: 0 1 auto; width: 40%; } + + &[name='uri'] { + margin-right: ${({ theme }) => theme.gridUnit * 3}px; + } } `; @@ -81,9 +86,8 @@ const DatabaseModal: FunctionComponent = ({ show, database = null, }) => { - // const [disableSave, setDisableSave] = useState(true); - const [disableSave] = useState(true); - const [db, setDB] = useState | null>(null); + const [disableSave, setDisableSave] = useState(true); + const [db, setDB] = useState(null); const [isHidden, setIsHidden] = useState(true); // Functions @@ -113,6 +117,14 @@ const DatabaseModal: FunctionComponent = ({ setDB(data); }; + const validate = () => { + if (db && db.name.length && db.uri.length) { + setDisableSave(false); + } else { + setDisableSave(true); + } + }; + const isEditMode = database !== null; // Initialize @@ -128,6 +140,11 @@ const DatabaseModal: FunctionComponent = ({ }); } + // Validation + useEffect(() => { + validate(); + }); + // Show/hide if (isHidden && show) { setIsHidden(false); @@ -187,6 +204,9 @@ const DatabaseModal: FunctionComponent = ({ placeholder={t('SQLAlchemy URI')} onChange={onInputChange} /> +
{t('Refer to the ')} From fed1592d4fa0d9bb8ce0b6a7330ae6b7682b555d Mon Sep 17 00:00:00 2001 From: riahk Date: Fri, 28 Aug 2020 12:15:37 -0700 Subject: [PATCH 02/20] performance tab --- .../CRUD/data/database/DatabaseModal.tsx | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index 254a83a38f4f9..951209ba7830b 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -24,6 +24,7 @@ import Modal from 'src/common/components/Modal'; import Tabs from 'src/common/components/Tabs'; import { DatabaseObject } from './types'; import Button from 'src/components/Button'; +import IndeterminateCheckbox from 'src/components/IndeterminateCheckbox'; interface DatabaseModalProps { addDangerToast: (msg: string) => void; @@ -46,7 +47,7 @@ const StyledInputContainer = styled.div` display: block; padding: ${({ theme }) => theme.gridUnit}px 0; color: ${({ theme }) => theme.colors.grayscale.light1}; - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.typography.sizes.s - 1}px; text-align: left; .required { @@ -57,10 +58,20 @@ const StyledInputContainer = styled.div` .input-container { display: flex; + align-items: center; + + label { + display: flex; + margin-right: ${({ theme }) => theme.gridUnit * 2}px; + } } - input[type='text'] { + input { flex: 1 1 auto; + } + + input[type='text'], + input[type='number'] { padding: ${({ theme }) => theme.gridUnit * 1.5}px ${({ theme }) => theme.gridUnit * 2}px; border-style: none; @@ -90,6 +101,8 @@ const DatabaseModal: FunctionComponent = ({ const [db, setDB] = useState(null); const [isHidden, setIsHidden] = useState(true); + console.log('db', db); + // Functions const hide = () => { setIsHidden(true); @@ -112,7 +125,11 @@ const DatabaseModal: FunctionComponent = ({ ...db, }; - data[target.name] = target.value; + if (target.type === 'checkbox') { + data[target.name] = target.checked; + } else { + data[target.name] = target.value; + } setDB(data); }; @@ -222,7 +239,36 @@ const DatabaseModal: FunctionComponent = ({ {t('Performance')}} key="2"> - Performance Form Data + +
{t('Chart Cache Timeout')}
+
+ +
+
+ {t( + 'Duration (in seconds) of the caching timeout for charts of this database.', + )} + {t(' A timeout of 0 indicates that the cache never expires.')} + {t(' Note this defaults to the global timeout if undefined.')} +
+
+ +
+ +
{t('Asynchronous Query Execution')}
+
+
{t('SQL Lab Settings')}} key="3"> SQL Lab Settings Form Data From 70feb8dc44382fc650d601b3453a58ffa36192a8 Mon Sep 17 00:00:00 2001 From: riahk Date: Fri, 28 Aug 2020 14:59:48 -0700 Subject: [PATCH 03/20] sql lab, security and extra tabs --- .../CRUD/data/database/DatabaseModal.tsx | 286 +++++++++++++++++- 1 file changed, 282 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index 951209ba7830b..5e42aba1492ce 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -25,6 +25,7 @@ import Tabs from 'src/common/components/Tabs'; import { DatabaseObject } from './types'; import Button from 'src/components/Button'; import IndeterminateCheckbox from 'src/components/IndeterminateCheckbox'; +import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; interface DatabaseModalProps { addDangerToast: (msg: string) => void; @@ -64,12 +65,23 @@ const StyledInputContainer = styled.div` display: flex; margin-right: ${({ theme }) => theme.gridUnit * 2}px; } + + i { + margin: 0 ${({ theme }) => theme.gridUnit}px; + } } - input { + input, + textarea { flex: 1 1 auto; } + textarea { + height: 160px; + resize: none; + } + + textarea, input[type='text'], input[type='number'] { padding: ${({ theme }) => theme.gridUnit * 1.5}px @@ -134,6 +146,18 @@ const DatabaseModal: FunctionComponent = ({ setDB(data); }; + const onTextChange = (event: React.ChangeEvent) => { + const target = event.target; + const data = { + name: db ? db.name : '', + uri: db ? db.uri : '', + ...db, + }; + + data[target.name] = target.value; + setDB(data); + }; + const validate = () => { if (db && db.name.length && db.uri.length) { setDisableSave(false); @@ -267,17 +291,271 @@ const DatabaseModal: FunctionComponent = ({ onChange={onInputChange} />
{t('Asynchronous Query Execution')}
+
{t('SQL Lab Settings')}} key="3"> - SQL Lab Settings Form Data + +
+ +
{t('Expose in SQL Lab')}
+ +
+
+ +
+ +
{t('Allow CREATE TABLE AS')}
+ +
+
+ +
+ +
{t('Allow CREATE VIEW AS')}
+ +
+
+ +
+ +
{t('Allow DML')}
+ +
+
+ +
+ +
{t('Allow Multi Schema Metadata Fetch')}
+ +
+
{t('Security')}} key="4"> - Security Form Data + +
{t('Secure Extra')}
+
+