## Description - Remove the primary column from the insert and update queries. - Save/Discard button isSaveDisabled and isDiscardDisabled properties should be in js mode. - Don't create insert and update query if datasource is read only #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24858 #### Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) > > > ## 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 - [ ] Jest - [x] 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 - [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 - [x] I have added tests that prove my fix is effective or that my feature works - [x] 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
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
import type { Datasource } from "entities/Datasource";
|
|
|
|
export const ENVIRONMENT_QUERY_KEY = "environment";
|
|
export const ENVIRONMENT_LOCAL_STORAGE_KEY = "currentEnvironment";
|
|
export const ENVIRONMENT_ID_LOCAL_STORAGE_KEY = "currentEnvironmentId";
|
|
|
|
export const updateLocalStorage = (name: string, id: string) => {
|
|
// Set the values of currentEnv and currentEnvId in localStorage also
|
|
localStorage.setItem(ENVIRONMENT_LOCAL_STORAGE_KEY, name.toLowerCase());
|
|
localStorage.setItem(ENVIRONMENT_ID_LOCAL_STORAGE_KEY, id);
|
|
};
|
|
|
|
// function to get the current environment from the URL
|
|
export const getCurrentEnvironment = () => {
|
|
const localStorageEnv = localStorage.getItem(ENVIRONMENT_LOCAL_STORAGE_KEY);
|
|
//compare currentEnv with local storage and get currentEnvId from localstorage if true
|
|
|
|
if (localStorageEnv && localStorageEnv.length > 0) {
|
|
const localStorageEnvId = localStorage.getItem(
|
|
ENVIRONMENT_ID_LOCAL_STORAGE_KEY,
|
|
);
|
|
if (!!localStorageEnvId && localStorageEnvId?.length > 0)
|
|
return localStorageEnvId;
|
|
}
|
|
return "unused_env";
|
|
};
|
|
|
|
// function to check if the datasource is configured for the current environment
|
|
export const isEnvironmentConfigured = (
|
|
datasource: Datasource | null,
|
|
environment?: string,
|
|
) => {
|
|
!environment && (environment = getCurrentEnvironment());
|
|
const isConfigured =
|
|
!!datasource &&
|
|
!!datasource.datasourceStorages &&
|
|
datasource.datasourceStorages[environment]?.isConfigured;
|
|
return !!isConfigured ? isConfigured : false;
|
|
};
|
|
|
|
// function to check if the datasource is valid for the current environment
|
|
export const isEnvironmentValid = (
|
|
datasource: Datasource | null,
|
|
environment?: string,
|
|
) => {
|
|
!environment && (environment = getCurrentEnvironment());
|
|
const isValid =
|
|
datasource &&
|
|
datasource.datasourceStorages &&
|
|
datasource.datasourceStorages[environment]?.isValid;
|
|
return isValid ? isValid : false;
|
|
};
|
|
|
|
/*
|
|
* Functiont to check get the datasource configuration for current ENV
|
|
*/
|
|
export const getEnvironmentConfiguration = (
|
|
datasource: Datasource | null,
|
|
environment = getCurrentEnvironment(),
|
|
) => {
|
|
return datasource?.datasourceStorages?.[environment]?.datasourceConfiguration;
|
|
};
|