2022-03-30 13:11:25 +00:00
|
|
|
import React, { useState, useEffect } from "react";
|
|
|
|
|
import styled from "styled-components";
|
2022-12-20 15:10:18 +00:00
|
|
|
import { ActionButton } from "pages/Editor/DataSourceEditor/JSONtoForm";
|
2022-03-30 13:11:25 +00:00
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
|
|
import {
|
|
|
|
|
getEntities,
|
2023-01-03 15:17:25 +00:00
|
|
|
getPluginNameFromId,
|
2022-03-30 13:11:25 +00:00
|
|
|
getPluginTypeFromDatasourceId,
|
|
|
|
|
} from "selectors/entitiesSelector";
|
|
|
|
|
import {
|
|
|
|
|
testDatasource,
|
|
|
|
|
deleteDatasource,
|
|
|
|
|
updateDatasource,
|
|
|
|
|
redirectAuthorizationCode,
|
|
|
|
|
getOAuthAccessToken,
|
2022-12-02 03:06:22 +00:00
|
|
|
setDatasourceViewMode,
|
2022-11-30 05:59:45 +00:00
|
|
|
createDatasourceFromForm,
|
|
|
|
|
toggleSaveActionFlag,
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
filePickerCallbackAction,
|
2022-03-30 13:11:25 +00:00
|
|
|
} from "actions/datasourceActions";
|
|
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
|
|
|
|
import { getCurrentApplicationId } from "selectors/editorSelectors";
|
|
|
|
|
import { useParams, useLocation } from "react-router";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ExplorerURLParams } from "@appsmith/pages/Editor/Explorer/helpers";
|
|
|
|
|
import type { AppState } from "@appsmith/reducers";
|
|
|
|
|
import type { Datasource } from "entities/Datasource";
|
|
|
|
|
import { AuthType, AuthenticationStatus } from "entities/Datasource";
|
2022-03-30 13:11:25 +00:00
|
|
|
import {
|
2022-12-20 15:10:18 +00:00
|
|
|
CONFIRM_CONTEXT_DELETING,
|
2022-03-30 13:11:25 +00:00
|
|
|
OAUTH_AUTHORIZATION_APPSMITH_ERROR,
|
|
|
|
|
OAUTH_AUTHORIZATION_FAILED,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-01-23 03:50:47 +00:00
|
|
|
import { Category, Toaster, Variant } from "design-system-old";
|
2022-03-30 13:11:25 +00:00
|
|
|
import {
|
|
|
|
|
CONTEXT_DELETE,
|
|
|
|
|
CONFIRM_CONTEXT_DELETE,
|
|
|
|
|
createMessage,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
|
|
|
|
import { debounce } from "lodash";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ApiDatasourceForm } from "entities/Datasource/RestAPIForm";
|
2022-11-30 05:59:45 +00:00
|
|
|
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
|
2022-01-14 06:31:54 +00:00
|
|
|
|
2022-12-01 06:30:50 +00:00
|
|
|
import {
|
|
|
|
|
hasDeleteDatasourcePermission,
|
|
|
|
|
hasManageDatasourcePermission,
|
|
|
|
|
} from "@appsmith/utils/permissionHelpers";
|
|
|
|
|
|
2022-01-14 06:31:54 +00:00
|
|
|
interface Props {
|
|
|
|
|
datasource: Datasource;
|
2022-12-20 15:10:18 +00:00
|
|
|
formData: Datasource | ApiDatasourceForm;
|
2022-01-14 06:31:54 +00:00
|
|
|
getSanitizedFormData: () => Datasource;
|
|
|
|
|
isInvalid: boolean;
|
2022-03-17 10:28:54 +00:00
|
|
|
pageId?: string;
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldRender?: boolean;
|
2022-03-30 13:11:25 +00:00
|
|
|
datasourceButtonConfiguration: string[] | undefined;
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldDisplayAuthMessage?: boolean;
|
2022-11-30 05:59:45 +00:00
|
|
|
triggerSave?: boolean;
|
|
|
|
|
isFormDirty?: boolean;
|
|
|
|
|
datasourceDeleteTrigger: () => void;
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
gsheetToken?: string;
|
2023-03-21 07:23:05 +00:00
|
|
|
gsheetProjectID?: string;
|
2022-01-14 06:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
export type DatasourceFormButtonTypes = Record<string, string[]>;
|
|
|
|
|
|
|
|
|
|
enum AuthorizationStatus {
|
|
|
|
|
SUCCESS = "success",
|
|
|
|
|
APPSMITH_ERROR = "appsmith_error",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum DatasourceButtonTypeEnum {
|
|
|
|
|
DELETE = "DELETE",
|
|
|
|
|
SAVE = "SAVE",
|
|
|
|
|
TEST = "TEST",
|
|
|
|
|
SAVE_AND_AUTHORIZE = "SAVE_AND_AUTHORIZE",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DatasourceButtonType: Record<
|
|
|
|
|
keyof typeof DatasourceButtonTypeEnum,
|
|
|
|
|
string
|
|
|
|
|
> = {
|
|
|
|
|
DELETE: "DELETE",
|
|
|
|
|
SAVE: "SAVE",
|
|
|
|
|
TEST: "TEST",
|
|
|
|
|
SAVE_AND_AUTHORIZE: "SAVE_AND_AUTHORIZE",
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-30 05:59:45 +00:00
|
|
|
const StyledButton = styled(ActionButton)<{ fluidWidth?: boolean }>`
|
2022-03-30 13:11:25 +00:00
|
|
|
&&&& {
|
|
|
|
|
height: 32px;
|
|
|
|
|
width: ${(props) => (props.fluidWidth ? "" : "87px")};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2022-12-20 15:10:18 +00:00
|
|
|
const SaveButtonContainer = styled.div`
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
`;
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
const StyledAuthMessage = styled.div`
|
|
|
|
|
color: ${(props) => props.theme.colors.error};
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
&:after {
|
|
|
|
|
content: " *";
|
|
|
|
|
color: inherit;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-14 06:31:54 +00:00
|
|
|
function DatasourceAuth({
|
|
|
|
|
datasource,
|
2022-03-30 13:11:25 +00:00
|
|
|
datasourceButtonConfiguration = ["DELETE", "SAVE"],
|
2022-11-30 05:59:45 +00:00
|
|
|
datasourceDeleteTrigger,
|
2022-01-14 06:31:54 +00:00
|
|
|
formData,
|
|
|
|
|
getSanitizedFormData,
|
|
|
|
|
isInvalid,
|
2022-03-30 13:11:25 +00:00
|
|
|
pageId: pageIdProp,
|
2022-01-14 06:31:54 +00:00
|
|
|
shouldRender,
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldDisplayAuthMessage = true,
|
2022-11-30 05:59:45 +00:00
|
|
|
triggerSave,
|
|
|
|
|
isFormDirty,
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
gsheetToken,
|
2023-03-21 07:23:05 +00:00
|
|
|
gsheetProjectID,
|
2022-01-14 06:31:54 +00:00
|
|
|
}: Props) {
|
|
|
|
|
const authType =
|
2022-12-20 15:10:18 +00:00
|
|
|
formData && "authType" in formData
|
|
|
|
|
? formData?.authType
|
|
|
|
|
: formData?.datasourceConfiguration?.authentication?.authenticationType;
|
2022-03-30 13:11:25 +00:00
|
|
|
|
2023-01-03 15:17:25 +00:00
|
|
|
const { id: datasourceId, isDeleting, pluginId } = datasource;
|
2022-03-30 13:11:25 +00:00
|
|
|
const applicationId = useSelector(getCurrentApplicationId);
|
2023-01-03 15:17:25 +00:00
|
|
|
const pluginName = useSelector((state: AppState) =>
|
|
|
|
|
getPluginNameFromId(state, pluginId),
|
|
|
|
|
);
|
2022-03-30 13:11:25 +00:00
|
|
|
|
2022-12-01 06:30:50 +00:00
|
|
|
const datasourcePermissions = datasource.userPermissions || [];
|
|
|
|
|
|
|
|
|
|
const canManageDatasource = hasManageDatasourcePermission(
|
|
|
|
|
datasourcePermissions,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const canDeleteDatasource = hasDeleteDatasourcePermission(
|
|
|
|
|
datasourcePermissions,
|
|
|
|
|
);
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
// hooks
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const { pageId: pageIdQuery } = useParams<ExplorerURLParams>();
|
|
|
|
|
|
|
|
|
|
const pageId = (pageIdQuery || pageIdProp) as string;
|
|
|
|
|
const [confirmDelete, setConfirmDelete] = useState(false);
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
|
|
|
|
|
const [scriptLoadedFlag] = useState<boolean>(
|
|
|
|
|
(window as any).googleAPIsLoaded,
|
|
|
|
|
);
|
|
|
|
|
const [pickerInitiated, setPickerInitiated] = useState<boolean>(false);
|
2023-01-03 15:17:25 +00:00
|
|
|
const dsName = datasource?.name;
|
|
|
|
|
const orgId = datasource?.workspaceId;
|
2022-03-30 13:11:25 +00:00
|
|
|
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
// objects gapi and google are set, when google apis script is loaded
|
|
|
|
|
const gapi: any = (window as any).gapi;
|
|
|
|
|
const google: any = (window as any).google;
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (confirmDelete) {
|
|
|
|
|
delayConfirmDeleteToFalse();
|
|
|
|
|
}
|
|
|
|
|
}, [confirmDelete]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (authType === AuthType.OAUTH2) {
|
|
|
|
|
// When the authorization server redirects a user to the datasource form page, the url contains the "response_status" query parameter .
|
|
|
|
|
// Get the access token if response_status is successful else show a toast error
|
|
|
|
|
|
|
|
|
|
const search = new URLSearchParams(location.search);
|
|
|
|
|
const status = search.get("response_status");
|
|
|
|
|
const queryIsImport = search.get("importForGit");
|
|
|
|
|
const queryDatasourceId = search.get("datasourceId");
|
|
|
|
|
const shouldNotify =
|
|
|
|
|
!queryIsImport || (queryIsImport && queryDatasourceId === datasourceId);
|
|
|
|
|
if (status && shouldNotify) {
|
|
|
|
|
const display_message = search.get("display_message");
|
|
|
|
|
const variant = Variant.danger;
|
|
|
|
|
|
|
|
|
|
if (status !== AuthorizationStatus.SUCCESS) {
|
|
|
|
|
const message =
|
|
|
|
|
status === AuthorizationStatus.APPSMITH_ERROR
|
|
|
|
|
? OAUTH_AUTHORIZATION_APPSMITH_ERROR
|
|
|
|
|
: OAUTH_AUTHORIZATION_FAILED;
|
|
|
|
|
Toaster.show({ text: display_message || message, variant });
|
2023-01-03 15:17:25 +00:00
|
|
|
const oAuthStatus = status;
|
|
|
|
|
AnalyticsUtil.logEvent("UPDATE_DATASOURCE", {
|
|
|
|
|
dsName,
|
|
|
|
|
oAuthStatus,
|
|
|
|
|
orgId,
|
|
|
|
|
pluginName,
|
|
|
|
|
});
|
2022-03-30 13:11:25 +00:00
|
|
|
} else {
|
|
|
|
|
dispatch(getOAuthAccessToken(datasourceId));
|
|
|
|
|
}
|
|
|
|
|
AnalyticsUtil.logEvent("DATASOURCE_AUTH_COMPLETE", {
|
|
|
|
|
applicationId,
|
|
|
|
|
datasourceId,
|
|
|
|
|
pageId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [authType]);
|
|
|
|
|
|
|
|
|
|
// selectors
|
|
|
|
|
const {
|
2022-11-04 05:55:25 +00:00
|
|
|
datasources: { isTesting, loading: isSaving },
|
2022-03-30 13:11:25 +00:00
|
|
|
} = useSelector(getEntities);
|
|
|
|
|
|
2022-10-19 10:34:12 +00:00
|
|
|
const delayConfirmDeleteToFalse = debounce(
|
|
|
|
|
() => setConfirmDelete(false),
|
|
|
|
|
2200,
|
|
|
|
|
);
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
const pluginType = useSelector((state: AppState) =>
|
|
|
|
|
getPluginTypeFromDatasourceId(state, datasourceId),
|
|
|
|
|
);
|
|
|
|
|
|
2022-11-30 05:59:45 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (triggerSave) {
|
|
|
|
|
if (pluginType === "SAAS") {
|
|
|
|
|
handleOauthDatasourceSave();
|
|
|
|
|
} else {
|
|
|
|
|
handleDefaultAuthDatasourceSave();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [triggerSave]);
|
2022-03-30 13:11:25 +00:00
|
|
|
|
|
|
|
|
const isAuthorized =
|
|
|
|
|
datasource?.datasourceConfiguration?.authentication
|
|
|
|
|
?.authenticationStatus === AuthenticationStatus.SUCCESS;
|
|
|
|
|
|
|
|
|
|
// Button Operations for respective buttons.
|
|
|
|
|
|
|
|
|
|
// Handles datasource deletion
|
|
|
|
|
const handleDatasourceDelete = () => {
|
|
|
|
|
dispatch(deleteDatasource({ id: datasourceId }));
|
2022-11-30 05:59:45 +00:00
|
|
|
datasourceDeleteTrigger();
|
2022-03-30 13:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handles datasource testing
|
|
|
|
|
const handleDatasourceTest = () => {
|
|
|
|
|
AnalyticsUtil.logEvent("TEST_DATA_SOURCE_CLICK", {
|
|
|
|
|
pageId: pageId,
|
|
|
|
|
appId: applicationId,
|
|
|
|
|
});
|
|
|
|
|
dispatch(testDatasource(getSanitizedFormData()));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handles default auth datasource saving
|
|
|
|
|
const handleDefaultAuthDatasourceSave = () => {
|
2022-11-30 05:59:45 +00:00
|
|
|
dispatch(toggleSaveActionFlag(true));
|
2022-03-30 13:11:25 +00:00
|
|
|
AnalyticsUtil.logEvent("SAVE_DATA_SOURCE_CLICK", {
|
|
|
|
|
pageId: pageId,
|
|
|
|
|
appId: applicationId,
|
|
|
|
|
});
|
|
|
|
|
// After saving datasource, only redirect to the 'new integrations' page
|
|
|
|
|
// if datasource is not used to generate a page
|
2022-11-30 05:59:45 +00:00
|
|
|
if (datasource.id === TEMP_DATASOURCE_ID) {
|
|
|
|
|
dispatch(createDatasourceFromForm(getSanitizedFormData()));
|
|
|
|
|
} else {
|
2022-12-02 03:06:22 +00:00
|
|
|
dispatch(setDatasourceViewMode(true));
|
2022-11-30 05:59:45 +00:00
|
|
|
// we dont need to redirect it to active ds list instead ds would be shown in view only mode
|
|
|
|
|
dispatch(updateDatasource(getSanitizedFormData()));
|
|
|
|
|
}
|
2022-03-30 13:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handles Oauth datasource saving
|
|
|
|
|
const handleOauthDatasourceSave = () => {
|
2022-11-30 05:59:45 +00:00
|
|
|
dispatch(toggleSaveActionFlag(true));
|
|
|
|
|
if (datasource.id === TEMP_DATASOURCE_ID) {
|
|
|
|
|
dispatch(
|
|
|
|
|
createDatasourceFromForm(
|
|
|
|
|
getSanitizedFormData(),
|
|
|
|
|
pluginType
|
|
|
|
|
? redirectAuthorizationCode(pageId, datasourceId, pluginType)
|
|
|
|
|
: undefined,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2022-12-02 03:06:22 +00:00
|
|
|
dispatch(setDatasourceViewMode(true));
|
2022-11-30 05:59:45 +00:00
|
|
|
dispatch(
|
|
|
|
|
updateDatasource(
|
|
|
|
|
getSanitizedFormData(),
|
|
|
|
|
pluginType
|
|
|
|
|
? redirectAuthorizationCode(pageId, datasourceId, pluginType)
|
|
|
|
|
: undefined,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-03-30 13:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
// This loads the picker object in gapi script
|
2023-03-21 07:23:05 +00:00
|
|
|
if (!!gsheetToken && !!gapi && !!gsheetProjectID) {
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
gapi.load("client:picker", async () => {
|
|
|
|
|
await gapi.client.load(
|
|
|
|
|
"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest",
|
|
|
|
|
);
|
|
|
|
|
setPickerInitiated(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-21 07:23:05 +00:00
|
|
|
}, [scriptLoadedFlag, gsheetToken, gsheetProjectID]);
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-03-21 07:23:05 +00:00
|
|
|
if (
|
|
|
|
|
!!gsheetToken &&
|
|
|
|
|
scriptLoadedFlag &&
|
|
|
|
|
pickerInitiated &&
|
|
|
|
|
!!google &&
|
|
|
|
|
!!gsheetProjectID
|
|
|
|
|
) {
|
|
|
|
|
createPicker(gsheetToken, gsheetProjectID);
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
}
|
2023-03-21 07:23:05 +00:00
|
|
|
}, [gsheetToken, scriptLoadedFlag, pickerInitiated, gsheetProjectID]);
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
|
2023-03-21 07:23:05 +00:00
|
|
|
const createPicker = async (accessToken: string, projectID: string) => {
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
const view = new google.picker.View(google.picker.ViewId.SPREADSHEETS);
|
|
|
|
|
view.setMimeTypes("application/vnd.google-apps.spreadsheet");
|
|
|
|
|
const picker = new google.picker.PickerBuilder()
|
|
|
|
|
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
|
|
|
|
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
|
2023-03-21 07:23:05 +00:00
|
|
|
.setAppId(projectID)
|
feat: file picker added and access token generation (#20778)
## Description
This PR includes following changes:
- In case of limiting google sheet access project, when user selects specific sheets as an option, they should be shown file picker UI once the authorisation is complete, In this file picker UI, users can select the google sheet files that they want to use with appsmith application and allow access to only those files.
- This PR contains the changes for file picker UI and updating datasource auth state based on the files selected by user.
TL;DR
Steps to test this PR:
- Create Google Sheet datasource
- In the datasource config form, select specific sheets as an option from the scope dropdown.
- Click on save and authorise
- This will take you to google oauth process
<img width="467" alt="Screenshot 2023-02-20 at 1 24 24 PM" src="https://user-images.githubusercontent.com/30018882/220045493-57b0ca6c-3f08-4963-af55-d603cf79bc43.png">
- Select the google account
- This will take you to google oauth2 consent screen
<img width="451" alt="Screenshot 2023-02-20 at 1 24 55 PM" src="https://user-images.githubusercontent.com/30018882/220045641-9f70dd29-6664-489a-b77b-df65445491df.png">
- Click on allow for all requested permissions
- This will take you back to appsmith's datasource config page in view mode and load the file picker UI
<img width="425" alt="Screenshot 2023-02-20 at 1 25 47 PM" src="https://user-images.githubusercontent.com/30018882/220045828-8b3e3e46-4ddc-4e30-b2f8-f12865395817.png">
- Select the files that you want to share with appsmith app
- Click on select
- You should see the new query button in enabled state, as datasource authorisation is complete
<img width="800" alt="Screenshot 2023-02-20 at 1 27 28 PM" src="https://user-images.githubusercontent.com/30018882/220046131-6ce99a85-cddc-4529-ae45-f9833aefd71b.png">
- In case you select cancel on google oauth2 consent screen, you should error message on datasource config page with new query button being disabled
<img width="810" alt="Screenshot 2023-02-20 at 1 28 49 PM" src="https://user-images.githubusercontent.com/30018882/220046385-6b8d636c-b517-44c3-a596-b52bc0084b94.png">
- In case you do give all the permissions but do not select any files in google file picker, then also you should see error message on datasource config page with new query button disabled.
Fixes #20163, #20290, #20160, #20162
Media
> A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video
## Type of change
> Please delete options that are not relevant.
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or manual QA
- [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-03-08 05:25:17 +00:00
|
|
|
.setOAuthToken(accessToken)
|
|
|
|
|
.addView(view)
|
|
|
|
|
.setCallback(pickerCallback)
|
|
|
|
|
.build();
|
|
|
|
|
picker.setVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const pickerCallback = async (data: any) => {
|
|
|
|
|
dispatch(
|
|
|
|
|
filePickerCallbackAction({
|
|
|
|
|
action: data.action,
|
|
|
|
|
datasourceId: datasourceId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-02 12:35:18 +00:00
|
|
|
const createMode = datasourceId === TEMP_DATASOURCE_ID;
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
const datasourceButtonsComponentMap = (buttonType: string): JSX.Element => {
|
|
|
|
|
return {
|
|
|
|
|
[DatasourceButtonType.DELETE]: (
|
|
|
|
|
<ActionButton
|
2022-11-30 05:59:45 +00:00
|
|
|
category={Category.primary}
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--delete-datasource"
|
2022-12-02 12:35:18 +00:00
|
|
|
disabled={createMode || !canDeleteDatasource}
|
2022-12-11 12:51:52 +00:00
|
|
|
isLoading={isDeleting}
|
2022-11-30 05:59:45 +00:00
|
|
|
key={buttonType}
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={() => {
|
2022-12-20 15:10:18 +00:00
|
|
|
if (!isDeleting) {
|
|
|
|
|
confirmDelete ? handleDatasourceDelete() : setConfirmDelete(true);
|
|
|
|
|
}
|
2022-03-30 13:11:25 +00:00
|
|
|
}}
|
2022-11-30 05:59:45 +00:00
|
|
|
size="medium"
|
|
|
|
|
tag="button"
|
2022-03-30 13:11:25 +00:00
|
|
|
text={
|
2022-12-20 15:10:18 +00:00
|
|
|
isDeleting
|
|
|
|
|
? createMessage(CONFIRM_CONTEXT_DELETING)
|
|
|
|
|
: confirmDelete
|
2022-03-30 13:11:25 +00:00
|
|
|
? createMessage(CONFIRM_CONTEXT_DELETE)
|
|
|
|
|
: createMessage(CONTEXT_DELETE)
|
|
|
|
|
}
|
2022-11-30 05:59:45 +00:00
|
|
|
variant={Variant.danger}
|
2022-01-14 06:31:54 +00:00
|
|
|
/>
|
2022-03-30 13:11:25 +00:00
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.TEST]: (
|
|
|
|
|
<ActionButton
|
2022-11-30 05:59:45 +00:00
|
|
|
category={Category.secondary}
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--test-datasource"
|
2022-11-30 05:59:45 +00:00
|
|
|
isLoading={isTesting}
|
|
|
|
|
key={buttonType}
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={handleDatasourceTest}
|
2022-11-30 05:59:45 +00:00
|
|
|
size="medium"
|
2022-12-01 06:30:50 +00:00
|
|
|
tag="button"
|
2022-03-30 13:11:25 +00:00
|
|
|
text="Test"
|
2022-11-30 05:59:45 +00:00
|
|
|
variant={Variant.success}
|
2022-01-14 06:31:54 +00:00
|
|
|
/>
|
2022-03-30 13:11:25 +00:00
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.SAVE]: (
|
2022-11-30 05:59:45 +00:00
|
|
|
<ActionButton
|
|
|
|
|
category={Category.primary}
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--save-datasource"
|
2022-12-02 12:35:18 +00:00
|
|
|
disabled={
|
|
|
|
|
isInvalid || !isFormDirty || (!createMode && !canManageDatasource)
|
|
|
|
|
}
|
2022-12-01 06:30:50 +00:00
|
|
|
filled
|
2022-12-11 12:51:52 +00:00
|
|
|
isLoading={isSaving}
|
2022-11-30 05:59:45 +00:00
|
|
|
key={buttonType}
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={handleDefaultAuthDatasourceSave}
|
2022-11-30 05:59:45 +00:00
|
|
|
size="medium"
|
|
|
|
|
tag="button"
|
2022-03-30 13:11:25 +00:00
|
|
|
text="Save"
|
2022-11-30 05:59:45 +00:00
|
|
|
variant={Variant.success}
|
2022-01-14 06:31:54 +00:00
|
|
|
/>
|
2022-03-30 13:11:25 +00:00
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.SAVE_AND_AUTHORIZE]: (
|
|
|
|
|
<StyledButton
|
2022-11-30 05:59:45 +00:00
|
|
|
category={Category.primary}
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--save-datasource"
|
2022-12-02 12:35:18 +00:00
|
|
|
disabled={isInvalid || (!createMode && !canManageDatasource)}
|
2022-12-01 06:30:50 +00:00
|
|
|
filled
|
2022-03-30 13:11:25 +00:00
|
|
|
fluidWidth
|
2022-11-30 05:59:45 +00:00
|
|
|
isLoading={isSaving}
|
|
|
|
|
key={buttonType}
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={handleOauthDatasourceSave}
|
2022-11-30 05:59:45 +00:00
|
|
|
size="medium"
|
|
|
|
|
tag="button"
|
2022-12-22 12:18:45 +00:00
|
|
|
text="Save and Authorize"
|
2022-11-30 05:59:45 +00:00
|
|
|
variant={Variant.success}
|
2022-03-30 13:11:25 +00:00
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
}[buttonType];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2022-12-20 15:10:18 +00:00
|
|
|
{authType === AuthType.OAUTH2 &&
|
|
|
|
|
!isAuthorized &&
|
|
|
|
|
shouldDisplayAuthMessage && (
|
|
|
|
|
<StyledAuthMessage>Datasource not authorized</StyledAuthMessage>
|
|
|
|
|
)}
|
2022-03-30 13:11:25 +00:00
|
|
|
{shouldRender && (
|
|
|
|
|
<SaveButtonContainer>
|
|
|
|
|
{datasourceButtonConfiguration?.map((btnConfig) =>
|
|
|
|
|
datasourceButtonsComponentMap(btnConfig),
|
|
|
|
|
)}
|
|
|
|
|
</SaveButtonContainer>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2022-01-14 06:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DatasourceAuth;
|