You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/06/16 02:03:29 UTC
[superset] branch hugh/big-query-edit created (now 761f696)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a change to branch hugh/big-query-edit
in repository https://gitbox.apache.org/repos/asf/superset.git.
at 761f696 working big query edits
This branch includes the following new commits:
new 761f696 working big query edits
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: working big query edits
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch hugh/big-query-edit
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 761f69690409f8ffdd92511af6264d9c34519bbf
Author: hughhhh <hu...@gmail.com>
AuthorDate: Tue Jun 15 22:01:52 2021 -0400
working big query edits
---
.../DatabaseModal/DatabaseConnectionForm.tsx | 44 +++++++++++++---------
.../CRUD/data/database/DatabaseModal/index.tsx | 9 ++++-
2 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
index 0906a6c..27bff7c 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx
@@ -65,32 +65,40 @@ interface FieldPropTypes {
sslForced?: boolean;
}
-const CredentialsInfo = ({ changeMethods }: FieldPropTypes) => {
- const [uploadOption, setUploadOption] = useState<number>(0);
+const CredentialsInfo = ({ changeMethods, isEditMode, db }: FieldPropTypes) => {
+ const [uploadOption, setUploadOption] = useState<number>(1);
const [fileToUpload, setFileToUpload] = useState<string | null | undefined>(
null,
);
return (
<CredentialInfoForm>
- <span className="label-select">
- How do you want to enter service account credentials?
- </span>
- <Select
- defaultValue={CredentialInfoOptions.jsonUpload}
- style={{ width: '100%' }}
- onChange={option => setUploadOption(option)}
- >
- <Select.Option value={CredentialInfoOptions.jsonUpload}>
- Upload JSON file
- </Select.Option>
- <Select.Option value={CredentialInfoOptions.copyPaste}>
- Copy and Paste JSON credentials
- </Select.Option>
- </Select>
+ {!isEditMode && (
+ <>
+ <span className="label-select">
+ How do you want to enter service account credentials?
+ </span>
+ <Select
+ style={{ width: '100%' }}
+ onChange={option => setUploadOption(option)}
+ >
+ <Select.Option value={CredentialInfoOptions.jsonUpload}>
+ Upload JSON file
+ </Select.Option>
+
+ <Select.Option value={CredentialInfoOptions.copyPaste}>
+ Copy and Paste JSON credentials
+ </Select.Option>
+ </Select>
+ </>
+ )}
{uploadOption === CredentialInfoOptions.copyPaste ? (
<div className="input-container" onChange={changeMethods.onChange}>
<span className="label-select">Service Account</span>
- <textarea className="input-form" name="encrypted_extra" />
+ <textarea
+ className="input-form"
+ name="encrypted_extra"
+ value={db?.parameters?.credentials_info}
+ />
<span className="label-paste">
Copy and paste the entire service account .json file here
</span>
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 eb94df8..ea0bb59 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -229,6 +229,13 @@ function dbReducer(
).toString();
}
+ if (action.payload?.parameters?.credentials_info) {
+ // deserialize credentials info for big query editting
+ action.payload.parameters.credentials_info = JSON.stringify(
+ action.payload?.parameters.credentials_info,
+ );
+ }
+
return {
...action.payload,
engine: trimmedState.engine,
@@ -299,7 +306,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
availableDbs?.databases?.find(
(available: { engine: string | undefined }) =>
// TODO: we need a centralized engine in one place
- available.engine === db?.engine || db?.backend,
+ available.engine === db?.backend || db?.engine,
) || {};
// Test Connection logic