From 6ddcf72efba1ec5c888c775a0e1a4e323b768de6 Mon Sep 17 00:00:00 2001 From: Dipyaman Biswas Date: Sun, 15 Oct 2023 00:04:45 +0530 Subject: [PATCH] feat: use hideWatermark from tenantConfig (#28085) ## Description Instead of using the env file to get the value for hideWatermark, we are moving it to the tenantConfig. Makes it easier to manage and does not need a server restart while changing the value. #### PR fixes following issue(s) Fixes #27922 https://github.com/appsmithorg/appsmith-ee/pull/2628 #### Type of change > Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - This change requires a documentation update > > > ## 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 - [ ] 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: - [ ] [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 --- app/client/jest.config.js | 2 -- app/client/src/ce/configs/index.ts | 9 +-------- app/client/src/ce/configs/types.ts | 1 - app/client/src/ce/constants/tenantConstants.ts | 1 + app/client/src/ce/pages/AdminSettings/config/general.tsx | 6 +++--- app/client/src/ce/selectors/tenantSelectors.tsx | 3 +++ app/client/src/pages/AppViewer/PageMenu.tsx | 6 +++--- app/client/src/pages/AppViewer/index.tsx | 4 ++-- 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/client/jest.config.js b/app/client/jest.config.js index 3fd4b33709..b40121f623 100644 --- a/app/client/jest.config.js +++ b/app/client/jest.config.js @@ -103,8 +103,6 @@ module.exports = { }, intercomAppID: "APP_ID", mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"), - - hideWatermark: parseConfig("__APPSMITH_HIDE_WATERMARK__"), disableIframeWidgetSandbox: parseConfig( "__APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX__", ), diff --git a/app/client/src/ce/configs/index.ts b/app/client/src/ce/configs/index.ts index c523207439..6e2a399c48 100644 --- a/app/client/src/ce/configs/index.ts +++ b/app/client/src/ce/configs/index.ts @@ -40,7 +40,6 @@ export interface INJECTED_CONFIGS { cloudServicesBaseUrl: string; googleRecaptchaSiteKey: string; supportEmail: string; - hideWatermark: boolean; disableIframeWidgetSandbox: boolean; pricingUrl: string; customerPortalUrl: string; @@ -107,9 +106,7 @@ export const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { googleRecaptchaSiteKey: process.env.REACT_APP_GOOGLE_RECAPTCHA_SITE_KEY || "", supportEmail: process.env.APPSMITH_SUPPORT_EMAIL || "support@appsmith.com", - hideWatermark: process.env.APPSMITH_HIDE_WATERMARK - ? process.env.APPSMITH_HIDE_WATERMARK.length > 0 - : false, + disableIframeWidgetSandbox: process.env .APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX ? process.env.APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX.length > 0 @@ -261,10 +258,6 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { APPSMITH_FEATURE_CONFIGS?.cloudServicesBaseUrl || "", appsmithSupportEmail: ENV_CONFIG.supportEmail, - hideWatermark: - ENV_CONFIG.hideWatermark || - APPSMITH_FEATURE_CONFIGS?.hideWatermark || - false, disableIframeWidgetSandbox: ENV_CONFIG.disableIframeWidgetSandbox || APPSMITH_FEATURE_CONFIGS?.disableIframeWidgetSandbox || diff --git a/app/client/src/ce/configs/types.ts b/app/client/src/ce/configs/types.ts index 947ecdff1f..5433dbb5a2 100644 --- a/app/client/src/ce/configs/types.ts +++ b/app/client/src/ce/configs/types.ts @@ -60,7 +60,6 @@ export interface AppsmithUIConfigs { apiKey: string; }; appsmithSupportEmail: string; - hideWatermark: boolean; disableIframeWidgetSandbox: boolean; pricingUrl: string; customerPortalUrl: string; diff --git a/app/client/src/ce/constants/tenantConstants.ts b/app/client/src/ce/constants/tenantConstants.ts index 19b4a43192..6f9cde1c44 100644 --- a/app/client/src/ce/constants/tenantConstants.ts +++ b/app/client/src/ce/constants/tenantConstants.ts @@ -4,6 +4,7 @@ export const tenantConfigConnection: string[] = [ "emailVerificationEnabled", "singleSessionPerUserEnabled", "showRolesAndGroups", + "hideWatermark", ]; export const RESTART_POLL_TIMEOUT = 2 * 150 * 1000; diff --git a/app/client/src/ce/pages/AdminSettings/config/general.tsx b/app/client/src/ce/pages/AdminSettings/config/general.tsx index 4a4417e944..a3ede65683 100644 --- a/app/client/src/ce/pages/AdminSettings/config/general.tsx +++ b/app/client/src/ce/pages/AdminSettings/config/general.tsx @@ -73,12 +73,12 @@ export const APPSMITH_DISABLE_TELEMETRY_SETTING: Setting = { }; export const APPSMITH_HIDE_WATERMARK_SETTING: Setting = { - id: "APPSMITH_HIDE_WATERMARK", - name: "APPSMITH_HIDE_WATERMARK", + id: "hideWatermark", + name: "hideWatermark", category: SettingCategories.GENERAL, controlType: SettingTypes.CHECKBOX, label: "Appsmith watermark", - text: "Show Appsmith watermark", + text: "Hide Appsmith watermark", isFeatureEnabled: false, isDisabled: () => true, textSuffix: , diff --git a/app/client/src/ce/selectors/tenantSelectors.tsx b/app/client/src/ce/selectors/tenantSelectors.tsx index 429d91d99e..838ebe4aa2 100644 --- a/app/client/src/ce/selectors/tenantSelectors.tsx +++ b/app/client/src/ce/selectors/tenantSelectors.tsx @@ -48,3 +48,6 @@ export const getIsFormLoginEnabled = (state: AppState): boolean => export const getInstanceId = (state: AppState): string => state.tenant?.instanceId; + +export const getHideWatermark = (state: AppState): boolean => + state.tenant?.tenantConfiguration?.hideWatermark; diff --git a/app/client/src/pages/AppViewer/PageMenu.tsx b/app/client/src/pages/AppViewer/PageMenu.tsx index 5b9b27db1b..c405556686 100644 --- a/app/client/src/pages/AppViewer/PageMenu.tsx +++ b/app/client/src/pages/AppViewer/PageMenu.tsx @@ -16,7 +16,6 @@ import { useHref } from "pages/Editor/utils"; import { APP_MODE } from "entities/App"; import { builderURL, viewerURL } from "@appsmith/RouteBuilder"; import { trimQueryString } from "utils/helpers"; -import { getAppsmithConfigs } from "@appsmith/configs"; import type { NavigationSetting } from "constants/AppConstants"; import { NAVIGATION_SETTINGS } from "constants/AppConstants"; import { get } from "lodash"; @@ -24,6 +23,7 @@ import { PageMenuContainer, StyledNavLink } from "./PageMenu.styled"; import { StyledCtaContainer } from "./Navigation/Sidebar.styled"; import ShareButton from "./Navigation/components/ShareButton"; import BackToAppsButton from "./Navigation/components/BackToAppsButton"; +import { getHideWatermark } from "@appsmith/selectors/tenantSelectors"; interface NavigationProps { isOpen?: boolean; @@ -41,7 +41,7 @@ export function PageMenu(props: NavigationProps) { const workspaceID = useSelector(getCurrentWorkspaceId); const headerHeight = useSelector(getAppViewHeaderHeight); const [query, setQuery] = useState(""); - const { hideWatermark } = getAppsmithConfigs(); + const hideWatermark = useSelector(getHideWatermark); const navColorStyle = application?.applicationDetail?.navigationSetting?.colorStyle || NAVIGATION_SETTINGS.COLOR_STYLE.LIGHT; @@ -147,7 +147,7 @@ export function PageMenu(props: NavigationProps) { {!hideWatermark && (