2022-08-04 05:40:44 +00:00
|
|
|
import { createReducer } from "utils/ReducerUtils";
|
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 { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
2020-01-27 13:53:33 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
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 {
|
2021-07-07 03:46:16 +00:00
|
|
|
Datasource,
|
|
|
|
|
DatasourceStructure,
|
|
|
|
|
MockDatasource,
|
|
|
|
|
} from "entities/Datasource";
|
2022-11-30 05:59:45 +00:00
|
|
|
import { TEMP_DATASOURCE_ID } from "constants/Datasource";
|
2019-10-22 14:59:58 +00:00
|
|
|
|
2019-11-07 09:32:38 +00:00
|
|
|
export interface DatasourceDataState {
|
|
|
|
|
list: Datasource[];
|
2019-10-22 14:59:58 +00:00
|
|
|
loading: boolean;
|
2020-04-28 06:52:53 +00:00
|
|
|
isTesting: boolean;
|
2022-03-17 10:28:54 +00:00
|
|
|
isListing: boolean; // fetching unconfigured datasource list
|
2020-09-21 09:11:42 +00:00
|
|
|
fetchingDatasourceStructure: boolean;
|
2020-09-29 04:17:25 +00:00
|
|
|
isRefreshingStructure: boolean;
|
2020-09-21 09:11:42 +00:00
|
|
|
structure: Record<string, DatasourceStructure>;
|
2021-07-07 03:46:16 +00:00
|
|
|
isFetchingMockDataSource: false;
|
|
|
|
|
mockDatasourceList: any[];
|
2021-08-20 06:57:01 +00:00
|
|
|
executingDatasourceQuery: boolean;
|
2022-03-17 10:28:54 +00:00
|
|
|
isReconnectingModalOpen: boolean; // reconnect datasource modal for import application
|
|
|
|
|
unconfiguredList: Datasource[];
|
2022-11-30 05:59:45 +00:00
|
|
|
isDatasourceBeingSaved: boolean;
|
|
|
|
|
isDatasourceBeingSavedFromPopup: boolean;
|
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;
|
2019-10-22 14:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-07 09:32:38 +00:00
|
|
|
const initialState: DatasourceDataState = {
|
2019-10-22 14:59:58 +00:00
|
|
|
list: [],
|
|
|
|
|
loading: false,
|
2020-04-28 06:52:53 +00:00
|
|
|
isTesting: false,
|
2022-03-17 10:28:54 +00:00
|
|
|
isListing: false,
|
2020-09-21 09:11:42 +00:00
|
|
|
fetchingDatasourceStructure: false,
|
2020-09-29 04:17:25 +00:00
|
|
|
isRefreshingStructure: false,
|
2020-09-21 09:11:42 +00:00
|
|
|
structure: {},
|
2021-07-07 03:46:16 +00:00
|
|
|
isFetchingMockDataSource: false,
|
|
|
|
|
mockDatasourceList: [],
|
2021-08-20 06:57:01 +00:00
|
|
|
executingDatasourceQuery: false,
|
2022-03-17 10:28:54 +00:00
|
|
|
isReconnectingModalOpen: false,
|
|
|
|
|
unconfiguredList: [],
|
2022-11-30 05:59:45 +00:00
|
|
|
isDatasourceBeingSaved: false,
|
|
|
|
|
isDatasourceBeingSavedFromPopup: 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
|
|
|
gsheetToken: "",
|
2023-03-21 07:23:05 +00:00
|
|
|
gsheetProjectID: "",
|
2019-10-22 14:59:58 +00:00
|
|
|
};
|
|
|
|
|
|
2019-11-07 09:32:38 +00:00
|
|
|
const datasourceReducer = createReducer(initialState, {
|
2021-07-07 03:46:16 +00:00
|
|
|
[ReduxActionTypes.FETCH_MOCK_DATASOURCES_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, isFetchingMockDataSource: true };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.FETCH_MOCK_DATASOURCES_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<any>,
|
|
|
|
|
) => {
|
2021-07-08 05:59:11 +00:00
|
|
|
const mockDatasourceList = action.payload as MockDatasource[];
|
2021-07-07 03:46:16 +00:00
|
|
|
return { ...state, isFetchingMockDataSource: false, mockDatasourceList };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionErrorTypes.FETCH_MOCK_DATASOURCES_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, isFetchingMockDataSource: false };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.ADD_MOCK_DATASOURCES_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, loading: true };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.ADD_MOCK_DATASOURCES_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
|
|
|
|
list: state.list.concat(action.payload),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionErrorTypes.FETCH_MOCK_DATASOURCES_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, loading: false };
|
|
|
|
|
},
|
2019-11-07 09:32:38 +00:00
|
|
|
[ReduxActionTypes.FETCH_DATASOURCES_INIT]: (state: DatasourceDataState) => {
|
2019-10-22 14:59:58 +00:00
|
|
|
return { ...state, loading: true };
|
|
|
|
|
},
|
2019-11-07 09:32:38 +00:00
|
|
|
[ReduxActionTypes.CREATE_DATASOURCE_INIT]: (state: DatasourceDataState) => {
|
2019-10-22 14:59:58 +00:00
|
|
|
return { ...state, loading: true };
|
|
|
|
|
},
|
2020-05-07 04:44:52 +00:00
|
|
|
[ReduxActionTypes.CREATE_DATASOURCE_FROM_FORM_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, loading: true };
|
|
|
|
|
},
|
2020-04-28 06:52:53 +00:00
|
|
|
[ReduxActionTypes.UPDATE_DATASOURCE_INIT]: (state: DatasourceDataState) => {
|
|
|
|
|
return { ...state, loading: true };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.TEST_DATASOURCE_INIT]: (state: DatasourceDataState) => {
|
|
|
|
|
return { ...state, isTesting: true };
|
|
|
|
|
},
|
2022-11-04 05:55:25 +00:00
|
|
|
[ReduxActionTypes.DELETE_DATASOURCE_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
list: state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, isDeleting: true };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
};
|
2020-04-29 10:03:56 +00:00
|
|
|
},
|
2020-09-29 04:17:25 +00:00
|
|
|
[ReduxActionTypes.REFRESH_DATASOURCE_STRUCTURE_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, isRefreshingStructure: true };
|
|
|
|
|
},
|
2021-08-20 06:57:01 +00:00
|
|
|
[ReduxActionTypes.EXECUTE_DATASOURCE_QUERY_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, executingDatasourceQuery: true };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.EXECUTE_DATASOURCE_QUERY_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, executingDatasourceQuery: false };
|
|
|
|
|
},
|
2020-09-21 09:11:42 +00:00
|
|
|
[ReduxActionTypes.FETCH_DATASOURCE_STRUCTURE_INIT]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, fetchingDatasourceStructure: true };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.FETCH_DATASOURCE_STRUCTURE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
2020-09-29 04:17:25 +00:00
|
|
|
action: ReduxAction<{ data: DatasourceStructure; datasourceId: string }>,
|
2020-09-21 09:11:42 +00:00
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
fetchingDatasourceStructure: false,
|
|
|
|
|
structure: {
|
|
|
|
|
...state.structure,
|
|
|
|
|
[action.payload.datasourceId]: action.payload.data,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-09-29 04:17:25 +00:00
|
|
|
[ReduxActionTypes.REFRESH_DATASOURCE_STRUCTURE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{ data: DatasourceStructure; datasourceId: string }>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isRefreshingStructure: false,
|
|
|
|
|
structure: {
|
|
|
|
|
...state.structure,
|
|
|
|
|
[action.payload.datasourceId]: action.payload.data,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-09-21 09:11:42 +00:00
|
|
|
[ReduxActionErrorTypes.FETCH_DATASOURCE_STRUCTURE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
fetchingDatasourceStructure: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2019-11-07 09:32:38 +00:00
|
|
|
[ReduxActionTypes.FETCH_DATASOURCES_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource[]>,
|
2019-10-22 14:59:58 +00:00
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
2019-11-29 05:22:49 +00:00
|
|
|
list: action.payload,
|
2019-10-22 14:59:58 +00:00
|
|
|
};
|
|
|
|
|
},
|
2021-04-26 12:17:38 +00:00
|
|
|
[ReduxActionTypes.TEST_DATASOURCE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{
|
|
|
|
|
show: boolean;
|
|
|
|
|
id?: string;
|
|
|
|
|
messages?: Array<string>;
|
|
|
|
|
error?: any;
|
|
|
|
|
}>,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
if (action.payload.id) {
|
|
|
|
|
const list = state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, messages: action.payload.messages };
|
|
|
|
|
}
|
|
|
|
|
return datasource;
|
|
|
|
|
});
|
2022-03-17 10:28:54 +00:00
|
|
|
const unconfiguredList = state.unconfiguredList.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, messages: action.payload.messages };
|
|
|
|
|
}
|
|
|
|
|
return datasource;
|
|
|
|
|
});
|
2021-04-26 12:17:38 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isTesting: false,
|
|
|
|
|
list: list,
|
2022-03-17 10:28:54 +00:00
|
|
|
unconfiguredList: unconfiguredList,
|
2021-04-26 12:17:38 +00:00
|
|
|
};
|
|
|
|
|
}
|
2020-04-28 06:52:53 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isTesting: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-04-29 10:03:56 +00:00
|
|
|
[ReduxActionTypes.DELETE_DATASOURCE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
list: state.list.filter(
|
2020-12-24 04:32:25 +00:00
|
|
|
(datasource) => datasource.id !== action.payload.id,
|
2020-04-29 10:03:56 +00:00
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
},
|
2022-02-18 06:58:36 +00:00
|
|
|
[ReduxActionTypes.DELETE_DATASOURCE_CANCELLED]: (
|
|
|
|
|
state: DatasourceDataState,
|
2022-11-04 05:55:25 +00:00
|
|
|
action: ReduxAction<Datasource>,
|
2022-02-18 06:58:36 +00:00
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
2022-11-04 05:55:25 +00:00
|
|
|
list: state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, isDeleting: false };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
2022-02-18 06:58:36 +00:00
|
|
|
};
|
|
|
|
|
},
|
2019-11-07 09:32:38 +00:00
|
|
|
[ReduxActionTypes.CREATE_DATASOURCE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
2019-10-22 14:59:58 +00:00
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
|
|
|
|
list: state.list.concat(action.payload),
|
2022-11-30 05:59:45 +00:00
|
|
|
isDatasourceBeingSaved: false,
|
|
|
|
|
isDatasourceBeingSavedFromPopup: false,
|
2019-10-22 14:59:58 +00:00
|
|
|
};
|
|
|
|
|
},
|
2020-04-28 06:52:53 +00:00
|
|
|
[ReduxActionTypes.UPDATE_DATASOURCE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
2020-12-24 04:32:25 +00:00
|
|
|
list: state.list.map((datasource) => {
|
2020-04-28 06:52:53 +00:00
|
|
|
if (datasource.id === action.payload.id) return action.payload;
|
|
|
|
|
|
2022-03-17 10:28:54 +00:00
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
unconfiguredList: state.unconfiguredList.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) return action.payload;
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.UPDATE_DATASOURCE_IMPORT_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
|
|
|
|
list: state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) return action.payload;
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
unconfiguredList: state.unconfiguredList.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) return action.payload;
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
},
|
2022-11-30 05:59:45 +00:00
|
|
|
[ReduxActionTypes.SAVE_DATASOURCE_NAME]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{ id: string; name: string }>,
|
|
|
|
|
) => {
|
|
|
|
|
const list = state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, name: action.payload.name };
|
|
|
|
|
}
|
|
|
|
|
return datasource;
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
list: list,
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-08-26 05:24:44 +00:00
|
|
|
[ReduxActionTypes.SAVE_DATASOURCE_NAME_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource>,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
2020-12-24 04:32:25 +00:00
|
|
|
list: state.list.map((datasource) => {
|
2020-08-26 05:24:44 +00:00
|
|
|
if (datasource.id === action.payload.id) return action.payload;
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-01-27 13:53:33 +00:00
|
|
|
[ReduxActionErrorTypes.CREATE_DATASOURCE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
2022-11-30 05:59:45 +00:00
|
|
|
isDatasourceBeingSaved: false,
|
|
|
|
|
isDatasourceBeingSavedFromPopup: false,
|
2020-01-27 13:53:33 +00:00
|
|
|
};
|
|
|
|
|
},
|
2020-04-29 10:03:56 +00:00
|
|
|
[ReduxActionErrorTypes.DELETE_DATASOURCE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
2022-11-04 05:55:25 +00:00
|
|
|
action: ReduxAction<Datasource>,
|
2020-04-29 10:03:56 +00:00
|
|
|
) => {
|
2022-11-04 05:55:25 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
list: state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, isDeleting: false };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return datasource;
|
|
|
|
|
}),
|
|
|
|
|
};
|
2020-04-29 10:03:56 +00:00
|
|
|
},
|
2020-04-28 06:52:53 +00:00
|
|
|
[ReduxActionErrorTypes.TEST_DATASOURCE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
2021-04-26 12:17:38 +00:00
|
|
|
action: ReduxAction<{
|
|
|
|
|
show: boolean;
|
|
|
|
|
id?: string;
|
|
|
|
|
messages?: Array<string>;
|
|
|
|
|
error?: any;
|
|
|
|
|
}>,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
if (action.payload.id) {
|
|
|
|
|
const list = state.list.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, messages: action.payload.messages };
|
|
|
|
|
}
|
|
|
|
|
return datasource;
|
|
|
|
|
});
|
2022-03-17 10:28:54 +00:00
|
|
|
const unconfiguredList = state.unconfiguredList.map((datasource) => {
|
|
|
|
|
if (datasource.id === action.payload.id) {
|
|
|
|
|
return { ...datasource, messages: action.payload.messages };
|
|
|
|
|
}
|
|
|
|
|
return datasource;
|
|
|
|
|
});
|
2021-04-26 12:17:38 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isTesting: false,
|
|
|
|
|
list: list,
|
2022-03-17 10:28:54 +00:00
|
|
|
unconfiguredList: unconfiguredList,
|
2021-04-26 12:17:38 +00:00
|
|
|
};
|
|
|
|
|
}
|
2020-04-28 06:52:53 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isTesting: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionErrorTypes.UPDATE_DATASOURCE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
): DatasourceDataState => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
loading: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-09-29 04:17:25 +00:00
|
|
|
[ReduxActionErrorTypes.REFRESH_DATASOURCE_STRUCTURE_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isRefreshingStructure: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2021-08-20 06:57:01 +00:00
|
|
|
[ReduxActionErrorTypes.EXECUTE_DATASOURCE_QUERY_ERROR]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
executingDatasourceQuery: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2022-03-17 10:28:54 +00:00
|
|
|
[ReduxActionTypes.SET_IS_RECONNECTING_DATASOURCES_MODAL_OPEN]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{ isOpen: boolean }>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isReconnectingModalOpen: action.payload.isOpen,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.SET_UNCONFIGURED_DATASOURCES]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<Datasource[] | undefined>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isListing: false,
|
|
|
|
|
unconfiguredList: action.payload,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.FETCH_UNCONFIGURED_DATASOURCE_LIST]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isListing: true,
|
|
|
|
|
unconfiguredList: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
2022-11-30 05:59:45 +00:00
|
|
|
[ReduxActionTypes.REMOVE_TEMP_DATASOURCE_SUCCESS]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isDeleting: false,
|
|
|
|
|
list: state.list.filter(
|
|
|
|
|
(datasource) => datasource.id !== TEMP_DATASOURCE_ID,
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.SET_DATASOURCE_SAVE_ACTION_FLAG]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{ isDSSaved: boolean }>,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, isDatasourceBeingSaved: action.payload.isDSSaved };
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.SET_DATASOURCE_SAVE_ACTION_FROM_POPUP_FLAG]: (
|
|
|
|
|
state: DatasourceDataState,
|
|
|
|
|
action: ReduxAction<{ isDSSavedFromPopup: boolean }>,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isDatasourceBeingSavedFromPopup: action.payload.isDSSavedFromPopup,
|
|
|
|
|
};
|
|
|
|
|
},
|
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
|
|
|
[ReduxActionTypes.SET_GSHEET_TOKEN]: (
|
|
|
|
|
state: DatasourceDataState,
|
2023-03-21 07:23:05 +00:00
|
|
|
action: ReduxAction<{ gsheetToken: string; gsheetProjectID: 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
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
gsheetToken: action.payload.gsheetToken,
|
2023-03-21 07:23:05 +00:00
|
|
|
gsheetProjectID: action.payload.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
|
|
|
};
|
|
|
|
|
},
|
2019-10-22 14:59:58 +00:00
|
|
|
});
|
|
|
|
|
|
2019-11-07 09:32:38 +00:00
|
|
|
export default datasourceReducer;
|