2023-05-22 12:05:59 +00:00
|
|
|
import React, { useEffect } from "react";
|
2022-03-30 13:11:25 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
|
|
import {
|
|
|
|
|
testDatasource,
|
|
|
|
|
updateDatasource,
|
|
|
|
|
redirectAuthorizationCode,
|
|
|
|
|
getOAuthAccessToken,
|
2022-11-30 05:59:45 +00:00
|
|
|
createDatasourceFromForm,
|
|
|
|
|
toggleSaveActionFlag,
|
fix: gs authorisation status updates (#23890)
## Description
This PR fixes inconsistencies in the authenticationStatus property for
google sheets:
- In case of google sheets datasource, when we authorise the datasource,
but do not grant permissions, the authenticationStatus is being saved as
`IN_PROGRESS`, instead it should be `FAILURE` as user failed to give
permissions.
- This PR adds 3 new statuses in AuthenticationStatus Enum,
`IN_PROGRESS_PERMISSIONS_GRANTED`, `FAILURE_ACCESS_DENIED` and
`FAILURE_NO_FILES_SELECTED`.
- `IN_PROGRESS_PERMISSIONS_GRANTED` is used in case of specific sheets
scope, so that we would know that users have granted permissions and
selection of files is pending
- `FAILURE_ACCESS_DENIED` denotes, for any of the scope, if user does
not grant permissions.
- `FAILURE_NO_FILES_SELECTED` denotes, for specific scope, if user
grants permissions but files have not been selected yet.
#### PR fixes following issue(s)
Fixes #23877
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### 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.
- Bug fix (non-breaking change which fixes an issue)
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] 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
- [ ] PR is being merged under a feature flag
#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [x] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-06-02 06:28:46 +00:00
|
|
|
updateDatasourceAuthState,
|
2022-03-30 13:11:25 +00:00
|
|
|
} from "actions/datasourceActions";
|
|
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
|
|
|
|
import { getCurrentApplicationId } from "selectors/editorSelectors";
|
2023-05-29 05:40:41 +00:00
|
|
|
import { useParams, useLocation, useHistory } 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 { Datasource } from "entities/Datasource";
|
|
|
|
|
import { AuthType, AuthenticationStatus } from "entities/Datasource";
|
2022-03-30 13:11:25 +00:00
|
|
|
import {
|
2023-05-22 12:05:59 +00:00
|
|
|
CANCEL,
|
2022-03-30 13:11:25 +00:00
|
|
|
OAUTH_AUTHORIZATION_APPSMITH_ERROR,
|
|
|
|
|
OAUTH_AUTHORIZATION_FAILED,
|
2023-05-22 12:05:59 +00:00
|
|
|
SAVE_AND_AUTHORIZE_BUTTON_TEXT,
|
2023-09-12 06:18:58 +00:00
|
|
|
SAVE_AND_RE_AUTHORIZE_BUTTON_TEXT,
|
2023-05-22 12:05:59 +00:00
|
|
|
SAVE_BUTTON_TEXT,
|
|
|
|
|
TEST_BUTTON_TEXT,
|
2022-03-30 13:11:25 +00:00
|
|
|
createMessage,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-05-22 12:05:59 +00:00
|
|
|
import { Button, toast } from "design-system";
|
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";
|
2023-05-29 05:40:41 +00:00
|
|
|
import { INTEGRATION_TABS, SHOW_FILE_PICKER_KEY } from "constants/routes";
|
2023-10-12 05:31:22 +00:00
|
|
|
import { integrationEditorURL } from "@appsmith/RouteBuilder";
|
2023-05-29 05:40:41 +00:00
|
|
|
import { getQueryParams } from "utils/URLUtils";
|
|
|
|
|
import type { AppsmithLocationState } from "utils/history";
|
2023-05-26 06:39:07 +00:00
|
|
|
import type { PluginType } from "entities/Action";
|
2023-09-11 07:09:41 +00:00
|
|
|
import { getCurrentEnvironmentDetails } from "@appsmith/selectors/environmentSelectors";
|
2023-09-29 20:42:56 +00:00
|
|
|
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
|
|
|
|
|
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
|
|
|
|
|
import { getHasManageDatasourcePermission } from "@appsmith/utils/BusinessFeatures/permissionPageHelpers";
|
2023-12-01 11:46:30 +00:00
|
|
|
import { resetCurrentPluginIdForCreateNewApp } from "actions/onboardingActions";
|
2022-12-01 06:30:50 +00:00
|
|
|
|
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;
|
2023-07-03 13:06:05 +00:00
|
|
|
currentEnvironment: string;
|
2022-01-14 06:31:54 +00:00
|
|
|
isInvalid: boolean;
|
2022-03-17 10:28:54 +00:00
|
|
|
pageId?: string;
|
2023-07-21 05:53:17 +00:00
|
|
|
formName: string;
|
2023-05-22 12:05:59 +00:00
|
|
|
viewMode?: boolean;
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldRender?: boolean;
|
2023-05-19 18:37:06 +00:00
|
|
|
isInsideReconnectModal?: boolean;
|
2022-03-30 13:11:25 +00:00
|
|
|
datasourceButtonConfiguration: string[] | undefined;
|
2023-05-26 06:39:07 +00:00
|
|
|
pluginType: PluginType;
|
|
|
|
|
pluginName: string;
|
|
|
|
|
pluginPackageName: string;
|
2023-07-21 05:53:17 +00:00
|
|
|
setDatasourceViewMode: (payload: {
|
|
|
|
|
datasourceId: string;
|
|
|
|
|
viewMode: boolean;
|
|
|
|
|
}) => void;
|
2023-05-26 06:39:07 +00:00
|
|
|
isSaving: boolean;
|
|
|
|
|
isTesting: boolean;
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldDisplayAuthMessage?: boolean;
|
2022-11-30 05:59:45 +00:00
|
|
|
triggerSave?: boolean;
|
|
|
|
|
isFormDirty?: boolean;
|
2023-05-12 15:04:38 +00:00
|
|
|
scopeValue?: string;
|
2023-07-24 10:29:05 +00:00
|
|
|
onCancel: () => void;
|
2023-12-01 11:46:30 +00:00
|
|
|
isOnboardingFlow?: boolean;
|
2022-01-14 06:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
export type DatasourceFormButtonTypes = Record<string, string[]>;
|
|
|
|
|
|
2023-04-21 11:03:39 +00:00
|
|
|
export enum AuthorizationStatus {
|
2022-03-30 13:11:25 +00:00
|
|
|
SUCCESS = "success",
|
|
|
|
|
APPSMITH_ERROR = "appsmith_error",
|
fix: gs authorisation status updates (#23890)
## Description
This PR fixes inconsistencies in the authenticationStatus property for
google sheets:
- In case of google sheets datasource, when we authorise the datasource,
but do not grant permissions, the authenticationStatus is being saved as
`IN_PROGRESS`, instead it should be `FAILURE` as user failed to give
permissions.
- This PR adds 3 new statuses in AuthenticationStatus Enum,
`IN_PROGRESS_PERMISSIONS_GRANTED`, `FAILURE_ACCESS_DENIED` and
`FAILURE_NO_FILES_SELECTED`.
- `IN_PROGRESS_PERMISSIONS_GRANTED` is used in case of specific sheets
scope, so that we would know that users have granted permissions and
selection of files is pending
- `FAILURE_ACCESS_DENIED` denotes, for any of the scope, if user does
not grant permissions.
- `FAILURE_NO_FILES_SELECTED` denotes, for specific scope, if user
grants permissions but files have not been selected yet.
#### PR fixes following issue(s)
Fixes #23877
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### 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.
- Bug fix (non-breaking change which fixes an issue)
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] 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
- [ ] PR is being merged under a feature flag
#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [x] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-06-02 06:28:46 +00:00
|
|
|
ACCESS_DENIED = "access_denied",
|
2022-03-30 13:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum DatasourceButtonTypeEnum {
|
|
|
|
|
SAVE = "SAVE",
|
|
|
|
|
TEST = "TEST",
|
2023-05-22 12:05:59 +00:00
|
|
|
CANCEL = "CANCEL",
|
2022-03-30 13:11:25 +00:00
|
|
|
SAVE_AND_AUTHORIZE = "SAVE_AND_AUTHORIZE",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DatasourceButtonType: Record<
|
|
|
|
|
keyof typeof DatasourceButtonTypeEnum,
|
|
|
|
|
string
|
|
|
|
|
> = {
|
|
|
|
|
SAVE: "SAVE",
|
|
|
|
|
TEST: "TEST",
|
2023-05-22 12:05:59 +00:00
|
|
|
CANCEL: "CANCEL",
|
2022-03-30 13:11:25 +00:00
|
|
|
SAVE_AND_AUTHORIZE: "SAVE_AND_AUTHORIZE",
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-22 12:05:59 +00:00
|
|
|
export const ActionButton = styled(Button)<{
|
|
|
|
|
floatLeft: boolean;
|
|
|
|
|
}>`
|
|
|
|
|
&&& {
|
|
|
|
|
// Pulling button to the left if floatLeft is set as true
|
|
|
|
|
margin-right: ${(props) => (props.floatLeft ? "auto" : "9px")};
|
2023-09-05 08:23:44 +00:00
|
|
|
margin-left: ${(props) => (props.floatLeft ? "16px" : "0px")};
|
2023-05-22 12:05:59 +00:00
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const SaveButtonContainer = styled.div<{
|
|
|
|
|
isInsideReconnectModal?: boolean;
|
|
|
|
|
}>`
|
2022-12-20 15:10:18 +00:00
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
2023-04-10 12:59:14 +00:00
|
|
|
gap: 9px;
|
2023-05-22 12:05:59 +00:00
|
|
|
padding-right: 20px;
|
|
|
|
|
border-top: ${(props) =>
|
2023-05-29 05:40:41 +00:00
|
|
|
props.isInsideReconnectModal ? "none" : "1px solid"};
|
|
|
|
|
border-color: var(--ads-v2-color-border);
|
2023-05-22 12:05:59 +00:00
|
|
|
align-items: center;
|
2023-05-29 05:40:41 +00:00
|
|
|
height: 68px;
|
2022-12-20 15:10:18 +00:00
|
|
|
`;
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
const StyledAuthMessage = styled.div`
|
2023-05-19 18:37:06 +00:00
|
|
|
color: var(--ads-v2-color-fg-error);
|
2022-03-30 13:11:25 +00:00
|
|
|
margin-top: 15px;
|
|
|
|
|
&:after {
|
|
|
|
|
content: " *";
|
|
|
|
|
color: inherit;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-14 06:31:54 +00:00
|
|
|
function DatasourceAuth({
|
2023-07-03 13:06:05 +00:00
|
|
|
currentEnvironment,
|
2022-01-14 06:31:54 +00:00
|
|
|
datasource,
|
2023-05-22 12:05:59 +00:00
|
|
|
datasourceButtonConfiguration = [
|
|
|
|
|
DatasourceButtonTypeEnum.CANCEL,
|
|
|
|
|
DatasourceButtonTypeEnum.SAVE,
|
|
|
|
|
],
|
2022-01-14 06:31:54 +00:00
|
|
|
formData,
|
|
|
|
|
getSanitizedFormData,
|
2023-10-11 07:14:38 +00:00
|
|
|
isFormDirty,
|
|
|
|
|
isInsideReconnectModal,
|
2022-01-14 06:31:54 +00:00
|
|
|
isInvalid,
|
2023-12-01 11:46:30 +00:00
|
|
|
isOnboardingFlow,
|
2023-10-11 07:14:38 +00:00
|
|
|
isSaving,
|
|
|
|
|
isTesting,
|
|
|
|
|
onCancel,
|
2023-08-09 08:54:03 +00:00
|
|
|
pageId: pageIdProp = "",
|
2023-05-26 06:39:07 +00:00
|
|
|
pluginName,
|
|
|
|
|
pluginPackageName,
|
2023-10-11 07:14:38 +00:00
|
|
|
pluginType,
|
|
|
|
|
scopeValue,
|
2022-12-20 15:10:18 +00:00
|
|
|
shouldDisplayAuthMessage = true,
|
2022-11-30 05:59:45 +00:00
|
|
|
triggerSave,
|
2023-10-11 07:14:38 +00:00
|
|
|
viewMode,
|
2022-01-14 06:31:54 +00:00
|
|
|
}: Props) {
|
2023-05-22 12:05:59 +00:00
|
|
|
const shouldRender = !viewMode || isInsideReconnectModal;
|
2022-01-14 06:31:54 +00:00
|
|
|
const authType =
|
2022-12-20 15:10:18 +00:00
|
|
|
formData && "authType" in formData
|
|
|
|
|
? formData?.authType
|
2023-07-03 13:06:05 +00:00
|
|
|
: formData?.datasourceStorages &&
|
|
|
|
|
formData?.datasourceStorages[currentEnvironment]
|
|
|
|
|
?.datasourceConfiguration?.authentication?.authenticationType;
|
2022-03-30 13:11:25 +00:00
|
|
|
|
2023-05-26 06:39:07 +00:00
|
|
|
const { id: datasourceId } = datasource;
|
2022-03-30 13:11:25 +00:00
|
|
|
const applicationId = useSelector(getCurrentApplicationId);
|
|
|
|
|
|
2022-12-01 06:30:50 +00:00
|
|
|
const datasourcePermissions = datasource.userPermissions || [];
|
|
|
|
|
|
2023-09-29 20:42:56 +00:00
|
|
|
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
|
|
|
|
|
|
|
|
|
const canManageDatasource = getHasManageDatasourcePermission(
|
|
|
|
|
isFeatureEnabled,
|
2022-12-01 06:30:50 +00:00
|
|
|
datasourcePermissions,
|
|
|
|
|
);
|
|
|
|
|
|
2023-09-11 07:09:41 +00:00
|
|
|
const currentEnvDetails = useSelector(getCurrentEnvironmentDetails);
|
|
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
// hooks
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const { pageId: pageIdQuery } = useParams<ExplorerURLParams>();
|
2023-05-29 05:40:41 +00:00
|
|
|
const history = useHistory<AppsmithLocationState>();
|
2022-03-30 13:11:25 +00:00
|
|
|
|
2023-08-09 08:54:03 +00:00
|
|
|
const pageId = isInsideReconnectModal
|
|
|
|
|
? pageIdProp
|
|
|
|
|
: ((pageIdQuery || pageIdProp) as 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
|
|
|
|
2022-03-30 13:11:25 +00:00
|
|
|
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");
|
2023-05-04 04:13:34 +00:00
|
|
|
const showFilePicker = search.get(SHOW_FILE_PICKER_KEY);
|
2022-03-30 13:11:25 +00:00
|
|
|
const shouldNotify =
|
2023-05-04 04:13:34 +00:00
|
|
|
!queryIsImport ||
|
|
|
|
|
(queryIsImport &&
|
|
|
|
|
queryDatasourceId === datasourceId &&
|
|
|
|
|
!showFilePicker);
|
2022-03-30 13:11:25 +00:00
|
|
|
if (status && shouldNotify) {
|
|
|
|
|
const display_message = search.get("display_message");
|
|
|
|
|
if (status !== AuthorizationStatus.SUCCESS) {
|
|
|
|
|
const message =
|
|
|
|
|
status === AuthorizationStatus.APPSMITH_ERROR
|
|
|
|
|
? OAUTH_AUTHORIZATION_APPSMITH_ERROR
|
|
|
|
|
: OAUTH_AUTHORIZATION_FAILED;
|
2023-05-19 18:37:06 +00:00
|
|
|
toast.show(display_message || message, { kind: "error" });
|
2023-05-30 11:49:35 +00:00
|
|
|
AnalyticsUtil.logEvent("DATASOURCE_AUTH_COMPLETE", {
|
|
|
|
|
applicationId: applicationId,
|
|
|
|
|
datasourceId: datasourceId,
|
|
|
|
|
pageId: pageId,
|
|
|
|
|
oAuthPassOrFailVerdict: status,
|
|
|
|
|
workspaceId: datasource?.workspaceId,
|
|
|
|
|
datasourceName: datasource?.name,
|
|
|
|
|
pluginName: pluginName,
|
|
|
|
|
});
|
fix: gs authorisation status updates (#23890)
## Description
This PR fixes inconsistencies in the authenticationStatus property for
google sheets:
- In case of google sheets datasource, when we authorise the datasource,
but do not grant permissions, the authenticationStatus is being saved as
`IN_PROGRESS`, instead it should be `FAILURE` as user failed to give
permissions.
- This PR adds 3 new statuses in AuthenticationStatus Enum,
`IN_PROGRESS_PERMISSIONS_GRANTED`, `FAILURE_ACCESS_DENIED` and
`FAILURE_NO_FILES_SELECTED`.
- `IN_PROGRESS_PERMISSIONS_GRANTED` is used in case of specific sheets
scope, so that we would know that users have granted permissions and
selection of files is pending
- `FAILURE_ACCESS_DENIED` denotes, for any of the scope, if user does
not grant permissions.
- `FAILURE_NO_FILES_SELECTED` denotes, for specific scope, if user
grants permissions but files have not been selected yet.
#### PR fixes following issue(s)
Fixes #23877
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### 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.
- Bug fix (non-breaking change which fixes an issue)
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] 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
- [ ] PR is being merged under a feature flag
#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [x] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
Co-authored-by: “sneha122” <“sneha@appsmith.com”>
2023-06-02 06:28:46 +00:00
|
|
|
|
|
|
|
|
if (status === AuthorizationStatus.ACCESS_DENIED) {
|
|
|
|
|
dispatch(
|
|
|
|
|
updateDatasourceAuthState(
|
|
|
|
|
datasource,
|
|
|
|
|
AuthenticationStatus.FAILURE_ACCESS_DENIED,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-03-30 13:11:25 +00:00
|
|
|
} else {
|
|
|
|
|
dispatch(getOAuthAccessToken(datasourceId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [authType]);
|
|
|
|
|
|
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 =
|
2023-08-10 12:38:00 +00:00
|
|
|
datasource?.datasourceStorages && authType === AuthType.OAUTH2
|
2023-09-11 07:09:41 +00:00
|
|
|
? datasource?.datasourceStorages[currentEnvDetails.editingId]
|
2023-08-10 12:38:00 +00:00
|
|
|
?.datasourceConfiguration?.authentication?.isAuthorized
|
|
|
|
|
: datasource?.datasourceStorages[currentEnvironment]
|
|
|
|
|
?.datasourceConfiguration?.authentication?.authenticationStatus ===
|
|
|
|
|
AuthenticationStatus.SUCCESS;
|
2022-03-30 13:11:25 +00:00
|
|
|
|
|
|
|
|
// Button Operations for respective buttons.
|
|
|
|
|
|
|
|
|
|
// Handles datasource testing
|
|
|
|
|
const handleDatasourceTest = () => {
|
|
|
|
|
AnalyticsUtil.logEvent("TEST_DATA_SOURCE_CLICK", {
|
|
|
|
|
pageId: pageId,
|
|
|
|
|
appId: applicationId,
|
2023-05-22 08:44:06 +00:00
|
|
|
datasourceId: datasourceId,
|
2023-07-21 05:53:17 +00:00
|
|
|
environmentId: currentEnvironment,
|
2023-09-11 07:09:41 +00:00
|
|
|
environmentName: currentEnvDetails.name,
|
2023-05-22 08:44:06 +00:00
|
|
|
pluginName: pluginName,
|
2022-03-30 13:11:25 +00:00
|
|
|
});
|
|
|
|
|
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,
|
2023-07-21 05:53:17 +00:00
|
|
|
environmentId: currentEnvironment,
|
2023-09-11 07:09:41 +00:00
|
|
|
environmentName: currentEnvDetails.name,
|
2023-03-21 08:16:46 +00:00
|
|
|
pluginName: pluginName || "",
|
|
|
|
|
pluginPackageName: pluginPackageName || "",
|
2022-03-30 13:11:25 +00:00
|
|
|
});
|
|
|
|
|
// 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 {
|
2023-05-19 18:37:06 +00:00
|
|
|
dispatch(
|
|
|
|
|
updateDatasource(
|
|
|
|
|
getSanitizedFormData(),
|
2023-07-21 05:53:17 +00:00
|
|
|
currentEnvironment,
|
2023-05-19 18:37:06 +00:00
|
|
|
undefined,
|
|
|
|
|
undefined,
|
|
|
|
|
isInsideReconnectModal,
|
|
|
|
|
),
|
|
|
|
|
);
|
2022-11-30 05:59:45 +00:00
|
|
|
}
|
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 {
|
|
|
|
|
dispatch(
|
|
|
|
|
updateDatasource(
|
|
|
|
|
getSanitizedFormData(),
|
2023-07-21 05:53:17 +00:00
|
|
|
currentEnvironment,
|
2022-11-30 05:59:45 +00:00
|
|
|
pluginType
|
|
|
|
|
? redirectAuthorizationCode(pageId, datasourceId, pluginType)
|
|
|
|
|
: undefined,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-05-12 15:04:38 +00:00
|
|
|
AnalyticsUtil.logEvent("DATASOURCE_AUTHORIZE_CLICK", {
|
2023-05-30 11:49:35 +00:00
|
|
|
dsName: datasource?.name,
|
|
|
|
|
orgId: datasource?.workspaceId,
|
|
|
|
|
pluginName: pluginName,
|
|
|
|
|
scopeValue: scopeValue,
|
2023-05-12 15:04:38 +00:00
|
|
|
});
|
2022-03-30 13:11:25 +00:00
|
|
|
};
|
|
|
|
|
|
2022-12-02 12:35:18 +00:00
|
|
|
const createMode = datasourceId === TEMP_DATASOURCE_ID;
|
2023-07-24 10:29:05 +00:00
|
|
|
const datasourceButtonsComponentMap = (buttonType: string): JSX.Element => {
|
2022-03-30 13:11:25 +00:00
|
|
|
return {
|
|
|
|
|
[DatasourceButtonType.TEST]: (
|
2023-05-22 12:05:59 +00:00
|
|
|
<ActionButton
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--test-datasource"
|
2023-05-22 12:05:59 +00:00
|
|
|
floatLeft={!isInsideReconnectModal}
|
2022-11-30 05:59:45 +00:00
|
|
|
isLoading={isTesting}
|
|
|
|
|
key={buttonType}
|
2024-03-05 06:07:04 +00:00
|
|
|
kind="secondary"
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={handleDatasourceTest}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
|
|
|
|
>
|
2023-05-22 12:05:59 +00:00
|
|
|
{createMessage(TEST_BUTTON_TEXT)}
|
|
|
|
|
</ActionButton>
|
|
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.CANCEL]: (
|
|
|
|
|
<Button
|
|
|
|
|
className="t--cancel-edit-datasource"
|
|
|
|
|
key={buttonType}
|
|
|
|
|
kind="tertiary"
|
|
|
|
|
onClick={() => {
|
2023-05-29 05:40:41 +00:00
|
|
|
if (createMode) {
|
2023-12-01 11:46:30 +00:00
|
|
|
if (!!isOnboardingFlow) {
|
|
|
|
|
// Going back from start from data screen
|
|
|
|
|
AnalyticsUtil.logEvent(
|
|
|
|
|
"ONBOARDING_FLOW_DATASOURCE_FORM_CANCEL_CLICK",
|
|
|
|
|
);
|
|
|
|
|
dispatch(resetCurrentPluginIdForCreateNewApp());
|
|
|
|
|
} else {
|
|
|
|
|
const URL = integrationEditorURL({
|
|
|
|
|
pageId,
|
|
|
|
|
selectedTab: INTEGRATION_TABS.NEW,
|
|
|
|
|
params: getQueryParams(),
|
|
|
|
|
});
|
|
|
|
|
history.push(URL);
|
|
|
|
|
}
|
2023-07-21 05:53:17 +00:00
|
|
|
} else {
|
2023-07-24 10:29:05 +00:00
|
|
|
!!onCancel && onCancel();
|
2023-07-21 05:53:17 +00:00
|
|
|
}
|
2023-05-22 12:05:59 +00:00
|
|
|
}}
|
|
|
|
|
size="md"
|
|
|
|
|
>
|
|
|
|
|
{createMessage(CANCEL)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Button>
|
2022-03-30 13:11:25 +00:00
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.SAVE]: (
|
2023-05-19 18:37:06 +00:00
|
|
|
<Button
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--save-datasource"
|
2023-05-19 18:37:06 +00:00
|
|
|
isDisabled={
|
2023-07-21 05:53:17 +00:00
|
|
|
isInvalid ||
|
|
|
|
|
(!createMode && !isFormDirty) ||
|
|
|
|
|
(!createMode && !canManageDatasource)
|
2022-12-02 12:35:18 +00:00
|
|
|
}
|
2022-12-11 12:51:52 +00:00
|
|
|
isLoading={isSaving}
|
2022-11-30 05:59:45 +00:00
|
|
|
key={buttonType}
|
2023-09-12 06:18:58 +00:00
|
|
|
onClick={
|
|
|
|
|
authType === AuthType.OAUTH2
|
|
|
|
|
? handleOauthDatasourceSave
|
|
|
|
|
: handleDefaultAuthDatasourceSave
|
|
|
|
|
}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
|
|
|
|
>
|
2023-09-12 06:18:58 +00:00
|
|
|
{authType === AuthType.OAUTH2
|
|
|
|
|
? isAuthorized
|
|
|
|
|
? createMessage(SAVE_AND_RE_AUTHORIZE_BUTTON_TEXT)
|
|
|
|
|
: createMessage(SAVE_AND_AUTHORIZE_BUTTON_TEXT)
|
|
|
|
|
: createMessage(SAVE_BUTTON_TEXT)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Button>
|
2022-03-30 13:11:25 +00:00
|
|
|
),
|
|
|
|
|
[DatasourceButtonType.SAVE_AND_AUTHORIZE]: (
|
2023-05-19 18:37:06 +00:00
|
|
|
<Button
|
2022-03-30 13:11:25 +00:00
|
|
|
className="t--save-datasource"
|
2023-05-19 18:37:06 +00:00
|
|
|
isDisabled={isInvalid || (!createMode && !canManageDatasource)}
|
2022-11-30 05:59:45 +00:00
|
|
|
isLoading={isSaving}
|
|
|
|
|
key={buttonType}
|
2022-03-30 13:11:25 +00:00
|
|
|
onClick={handleOauthDatasourceSave}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
|
|
|
|
>
|
2023-05-22 12:05:59 +00:00
|
|
|
{createMessage(SAVE_AND_AUTHORIZE_BUTTON_TEXT)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Button>
|
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 && (
|
2023-05-22 12:05:59 +00:00
|
|
|
<SaveButtonContainer isInsideReconnectModal={isInsideReconnectModal}>
|
2022-03-30 13:11:25 +00:00
|
|
|
{datasourceButtonConfiguration?.map((btnConfig) =>
|
2023-07-24 10:29:05 +00:00
|
|
|
datasourceButtonsComponentMap(btnConfig),
|
2022-03-30 13:11:25 +00:00
|
|
|
)}
|
|
|
|
|
</SaveButtonContainer>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2022-01-14 06:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DatasourceAuth;
|