From fbfdfc060f22d9253876da45c11ea4cef9ee5fb2 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Thu, 4 Jan 2024 14:32:40 +0530 Subject: [PATCH] fix: Auth API send refresh token issue fixed (#30012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR fixes issue of `Send scope with refresh token` dropdown in Authenticated API datasource. The issue was that this dropdown has a default value of No, whenever we update this from No to Yes and save the datasource, now if we edit this datasource, the value in this dropdown should be Yes but it was going back to default No. This PR fixes that issue **Root cause:** The issue occurred because in PR https://github.com/appsmithorg/appsmith/pull/29393 we had set Auth API dropdown values to default ones, so irrespective of the value in datasource config, these dropdowns were getting set to default values. **Solution:** This PR updates the initial values, so that if this value is already set, initial value is read from dsConfig, otherwise it's set to default value #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/29941 > 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 - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### 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 - [ ] 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/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] 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 ## Summary by CodeRabbit - **Refactor** - Improved the conditional rendering logic in the data source editor for a more intuitive user interface based on the selected authentication method. --------- Co-authored-by: “sneha122” <“sneha@appsmith.com”> --- .../pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx b/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx index 03f197237f..30cea60ff9 100644 --- a/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx +++ b/app/client/src/pages/Editor/DataSourceEditor/RestAPIDatasourceForm.tsx @@ -595,7 +595,7 @@ class DatasourceRestAPIEditor extends React.Component { "", false, "", - true, + !!_.get(formData.authentication, "isTokenHeader"), )} {_.get(formData.authentication, "isTokenHeader") && ( @@ -679,7 +679,7 @@ class DatasourceRestAPIEditor extends React.Component { "", false, "", - false, + !!_.get(formData.authentication, "isAuthorizationHeader"), )} @@ -721,7 +721,7 @@ class DatasourceRestAPIEditor extends React.Component { "", false, "", - false, + !!_.get(authentication, "sendScopeWithRefreshToken"), )} )}