PromucFlow_constructor/app/client/src/entities/Datasource/RestAPIForm.ts

109 lines
2.3 KiB
TypeScript
Raw Normal View History

import { Property } from "entities/Action";
export enum AuthType {
2022-03-21 09:54:26 +00:00
NONE = "dbAuth",
OAuth2 = "oAuth2",
basic = "basic",
apiKey = "apiKey",
bearerToken = "bearerToken",
}
export enum SSLType {
DEFAULT = "DEFAULT",
SELF_SIGNED_CERTIFICATE = "SELF_SIGNED_CERTIFICATE",
}
export enum ApiKeyAuthType {
QueryParams = "queryParams",
Header = "header",
}
export enum GrantType {
ClientCredentials = "client_credentials",
AuthorizationCode = "authorization_code",
}
export type Authentication =
| ClientCredentials
| AuthorizationCode
| Basic
| ApiKey
| BearerToken;
export interface Connection {
ssl: SSL;
}
export interface SSL {
authType: SSLType;
certificateFile: Certificate;
}
export interface Certificate {
name: string;
base64Content: string | ArrayBuffer | null;
}
export interface ApiDatasourceForm {
datasourceId: string;
pluginId: string;
workspaceId: string;
isValid: boolean;
url: string;
headers?: Property[];
queryParameters?: Property[];
isSendSessionEnabled: boolean;
sessionSignatureKey: string;
authType: AuthType;
authentication?: Authentication;
connection?: Connection;
}
export interface Oauth2Common {
authenticationType: AuthType.OAuth2;
accessTokenUrl: string;
clientId: string;
clientSecret: string;
headerPrefix: string;
scopeString: string;
isTokenHeader: boolean;
isAuthorizationHeader: boolean;
audience: string;
resource: string;
fix: ds discard popup issue fixes (#19114) This PR includes following changes: - With latest datasource autosave improvements, we do not save the datasource immediately but save it on explicit click of save button, so in case user has not saved any changes and tries to leave the page, we have added a popup to inform users that they have unsaved changes and whether they would like to save them or not. - The issue was in case of postgres and authenticated API datasource, this popup was getting seen even when the user has not made any changes in the datasource configuration. This PR solves that issue. - The unsaved changes popup needs to be shown only when user has made any new changes in the datasource form TL;DR - We have used redux form's isDirty method to check if user has made any new updates to the form or not. This isDirty compares initial value of datasource form with current form value and if current form value is different it shows the unsaved changes popup - The issue occurred because in case of postgres and authenticated API datasource, we initialise 1 default pair of host address and port (postgres), and default pairs of headers and query parameters (Authenticated API). These initial default changes made the form dirty and so user used to see the popup even when they have not explicitly made any changes. - This PR fixes the issue by setting initial form value with these defaults so they do not make the form dirty. Fixes #18962 , #18998 https://user-images.githubusercontent.com/30018882/208931098-b570e3c4-10bc-4b76-bd54-531ccf869436.mov Co-authored-by: “sneha122” <“sneha@appsmith.com”> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-12-30 10:23:24 +00:00
sendScopeWithRefreshToken: boolean;
refreshTokenClientCredentialsLocation: string;
useSelfSignedCert?: boolean;
}
export interface ClientCredentials extends Oauth2Common {
grantType: GrantType.ClientCredentials;
customTokenParameters: Property[];
}
export interface AuthorizationCode extends Oauth2Common {
grantType: GrantType.AuthorizationCode;
authorizationUrl: string;
customAuthenticationParameters: Property[];
isAuthorized: boolean;
}
export interface Basic {
authenticationType: AuthType.basic;
username: string;
password: string;
fix: secret saved indicator on ui for datasource forms (#18531) ## Description Secret saved indicator on ui exists if the datasource field has a `valueExistPath` and server sends back the boolean value for the specific field in `secretExists` key. The UI would appear as follows : #### When the password is saved and there exists a key `valueExistPath` for `Password` field and the value in `secretExists` is true then - When password field is not focused. An overlay indicating the password shows up. <img width="575" alt="Screenshot 2022-11-28 at 8 58 44 PM" src="https://user-images.githubusercontent.com/7565635/204317024-be22127b-adf4-4914-9180-804ebe6b482a.png"> - When the password field is focused. The overlay goes away. <img width="588" alt="Screenshot 2022-11-28 at 8 58 51 PM" src="https://user-images.githubusercontent.com/7565635/204317400-9d601230-5493-40c0-ac66-21112d0d98ca.png"> TL;DR Fixes #14783 Media [Loom Video of 4 sec](https://www.loom.com/share/ba30b9674d754bf4a0c2704eef69008d) ## Type of change - 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 - [ ] 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 - [ ] 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: “sneha122” <“sneha@appsmith.com”>
2023-01-20 14:03:42 +00:00
secretExists?: Record<string, boolean>;
}
export interface ApiKey {
authenticationType: AuthType.apiKey;
label: string;
headerPrefix: string;
value: string;
addTo: string;
}
export interface BearerToken {
authenticationType: AuthType.bearerToken;
bearerToken: string;
}