Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dbc ui): Adding Google Sheets Dynamic Form #15801

Merged
merged 63 commits into from Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
accb48e
feat: Make Google Sheets Dyanmic (#15576)
AAfghahi Jul 8, 2021
eb5f607
first draft
AAfghahi Jul 8, 2021
459eba3
added table_catalog
AAfghahi Jul 9, 2021
9aba8fc
remove console.log
hughhhh Jul 12, 2021
6b30f79
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
AAfghahi Jul 13, 2021
962e597
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/i…
AAfghahi Jul 13, 2021
0e4f249
revisions
AAfghahi Jul 13, 2021
84222b2
revisions
AAfghahi Jul 13, 2021
4b466ad
save this for now
hughhhh Jul 14, 2021
aa65132
working form
hughhhh Jul 15, 2021
5594a3b
Merge branch 'pexdax/improved-sheets' of https://github.com/apache/su…
hughhhh Jul 15, 2021
bd089fb
Merge branch 'pexdax/improved-sheets' of https://github.com/apache/su…
hughhhh Jul 15, 2021
fca0ca8
save disable on public sheets
hughhhh Jul 16, 2021
640ecab
refactor somethings
hughhhh Jul 19, 2021
e951350
saving this for now
hughhhh Jul 19, 2021
4714264
working edit
hughhhh Jul 20, 2021
ce0c894
add back query to schema
hughhhh Jul 20, 2021
afcab7c
working add
hughhhh Jul 20, 2021
a30b0d8
fix styling
hughhhh Jul 20, 2021
bdcaf2b
fixing x
hughhhh Jul 20, 2021
1b73a07
fix linting
hughhhh Jul 20, 2021
cd8f7c6
prettier
hughhhh Jul 20, 2021
1e020f9
fix some type issues
hughhhh Jul 20, 2021
ee9a363
more lint fixes
hughhhh Jul 20, 2021
e7e8819
Merge branch 'master' of https://github.com/apache/superset into hugh…
hughhhh Jul 21, 2021
cbd43b3
remove unused dependency
hughhhh Jul 21, 2021
54186da
fix linint
hughhhh Jul 21, 2021
630dcb1
fix validation
hughhhh Jul 21, 2021
58a36f0
pylint bypass
hughhhh Jul 21, 2021
9fa5123
pylint bypass
hughhhh Jul 21, 2021
e84e107
fix this
hughhhh Jul 21, 2021
1e23812
fix mypy
hughhhh Jul 21, 2021
ce67725
yerp
hughhhh Jul 21, 2021
21cd296
fix test
hughhhh Jul 21, 2021
de70f64
fix test
hughhhh Jul 21, 2021
0640403
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/i…
hughhhh Jul 21, 2021
a122eb4
fix merge conflict
hughhhh Jul 22, 2021
259c31c
Merge branch 'hugh/gsheets-public' of https://github.com/apache/super…
hughhhh Jul 22, 2021
c18ae26
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
03a713a
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
3d6c410
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
1c34b12
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
9028f5a
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
22f495e
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/D…
hughhhh Jul 22, 2021
d8c1673
wrap add sheets
hughhhh Jul 22, 2021
319ef6c
fix linting issues
hughhhh Jul 22, 2021
bcbc992
fix unit test
hughhhh Jul 22, 2021
cc3dc6f
ignore typing
hughhhh Jul 22, 2021
a3b65fd
fix editting and paste issues
hughhhh Jul 22, 2021
0121617
remove query
hughhhh Jul 24, 2021
c24e074
fix this
hughhhh Jul 25, 2021
29deada
fix test
hughhhh Jul 25, 2021
92f473b
add test back
hughhhh Jul 26, 2021
4363d60
Merge branch 'master' of https://github.com/apache/superset into hugh…
hughhhh Jul 26, 2021
30fc76e
fix error messaging
hughhhh Jul 27, 2021
7c59782
update url messaging on error
hughhhh Jul 27, 2021
53c365b
change error type
hughhhh Jul 27, 2021
90d7268
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/i…
hughhhh Jul 28, 2021
eed363b
add errors for sheets with no name
hughhhh Jul 28, 2021
84621fa
fix
hughhhh Jul 28, 2021
e988d38
fix messaging for gsheets
hughhhh Jul 28, 2021
c71de88
stop pylint
hughhhh Jul 28, 2021
451c533
update line
hughhhh Jul 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,19 +19,21 @@
import React, { FormEvent, useState } from 'react';
import { SupersetTheme, JsonObject, t } from '@superset-ui/core';
import { InputProps } from 'antd/lib/input';
import { Switch, Select, Button } from 'src/common/components';
import { Input, Switch, Select, Button } from 'src/common/components';
import InfoTooltip from 'src/components/InfoTooltip';
import ValidatedInput from 'src/components/Form/LabeledErrorBoundInput';
import FormLabel from 'src/components/Form/FormLabel';
import { DeleteFilled } from '@ant-design/icons';
import { DeleteFilled, CloseOutlined } from '@ant-design/icons';
import {
formScrollableStyles,
validatedFormStyles,
CredentialInfoForm,
toggleStyle,
infoTooltip,
StyledFooterButton,
StyledCatalogTable,
} from './styles';
import { DatabaseForm, DatabaseObject } from '../types';
import { CatalogObject, DatabaseForm, DatabaseObject } from '../types';

enum CredentialInfoOptions {
jsonUpload,
Expand All @@ -46,6 +48,7 @@ export const FormFieldOrder = [
'password',
'database_name',
'credentials_info',
'catalog',
'query',
'encryption',
];
Expand All @@ -58,7 +61,10 @@ interface FieldPropTypes {
onParametersUploadFileChange: (value: any) => string;
changeMethods: { onParametersChange: (value: any) => string } & {
onChange: (value: any) => string;
} & { onParametersUploadFileChange: (value: any) => string };
} & { onParametersUploadFileChange: (value: any) => string } & {
onAddTableCatalog: () => void;
onRemoveTableCatalog: (idx: number) => void;
};
validationErrors: JsonObject | null;
getValidation: () => void;
db?: DatabaseObject;
Expand Down Expand Up @@ -187,6 +193,89 @@ const CredentialsInfo = ({
);
};

const TableCatalog = ({
required,
changeMethods,
getValidation,
validationErrors,
db,
}: FieldPropTypes) => {
const tableCatalog = db?.catalog || [];
const catalogError = validationErrors || {};
return (
<StyledCatalogTable>
<div className="catalog-type-select">
<FormLabel required>{t('Type of Google Sheets Allowed')}</FormLabel>
<Select style={{ width: '100%' }} defaultValue="true" disabled>
<Select.Option value="true" key={1}>
{t('Publicly shared sheets only')}
</Select.Option>
</Select>
</div>
<h4 className="gsheet-title">
{t('Connect Google Sheets as tables to this database')}
</h4>
<div>
{tableCatalog?.map((sheet: CatalogObject, idx: number) => (
<>
<FormLabel className="catalog-label" required>
{t('Google Sheet Name and URL')}
</FormLabel>
<div className="catalog-name">
<Input
className="catalog-name-input"
placeholder={t('Enter a name for this sheet')}
onChange={e => {
changeMethods.onParametersChange({
target: {
type: `catalog-${idx}`,
name: 'name',
value: e.target.value,
},
});
}}
value={sheet.name}
/>

{tableCatalog?.length > 1 && (
<CloseOutlined
className="catalog-delete"
onClick={() => changeMethods.onRemoveTableCatalog(idx)}
/>
)}
</div>
<ValidatedInput
className="catalog-name-url"
required={required}
validationMethods={{ onBlur: getValidation }}
errorMessage={catalogError[sheet.name]}
placeholder={t('Paste the shareable Google Sheet URL here')}
onChange={(e: { target: { value: any } }) =>
changeMethods.onParametersChange({
target: {
type: `catalog-${idx}`,
name: 'value',
value: e.target.value,
},
})
}
value={sheet.value}
/>
</>
))}
<StyledFooterButton
className="catalog-add-btn"
onClick={() => {
changeMethods.onAddTableCatalog();
}}
>
+ {t('Add sheet')}
</StyledFooterButton>
</div>
</StyledCatalogTable>
);
};

const hostField = ({
required,
changeMethods,
Expand Down Expand Up @@ -300,18 +389,22 @@ const displayField = ({
validationErrors,
db,
}: FieldPropTypes) => (
<ValidatedInput
id="database_name"
name="database_name"
required
value={db?.database_name}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.database_name}
placeholder=""
label="Display Name"
onChange={changeMethods.onChange}
helpText={t('Pick a nickname for this database to display as in Superset.')}
/>
<>
<ValidatedInput
id="database_name"
name="database_name"
required
value={db?.database_name}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.database_name}
placeholder=""
label={t('Display Name')}
onChange={changeMethods.onChange}
helpText={t(
'Pick a nickname for this database to display as in Superset.',
)}
/>
</>
);

const queryField = ({
Expand Down Expand Up @@ -375,13 +468,16 @@ const FORM_FIELD_MAP = {
query: queryField,
encryption: forceSSLField,
credentials_info: CredentialsInfo,
catalog: TableCatalog,
};

const DatabaseConnectionForm = ({
dbModel: { parameters },
onParametersChange,
onChange,
onParametersUploadFileChange,
onAddTableCatalog,
onRemoveTableCatalog,
validationErrors,
getValidation,
db,
Expand All @@ -403,6 +499,8 @@ const DatabaseConnectionForm = ({
onParametersUploadFileChange?: (
event: FormEvent<InputProps> | { target: HTMLInputElement },
) => void;
onAddTableCatalog: () => void;
onRemoveTableCatalog: (idx: number) => void;
validationErrors: JsonObject | null;
getValidation: () => void;
}) => (
Expand All @@ -426,6 +524,8 @@ const DatabaseConnectionForm = ({
onParametersChange,
onChange,
onParametersUploadFileChange,
onAddTableCatalog,
onRemoveTableCatalog,
},
validationErrors,
getValidation,
Expand Down