diff --git a/app/client/cypress/integration/Smoke_TestSuite/EnterpriseTests/AdminSettings/Admin_settings_spec.js b/app/client/cypress/integration/Smoke_TestSuite/EnterpriseTests/AdminSettings/Admin_settings_spec.js index 3a03e01e94..389cc55006 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/EnterpriseTests/AdminSettings/Admin_settings_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/EnterpriseTests/AdminSettings/Admin_settings_spec.js @@ -32,4 +32,13 @@ describe("Admin settings page", function() { .should("contain", "UPGRADE"); } }); + + it.only("should test that Appsmith Watermark setting shows upgrade button", () => { + cy.visit("/settings/general"); + + // checking if the setting contains a word 'Upgrade + cy.get( + EnterpriseAdminSettingsLocators.hideAppsmithWatermarkSetting, + ).contains("Upgrade"); + }); }); diff --git a/app/client/cypress/locators/EnterpriseAdminSettingsLocators.json b/app/client/cypress/locators/EnterpriseAdminSettingsLocators.json index eebcadee62..46eb439396 100644 --- a/app/client/cypress/locators/EnterpriseAdminSettingsLocators.json +++ b/app/client/cypress/locators/EnterpriseAdminSettingsLocators.json @@ -1,4 +1,5 @@ { "upgradeSamlButton": ".t--settings-sub-category-upgrade-saml", - "upgradeOidcButton": ".t--settings-sub-category-upgrade-oidc" -} \ No newline at end of file + "upgradeOidcButton": ".t--settings-sub-category-upgrade-oidc", + "hideAppsmithWatermarkSetting": ".admin-settings-group-appsmith-hide-watermark" +} diff --git a/app/client/docker/templates/nginx-app-http.conf.template b/app/client/docker/templates/nginx-app-http.conf.template index baebf96c06..68b2484c9e 100644 --- a/app/client/docker/templates/nginx-app-http.conf.template +++ b/app/client/docker/templates/nginx-app-http.conf.template @@ -44,6 +44,7 @@ server { sub_filter __APPSMITH_FORM_LOGIN_DISABLED__ '${APPSMITH_FORM_LOGIN_DISABLED}'; sub_filter __APPSMITH_SIGNUP_DISABLED__ '${APPSMITH_SIGNUP_DISABLED}'; sub_filter __APPSMITH_ZIPY_SDK_KEY__ '${APPSMITH_ZIPY_SDK_KEY}'; + sub_filter __APPSMITH_HIDE_WATERMARK__ '${APPSMITH_HIDE_WATERMARK}'; } location /api { diff --git a/app/client/docker/templates/nginx-app-https.conf.template b/app/client/docker/templates/nginx-app-https.conf.template index 6531bcfe25..39211b11a3 100644 --- a/app/client/docker/templates/nginx-app-https.conf.template +++ b/app/client/docker/templates/nginx-app-https.conf.template @@ -54,6 +54,7 @@ server { sub_filter __APPSMITH_FORM_LOGIN_DISABLED__ '${APPSMITH_FORM_LOGIN_DISABLED}'; sub_filter __APPSMITH_SIGNUP_DISABLED__ '${APPSMITH_SIGNUP_DISABLED}'; sub_filter __APPSMITH_ZIPY_SDK_KEY__ '${APPSMITH_ZIPY_SDK_KEY}'; + sub_filter __APPSMITH_HIDE_WATERMARK__ '${APPSMITH_HIDE_WATERMARK}'; } diff --git a/app/client/docker/templates/nginx-app.conf.template b/app/client/docker/templates/nginx-app.conf.template index aa1b345031..f9246f6720 100644 --- a/app/client/docker/templates/nginx-app.conf.template +++ b/app/client/docker/templates/nginx-app.conf.template @@ -52,6 +52,7 @@ server { sub_filter __APPSMITH_FORM_LOGIN_DISABLED__ '${APPSMITH_FORM_LOGIN_DISABLED}'; sub_filter __APPSMITH_SIGNUP_DISABLED__ '${APPSMITH_SIGNUP_DISABLED}'; sub_filter __APPSMITH_ZIPY_SDK_KEY__ '${APPSMITH_ZIPY_SDK_KEY}'; + sub_filter __APPSMITH_HIDE_WATERMARK__ '${APPSMITH_HIDE_WATERMARK}'; } diff --git a/app/client/jest.config.js b/app/client/jest.config.js index d0ab454783..bd32f41ac0 100644 --- a/app/client/jest.config.js +++ b/app/client/jest.config.js @@ -77,6 +77,7 @@ module.exports = { mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"), disableTelemetry: "DISABLE_TELEMETRY" === "" || "DISABLE_TELEMETRY", + hideWatermark: parseConfig("__APPSMITH_HIDE_WATERMARK__"), }, }, }; diff --git a/app/client/public/index.html b/app/client/public/index.html index dc96bbdfd0..3256aa7c0b 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -211,6 +211,7 @@ mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"), cloudServicesBaseUrl: parseConfig("__APPSMITH_CLOUD_SERVICES_BASE_URL__") || "https://cs.appsmith.com", googleRecaptchaSiteKey: parseConfig("__APPSMITH_RECAPTCHA_SITE_KEY__"), + hideWatermark: parseConfig("__APPSMITH_HIDE_WATERMARK__") }; diff --git a/app/client/src/ce/configs/index.ts b/app/client/src/ce/configs/index.ts index bef8de545c..20b344e8c2 100644 --- a/app/client/src/ce/configs/index.ts +++ b/app/client/src/ce/configs/index.ts @@ -46,6 +46,7 @@ export interface INJECTED_CONFIGS { cloudServicesBaseUrl: string; googleRecaptchaSiteKey: string; supportEmail: string; + hideWatermark: boolean; } const capitalizeText = (text: string) => { @@ -124,6 +125,9 @@ 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.REACT_APP_APPSMITH_HIDE_WATERMARK + ? process.env.REACT_APP_APPSMITH_HIDE_WATERMARK.length > 0 + : false, }; }; @@ -270,5 +274,7 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { ENV_CONFIG.cloudServicesBaseUrl || APPSMITH_FEATURE_CONFIGS.cloudServicesBaseUrl, appsmithSupportEmail: ENV_CONFIG.supportEmail, + hideWatermark: + ENV_CONFIG.hideWatermark || APPSMITH_FEATURE_CONFIGS.hideWatermark, }; }; diff --git a/app/client/src/ce/configs/types.ts b/app/client/src/ce/configs/types.ts index 7eac1a47da..9f2f834d2a 100644 --- a/app/client/src/ce/configs/types.ts +++ b/app/client/src/ce/configs/types.ts @@ -68,4 +68,5 @@ export interface AppsmithUIConfigs { apiKey: string; }; appsmithSupportEmail: string; + hideWatermark: boolean; } diff --git a/app/client/src/ce/constants/messages.ts b/app/client/src/ce/constants/messages.ts index 995f05a1a0..5ce4ae0047 100644 --- a/app/client/src/ce/constants/messages.ts +++ b/app/client/src/ce/constants/messages.ts @@ -1102,6 +1102,7 @@ export const APP_THEME_BETA_CARD_CONTENT = () => export const UPGRADE_TO_EE = (authLabel: string) => `Hello, I would like to upgrade and start using ${authLabel} authentication.`; +export const UPGRADE_TO_EE_GENERIC = () => `Hello, I would like to upgrade`; export const ADMIN_AUTH_SETTINGS_TITLE = () => "Select Authentication Method"; export const ADMIN_AUTH_SETTINGS_SUBTITLE = () => "Select a protocol you want to authenticate users with"; diff --git a/app/client/src/ce/pages/AdminSettings/config/general.tsx b/app/client/src/ce/pages/AdminSettings/config/general.tsx new file mode 100644 index 0000000000..2c7c9b04e5 --- /dev/null +++ b/app/client/src/ce/pages/AdminSettings/config/general.tsx @@ -0,0 +1,96 @@ +import React from "react"; +import { isEmail } from "utils/formhelpers"; +import { apiRequestConfig } from "api/Api"; +import UserApi from "@appsmith/api/UserApi"; +import { + AdminConfigType, + SettingCategories, + SettingSubtype, + SettingTypes, + Setting, +} from "@appsmith/pages/AdminSettings/config/types"; +import BrandingBadge from "pages/AppViewer/BrandingBadge"; + +export const APPSMITH_INSTANCE_NAME_SETTING_SETTING: Setting = { + id: "APPSMITH_INSTANCE_NAME", + category: SettingCategories.GENERAL, + controlType: SettingTypes.TEXTINPUT, + controlSubType: SettingSubtype.TEXT, + label: "Instance Name", + placeholder: "appsmith/prod", +}; + +export const APPSMITH__ADMIN_EMAILS_SETTING: Setting = { + id: "APPSMITH_ADMIN_EMAILS", + category: SettingCategories.GENERAL, + controlType: SettingTypes.TEXTINPUT, + controlSubType: SettingSubtype.EMAIL, + label: "Admin Email", + subText: + "Emails of the users who can modify instance settings (Comma Separated)", + placeholder: "Jane@example.com", + validate: (value: string) => { + if ( + value && + !value + .split(",") + .reduce((prev, curr) => prev && isEmail(curr.trim()), true) + ) { + return "Please enter valid email id(s)"; + } + }, +}; + +export const APPSMITH_DOWNLOAD_DOCKER_COMPOSE_FILE_SETTING: Setting = { + id: "APPSMITH_DOWNLOAD_DOCKER_COMPOSE_FILE", + action: () => { + const { host, protocol } = window.location; + window.open( + `${protocol}//${host}${apiRequestConfig.baseURL}${UserApi.downloadConfigURL}`, + "_blank", + ); + }, + category: SettingCategories.GENERAL, + controlType: SettingTypes.BUTTON, + label: "Generated Docker Compose File", + text: "Download", +}; + +export const APPSMITH_DISABLE_TELEMETRY_SETTING: Setting = { + id: "APPSMITH_DISABLE_TELEMETRY", + category: SettingCategories.GENERAL, + controlType: SettingTypes.TOGGLE, + label: "Share anonymous usage data", + subText: "Share anonymous usage data to help improve the product", + toggleText: (value: boolean) => + value ? "Don't share any data" : "Share Anonymous Telemetry", +}; + +export const APPSMITH_HIDE_WATERMARK_SETTING: Setting = { + id: "APPSMITH_HIDE_WATERMARK", + name: "appsmith-hide-watermark", + category: SettingCategories.GENERAL, + controlType: SettingTypes.CHECKBOX, + label: "Appsmith Watermark", + text: "Show Appsmith Watermark", + needsUpgrade: true, + isDisabled: () => true, + textSuffix: , + upgradeLogEventName: "ADMIN_SETTINGS_UPGRADE_WATERMARK", + upgradeIntercomMessage: + "Hello, I would like to upgrade and remove the watermark.", +}; + +export const config: AdminConfigType = { + type: SettingCategories.GENERAL, + controlType: SettingTypes.GROUP, + title: "General", + canSave: true, + settings: [ + APPSMITH_INSTANCE_NAME_SETTING_SETTING, + APPSMITH__ADMIN_EMAILS_SETTING, + APPSMITH_DOWNLOAD_DOCKER_COMPOSE_FILE_SETTING, + APPSMITH_DISABLE_TELEMETRY_SETTING, + APPSMITH_HIDE_WATERMARK_SETTING, + ], +} as AdminConfigType; diff --git a/app/client/src/ce/pages/AdminSettings/config/index.ts b/app/client/src/ce/pages/AdminSettings/config/index.ts index 6892c5f762..b9c86751be 100644 --- a/app/client/src/ce/pages/AdminSettings/config/index.ts +++ b/app/client/src/ce/pages/AdminSettings/config/index.ts @@ -1,6 +1,6 @@ import { ConfigFactory } from "pages/Settings/config/ConfigFactory"; -import { config as GeneralConfig } from "pages/Settings/config/general"; +import { config as GeneralConfig } from "@appsmith/pages/AdminSettings/config/general"; import { config as EmailConfig } from "pages/Settings/config/email"; import { config as MapsConfig } from "pages/Settings/config/googleMaps"; import { config as VersionConfig } from "pages/Settings/config/version"; diff --git a/app/client/src/ce/pages/AdminSettings/config/types.ts b/app/client/src/ce/pages/AdminSettings/config/types.ts index dc5c2ded7b..cfef7e2b4c 100644 --- a/app/client/src/ce/pages/AdminSettings/config/types.ts +++ b/app/client/src/ce/pages/AdminSettings/config/types.ts @@ -1,6 +1,7 @@ import React from "react"; import { ReduxAction } from "@appsmith/constants/ReduxActionConstants"; import { Dispatch } from "react"; +import { EventName } from "utils/AnalyticsUtil"; export enum SettingTypes { TEXTINPUT = "TEXTINPUT", @@ -14,6 +15,7 @@ export enum SettingTypes { ACCORDION = "ACCORDION", TAGINPUT = "TAGINPUT", DROPDOWN = "DROPDOWN", + CHECKBOX = "CHECKBOX", } export enum SettingSubtype { @@ -38,6 +40,7 @@ export interface Setting { subCategory?: string; value?: string; text?: string; + textSuffix?: React.ReactElement; action?: ( dispatch: Dispatch>, settings?: Record, @@ -54,6 +57,9 @@ export interface Setting { formName?: string; fieldName?: string; dropdownOptions?: Array<{ id: string; value: string; label?: string }>; + needsUpgrade?: boolean; + upgradeLogEventName?: EventName; + upgradeIntercomMessage?: string; } export interface Category { diff --git a/app/client/src/ce/selectors/workspaceSelectors.tsx b/app/client/src/ce/selectors/workspaceSelectors.tsx index 7c1000587a..831adb0bc6 100644 --- a/app/client/src/ce/selectors/workspaceSelectors.tsx +++ b/app/client/src/ce/selectors/workspaceSelectors.tsx @@ -63,10 +63,7 @@ export const getDefaultRole = createSelector( return roles?.find((role) => role.isDefault); }, ); + export const getCurrentError = (state: AppState) => { return state.ui.errors.currentError; }; - -export const getShowBrandingBadge = () => { - return true; -}; diff --git a/app/client/src/ee/pages/AdminSettings/config/general.tsx b/app/client/src/ee/pages/AdminSettings/config/general.tsx new file mode 100644 index 0000000000..71a0b55a7a --- /dev/null +++ b/app/client/src/ee/pages/AdminSettings/config/general.tsx @@ -0,0 +1 @@ +export * from "ce/pages/AdminSettings/config/general"; diff --git a/app/client/src/pages/AppViewer/BrandingBadge.tsx b/app/client/src/pages/AppViewer/BrandingBadge.tsx index 4c6ad89bc9..545d128868 100644 --- a/app/client/src/pages/AppViewer/BrandingBadge.tsx +++ b/app/client/src/pages/AppViewer/BrandingBadge.tsx @@ -4,15 +4,10 @@ import { ReactComponent as AppsmithLogo } from "assets/svg/appsmith-logo-no-pad. function BrandingBadge() { return ( - +

Built on

-
+ ); } diff --git a/app/client/src/pages/AppViewer/PageMenu.tsx b/app/client/src/pages/AppViewer/PageMenu.tsx index 28f4c26b84..82c1ff564c 100644 --- a/app/client/src/pages/AppViewer/PageMenu.tsx +++ b/app/client/src/pages/AppViewer/PageMenu.tsx @@ -19,7 +19,7 @@ import { getSelectedAppTheme } from "selectors/appThemingSelectors"; import BrandingBadge from "./BrandingBadgeMobile"; import { getAppViewHeaderHeight } from "selectors/appViewSelectors"; import { useOnClickOutside } from "utils/hooks/useOnClickOutside"; -import { getShowBrandingBadge } from "@appsmith/selectors/workspaceSelectors"; +import { getAppsmithConfigs } from "@appsmith/configs"; import { useHref } from "pages/Editor/utils"; import { APP_MODE } from "entities/App"; import { builderURL, viewerURL } from "RouteBuilder"; @@ -44,7 +44,7 @@ export function PageMenu(props: AppViewerHeaderProps) { ); const headerHeight = useSelector(getAppViewHeaderHeight); const [query, setQuery] = useState(""); - const showBrandingBadge = useSelector(getShowBrandingBadge); + const { hideWatermark } = getAppsmithConfigs(); // hide menu on click outside useOnClickOutside( @@ -91,11 +91,12 @@ export function PageMenu(props: AppViewerHeaderProps) { "-left-full": !isOpen, "left-0": isOpen, })} + ref={menuRef} style={{ height: `calc(100% - ${headerHeight}px)`, }} > -
+
{appPages.map((page) => ( ))} @@ -128,7 +129,16 @@ export function PageMenu(props: AppViewerHeaderProps) { /> )} - {showBrandingBadge && } + {!hideWatermark && ( + + + + )}
diff --git a/app/client/src/pages/AppViewer/index.tsx b/app/client/src/pages/AppViewer/index.tsx index 2c59904d99..3d0c958a2e 100644 --- a/app/client/src/pages/AppViewer/index.tsx +++ b/app/client/src/pages/AppViewer/index.tsx @@ -41,12 +41,12 @@ import { import { setAppViewHeaderHeight } from "actions/appViewActions"; import { showPostCompletionMessage } from "selectors/onboardingSelectors"; import { CANVAS_SELECTOR } from "constants/WidgetConstants"; -import { getShowBrandingBadge } from "@appsmith/selectors/workspaceSelectors"; import { fetchPublishedPage } from "actions/pageActions"; import usePrevious from "utils/hooks/usePrevious"; import { getIsBranchUpdated } from "../utils"; import { APP_MODE } from "entities/App"; import { initAppViewer } from "actions/initActions"; +import { getAppsmithConfigs } from "@appsmith/configs"; const AppViewerBody = styled.section<{ hasPages: boolean; @@ -97,9 +97,9 @@ function AppViewer(props: Props) { ); const showGuidedTourMessage = useSelector(showPostCompletionMessage); const headerHeight = useSelector(getAppViewHeaderHeight); - const showBrandingBadge = useSelector(getShowBrandingBadge); const branch = getSearchQuery(search, GIT_BRANCH_QUERY_KEY); const prevValues = usePrevious({ branch, location: props.location, pageId }); + const { hideWatermark } = getAppsmithConfigs(); /** * initializes the widgets factory and registers all widgets @@ -262,7 +262,16 @@ function AppViewer(props: Props) { > {isInitialized && registered && } - {showBrandingBadge && } + {!hideWatermark && ( + + + + )} diff --git a/app/client/src/pages/Settings/FormGroup/Checkbox.tsx b/app/client/src/pages/Settings/FormGroup/Checkbox.tsx new file mode 100644 index 0000000000..b506452208 --- /dev/null +++ b/app/client/src/pages/Settings/FormGroup/Checkbox.tsx @@ -0,0 +1,120 @@ +import React, { memo } from "react"; +import { + Field, + getFormValues, + WrappedFieldInputProps, + WrappedFieldMetaProps, +} from "redux-form"; +import styled from "styled-components"; +import { FormGroup, SettingComponentProps } from "./Common"; +import { FormTextFieldProps } from "components/ads/formFields/TextField"; +import Checkbox from "components/ads/Checkbox"; +import { Button, Category } from "components/ads"; +import { useSelector } from "react-redux"; +import { SETTINGS_FORM_NAME } from "constants/forms"; +import useOnUpgrade from "utils/hooks/useOnUpgrade"; +import { EventName } from "utils/AnalyticsUtil"; + +const CheckboxWrapper = styled.div` + display: grid; + margin-bottom: 8px; + grid-template-columns: auto 1fr auto; + align-items: center; + gap: 16px; +`; + +const UpgradeButton = styled(Button)` + height: 30px; + width: 94px; + padding: 8px 16px; +`; + +type CheckboxProps = { + label?: string; + id?: string; + isDisabled?: boolean; + needsUpgrade?: boolean; + text: string; + labelSuffix?: React.ReactElement; + upgradeLogEventName?: EventName; + upgradeIntercomMessage?: string; + isPropertyDisabled?: boolean; +}; + +function FieldCheckboxWithCheckboxText(props: CheckboxProps) { + return function FieldCheckbox( + componentProps: FormTextFieldProps & { + meta: Partial; + input: Partial; + }, + ) { + const { isPropertyDisabled, labelSuffix } = props; + const val = componentProps.input.value; + const { onUpgrade } = useOnUpgrade({ + logEventName: props.upgradeLogEventName, + intercomMessage: props.upgradeIntercomMessage, + }); + + function onCheckbox(value?: boolean) { + const CheckboxValue = isPropertyDisabled ? !value : value; + componentProps.input.onChange && + componentProps.input.onChange(CheckboxValue); + componentProps.input.onBlur && componentProps.input.onBlur(CheckboxValue); + } + /* Value = !ENV_VARIABLE + This has been done intentionally as naming convention used contains the word disabled but the UI should show the button enabled by default. + */ + return ( + + +
{labelSuffix}
+ {props.needsUpgrade && ( + + )} +
+ ); + }; +} + +const StyledFieldCheckboxGroup = styled.div` + margin-bottom: 8px; +`; + +const formValuesSelector = getFormValues(SETTINGS_FORM_NAME); + +export function CheckboxComponent({ setting }: SettingComponentProps) { + const settings = useSelector(formValuesSelector); + + return ( + + + + + + ); +} + +export default memo(CheckboxComponent); diff --git a/app/client/src/pages/Settings/FormGroup/Common.tsx b/app/client/src/pages/Settings/FormGroup/Common.tsx index 7b430e5e7e..d2e3399564 100644 --- a/app/client/src/pages/Settings/FormGroup/Common.tsx +++ b/app/client/src/pages/Settings/FormGroup/Common.tsx @@ -33,7 +33,6 @@ export const StyledFormGroup = styled.div` & svg:hover { cursor: default; path { - fill: #fff; } } `; diff --git a/app/client/src/pages/Settings/FormGroup/group.tsx b/app/client/src/pages/Settings/FormGroup/group.tsx index b7137f183a..5d5b5960bd 100644 --- a/app/client/src/pages/Settings/FormGroup/group.tsx +++ b/app/client/src/pages/Settings/FormGroup/group.tsx @@ -23,6 +23,7 @@ import TagInputField from "./TagInputField"; import Dropdown from "./Dropdown"; import { Classes } from "@blueprintjs/core"; import { Colors } from "constants/Colors"; +import Checkbox from "./Checkbox"; type GroupProps = { name?: string; @@ -126,6 +127,17 @@ export default function Group({ ); + case SettingTypes.CHECKBOX: + return ( +
+ +
+ ); case SettingTypes.LINK: return (
{ - if ( - value && - !value - .split(",") - .reduce((prev, curr) => prev && isEmail(curr.trim()), true) - ) { - return "Please enter valid email id(s)"; - } - }, - }, - { - id: "APPSMITH_DOWNLOAD_DOCKER_COMPOSE_FILE", - action: () => { - const { host, protocol } = window.location; - window.open( - `${protocol}//${host}${apiRequestConfig.baseURL}${UserApi.downloadConfigURL}`, - "_blank", - ); - }, - category: SettingCategories.GENERAL, - controlType: SettingTypes.BUTTON, - label: "Generated Docker Compose File", - text: "Download", - }, - { - id: "APPSMITH_DISABLE_TELEMETRY", - category: SettingCategories.GENERAL, - controlType: SettingTypes.TOGGLE, - label: "Share anonymous usage data", - subText: "Share anonymous usage data to help improve the product", - toggleText: (value: boolean) => - value ? "Don't share any data" : "Share Anonymous Telemetry", - }, - ], -} as AdminConfigType; diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 4780070aee..1240b626e4 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -248,6 +248,8 @@ export type EventName = | "BACK_BUTTON_CLICK" | "WIDGET_TAB_CLICK" | "ENTITY_EXPLORER_CLICK" + | "ADMIN_SETTINGS_UPGRADE_WATERMARK" + | "ADMIN_SETTINGS_UPGRADE" | "PRETTIFY_CODE_MANUAL_TRIGGER" | "PRETTIFY_CODE_KEYBOARD_SHORTCUT"; diff --git a/app/client/src/utils/hooks/useOnUpgrade.ts b/app/client/src/utils/hooks/useOnUpgrade.ts new file mode 100644 index 0000000000..c97b478a14 --- /dev/null +++ b/app/client/src/utils/hooks/useOnUpgrade.ts @@ -0,0 +1,33 @@ +import { getAppsmithConfigs } from "@appsmith/configs"; +import { createMessage, UPGRADE_TO_EE_GENERIC } from "ce/constants/messages"; +import AnalyticsUtil, { EventName } from "utils/AnalyticsUtil"; + +const { intercomAppID } = getAppsmithConfigs(); + +type Props = { + intercomMessage?: string; + logEventName?: EventName; + logEventData?: any; +}; + +const useOnUpgrade = (props: Props) => { + const { intercomMessage, logEventData, logEventName } = props; + + const triggerIntercom = (message: string) => { + if (intercomAppID && window.Intercom) { + window.Intercom("showNewMessage", message); + } + }; + + const onUpgrade = () => { + AnalyticsUtil.logEvent( + logEventName || "ADMIN_SETTINGS_UPGRADE", + logEventData, + ); + triggerIntercom(intercomMessage || createMessage(UPGRADE_TO_EE_GENERIC)); + }; + + return { onUpgrade }; +}; + +export default useOnUpgrade;