diff --git a/app/client/jest.config.js b/app/client/jest.config.js index bae9af532c..478bea0b29 100644 --- a/app/client/jest.config.js +++ b/app/client/jest.config.js @@ -44,6 +44,7 @@ module.exports = { enableGithubOAuth: parseConfig("__APPSMITH_OAUTH2_GITHUB_CLIENT_ID__"), disableLoginForm: parseConfig("__APPSMITH_FORM_LOGIN_DISABLED__"), disableSignup: parseConfig("__APPSMITH_SIGNUP_DISABLED__"), + disableTelemetry: parseConfig("__APPSMITH_DISABLE_TELEMETRY__"), enableRapidAPI: parseConfig("__APPSMITH_MARKETPLACE_ENABLED__"), segment: { apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"), diff --git a/app/client/public/index.html b/app/client/public/index.html index 3cedce33ae..0fd4b01434 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -195,6 +195,7 @@ enableGithubOAuth: parseConfig("__APPSMITH_OAUTH2_GITHUB_CLIENT_ID__"), disableLoginForm: parseConfig("__APPSMITH_FORM_LOGIN_DISABLED__"), disableSignup: parseConfig("__APPSMITH_SIGNUP_DISABLED__"), + disableTelemetry: parseConfig("__APPSMITH_DISABLE_TELEMETRY__"), enableRapidAPI: parseConfig("__APPSMITH_MARKETPLACE_ENABLED__"), segment: { apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"), diff --git a/app/client/src/ce/configs/index.ts b/app/client/src/ce/configs/index.ts index 5200a0d269..8a6750bab9 100644 --- a/app/client/src/ce/configs/index.ts +++ b/app/client/src/ce/configs/index.ts @@ -17,6 +17,7 @@ export interface INJECTED_CONFIGS { enableGithubOAuth: boolean; disableLoginForm: boolean; disableSignup: boolean; + disableTelemetry: boolean; enableRapidAPI: boolean; segment: { apiKey: string; @@ -77,6 +78,9 @@ export const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { disableSignup: process.env.APPSMITH_SIGNUP_DISABLED ? process.env.APPSMITH_SIGNUP_DISABLED.length > 0 : false, + disableTelemetry: process.env.APPSMITH_DISABLE_TELEMETRY + ? process.env.APPSMITH_DISABLE_TELEMETRY.length > 0 + : true, segment: { apiKey: process.env.REACT_APP_SEGMENT_KEY || "", ceKey: process.env.REACT_APP_SEGMENT_CE_KEY || "", @@ -246,6 +250,8 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { ENV_CONFIG.disableLoginForm || APPSMITH_FEATURE_CONFIGS.disableLoginForm, disableSignup: ENV_CONFIG.disableSignup || APPSMITH_FEATURE_CONFIGS.disableSignup, + disableTelemetry: + ENV_CONFIG.disableTelemetry || APPSMITH_FEATURE_CONFIGS.disableTelemetry, enableGoogleOAuth: ENV_CONFIG.enableGoogleOAuth || APPSMITH_FEATURE_CONFIGS.enableGoogleOAuth, diff --git a/app/client/src/ce/configs/types.ts b/app/client/src/ce/configs/types.ts index 51bf7e7c6a..7eac1a47da 100644 --- a/app/client/src/ce/configs/types.ts +++ b/app/client/src/ce/configs/types.ts @@ -46,6 +46,7 @@ export interface AppsmithUIConfigs { enableGithubOAuth: boolean; disableLoginForm: boolean; disableSignup: boolean; + disableTelemetry: boolean; enableMixpanel: boolean; enableTNCPP: boolean; diff --git a/app/client/src/ce/pages/AdminSettings/config/authentication/index.tsx b/app/client/src/ce/pages/AdminSettings/config/authentication/index.tsx index 951d865820..19c3d897a1 100644 --- a/app/client/src/ce/pages/AdminSettings/config/authentication/index.tsx +++ b/app/client/src/ce/pages/AdminSettings/config/authentication/index.tsx @@ -6,6 +6,7 @@ import { } from "constants/ThirdPartyConstants"; import { SettingCategories, + SettingSubCategories, SettingTypes, SettingSubtype, AdminConfigType, @@ -34,7 +35,7 @@ const Form_Auth: AdminConfigType = { { id: "APPSMITH_FORM_LOGIN_DISABLED", category: SettingCategories.FORM_AUTH, - subCategory: "form login", + subCategory: SettingSubCategories.FORMLOGIN, controlType: SettingTypes.TOGGLE, label: "Form Login Option", toggleText: (value: boolean) => { @@ -48,12 +49,12 @@ const Form_Auth: AdminConfigType = { { id: "APPSMITH_SIGNUP_DISABLED", category: SettingCategories.FORM_AUTH, - subCategory: "form signup", + subCategory: SettingSubCategories.FORMLOGIN, controlType: SettingTypes.TOGGLE, label: "Signup", toggleText: (value: boolean) => { if (value) { - return "Allow only invited users to signup"; + return "Restrict Signups"; } else { return " Allow all users to signup"; } @@ -62,7 +63,7 @@ const Form_Auth: AdminConfigType = { { id: "APPSMITH_FORM_CALLOUT_BANNER", category: SettingCategories.FORM_AUTH, - subCategory: "form signup", + subCategory: SettingSubCategories.FORMLOGIN, controlType: SettingTypes.LINK, label: "User emails are not verified. This can lead to a breach in your application.", @@ -83,7 +84,7 @@ const Google_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GOOGLE_READ_MORE", category: SettingCategories.GOOGLE_AUTH, - subCategory: "google signup", + subCategory: SettingSubCategories.GOOGLE, controlType: SettingTypes.LINK, label: "How to configure?", url: GOOGLE_SIGNUP_SETUP_DOC, @@ -91,7 +92,7 @@ const Google_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_ID", category: SettingCategories.GOOGLE_AUTH, - subCategory: "google signup", + subCategory: SettingSubCategories.GOOGLE, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Client ID", @@ -99,7 +100,7 @@ const Google_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET", category: SettingCategories.GOOGLE_AUTH, - subCategory: "google signup", + subCategory: SettingSubCategories.GOOGLE, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Client Secret", @@ -107,7 +108,7 @@ const Google_Auth: AdminConfigType = { { id: "APPSMITH_SIGNUP_ALLOWED_DOMAINS", category: SettingCategories.GOOGLE_AUTH, - subCategory: "google signup", + subCategory: SettingSubCategories.GOOGLE, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Allowed Domains", @@ -128,7 +129,7 @@ const Github_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GITHUB_READ_MORE", category: SettingCategories.GITHUB_AUTH, - subCategory: "github signup", + subCategory: SettingSubCategories.GITHUB, controlType: SettingTypes.LINK, label: "How to configure?", url: GITHUB_SIGNUP_SETUP_DOC, @@ -136,7 +137,7 @@ const Github_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GITHUB_CLIENT_ID", category: SettingCategories.GITHUB_AUTH, - subCategory: "github signup", + subCategory: SettingSubCategories.GITHUB, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Client ID", @@ -144,7 +145,7 @@ const Github_Auth: AdminConfigType = { { id: "APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET", category: SettingCategories.GITHUB_AUTH, - subCategory: "github signup", + subCategory: SettingSubCategories.GITHUB, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Client Secret", diff --git a/app/client/src/ce/pages/AdminSettings/config/types.ts b/app/client/src/ce/pages/AdminSettings/config/types.ts index 859a8776ab..869a5663d3 100644 --- a/app/client/src/ce/pages/AdminSettings/config/types.ts +++ b/app/client/src/ce/pages/AdminSettings/config/types.ts @@ -71,6 +71,12 @@ export const SettingCategories = { GITHUB_AUTH: "github-auth", }; +export const SettingSubCategories = { + GOOGLE: "google signup", + GITHUB: "github signup", + FORMLOGIN: "form login", +}; + export type AdminConfigType = { type: string; controlType: SettingTypes; diff --git a/app/client/src/ce/utils/adminSettingsHelpers.ts b/app/client/src/ce/utils/adminSettingsHelpers.ts index 6a83b7000b..04b97c2862 100644 --- a/app/client/src/ce/utils/adminSettingsHelpers.ts +++ b/app/client/src/ce/utils/adminSettingsHelpers.ts @@ -11,18 +11,21 @@ export const connectedMethods = [ !disableLoginForm, ].filter(Boolean); +/* settings is the updated & unsaved settings on Admin settings page */ export const saveAllowed = (settings: any) => { - if ( - connectedMethods.length >= 2 || - (connectedMethods.length === 1 && - ((!("APPSMITH_FORM_LOGIN_DISABLED" in settings) && !disableLoginForm) || - (settings["APPSMITH_OAUTH2_GOOGLE_CLIENT_ID"] !== "" && - enableGoogleOAuth) || - (settings["APPSMITH_OAUTH2_GITHUB_CLIENT_ID"] !== "" && - enableGithubOAuth))) - ) { - return true; + if (connectedMethods.length === 1) { + const checkFormLogin = !( + "APPSMITH_FORM_LOGIN_DISABLED" in settings || disableLoginForm + ), + checkGoogleAuth = + settings["APPSMITH_OAUTH2_GOOGLE_CLIENT_ID"] !== "" && + enableGoogleOAuth, + checkGithubAuth = + settings["APPSMITH_OAUTH2_GITHUB_CLIENT_ID"] !== "" && + enableGithubOAuth; + + return checkFormLogin || checkGoogleAuth || checkGithubAuth; } else { - return false; + return connectedMethods.length >= 2; } }; diff --git a/app/client/src/pages/Settings/FormGroup/TextInput.tsx b/app/client/src/pages/Settings/FormGroup/TextInput.tsx index ae37172c6c..4dfce25bc2 100644 --- a/app/client/src/pages/Settings/FormGroup/TextInput.tsx +++ b/app/client/src/pages/Settings/FormGroup/TextInput.tsx @@ -6,7 +6,8 @@ import { FormGroup, SettingComponentProps } from "./Common"; export default function TextInput({ setting }: SettingComponentProps) { return ( ) => { const errors: any = {}; _.filter(values, (value, name) => { - const message = AdminConfig.validate(name, value); - if (message) { - errors[name] = message; + const err_message = AdminConfig.validate(name, value); + if (err_message) { + errors[name] = err_message; } }); return errors; diff --git a/app/client/src/pages/Settings/config/advanced.ts b/app/client/src/pages/Settings/config/advanced.ts index 323c424785..907a1cac01 100644 --- a/app/client/src/pages/Settings/config/advanced.ts +++ b/app/client/src/pages/Settings/config/advanced.ts @@ -12,7 +12,7 @@ export const config: AdminConfigType = { settings: [ { id: "APPSMITH_MONGODB_URI", - category: "advanced", + category: SettingCategories.ADVANCED, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "MongoDB URI", @@ -21,7 +21,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_REDIS_URL", - category: "advanced", + category: SettingCategories.ADVANCED, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Redis URL", @@ -30,7 +30,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_CUSTOM_DOMAIN", - category: "advanced", + category: SettingCategories.ADVANCED, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Custom Domain", diff --git a/app/client/src/pages/Settings/config/email.ts b/app/client/src/pages/Settings/config/email.ts index ff638f4028..aa4b37fb3e 100644 --- a/app/client/src/pages/Settings/config/email.ts +++ b/app/client/src/pages/Settings/config/email.ts @@ -21,14 +21,14 @@ export const config: AdminConfigType = { settings: [ { id: "APPSMITH_MAIL_READ_MORE", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.LINK, label: "How to configure?", url: EMAIL_SETUP_DOC, }, { id: "APPSMITH_MAIL_HOST", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "SMTP Host", @@ -36,7 +36,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_MAIL_PORT", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.NUMBER, placeholder: "25", @@ -50,7 +50,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_MAIL_FROM", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "From Address", @@ -65,13 +65,13 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_MAIL_SMTP_TLS_ENABLED", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TOGGLE, label: "TLS Protected Connection", }, { id: "APPSMITH_MAIL_USERNAME", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "SMTP Username", @@ -81,7 +81,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_MAIL_PASSWORD", - category: "email", + category: SettingCategories.EMAIL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.PASSWORD, label: "SMTP Password", @@ -91,7 +91,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_MAIL_TEST_EMAIL", - category: "email", + category: SettingCategories.EMAIL, action: (dispatch: Dispatch>, settings: any = {}) => { dispatch && dispatch({ diff --git a/app/client/src/pages/Settings/config/general.ts b/app/client/src/pages/Settings/config/general.ts index 6138fe1ed1..15c2053cb8 100644 --- a/app/client/src/pages/Settings/config/general.ts +++ b/app/client/src/pages/Settings/config/general.ts @@ -16,7 +16,7 @@ export const config: AdminConfigType = { settings: [ { id: "APPSMITH_INSTANCE_NAME", - category: "general", + category: SettingCategories.GENERAL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Instance Name", @@ -24,7 +24,7 @@ export const config: AdminConfigType = { }, { id: "APPSMITH_ADMIN_EMAILS", - category: "general", + category: SettingCategories.GENERAL, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.EMAIL, label: "Admin Email", @@ -51,14 +51,14 @@ export const config: AdminConfigType = { "_blank", ); }, - category: "general", + category: SettingCategories.GENERAL, controlType: SettingTypes.BUTTON, label: "Generated Docker Compose File", text: "Download", }, { id: "APPSMITH_DISABLE_TELEMETRY", - category: "general", + category: SettingCategories.GENERAL, controlType: SettingTypes.TOGGLE, label: "Disable Sharing Anonymous Usage Data", subText: "Share anonymous usage data to help improve the product", @@ -66,7 +66,7 @@ export const config: AdminConfigType = { if (value) { return "Don't share any data"; } else { - return "Share data & make appsmith better!"; + return "Share Anonymous Telemetry"; } }, }, diff --git a/app/client/src/pages/Settings/config/googleMaps.ts b/app/client/src/pages/Settings/config/googleMaps.ts index 365bd5b532..8601ece8b3 100644 --- a/app/client/src/pages/Settings/config/googleMaps.ts +++ b/app/client/src/pages/Settings/config/googleMaps.ts @@ -14,14 +14,14 @@ export const config: AdminConfigType = { settings: [ { id: "APPSMITH_GOOGLE_MAPS_READ_MORE", - category: "google-maps", + category: SettingCategories.GOOGLE_MAPS, controlType: SettingTypes.LINK, label: "How to configure?", url: GOOGLE_MAPS_SETUP_DOC, }, { id: "APPSMITH_GOOGLE_MAPS_API_KEY", - category: "google-maps", + category: SettingCategories.GOOGLE_MAPS, controlType: SettingTypes.TEXTINPUT, controlSubType: SettingSubtype.TEXT, label: "Google Maps API Key", diff --git a/app/client/src/pages/Settings/config/version.ts b/app/client/src/pages/Settings/config/version.ts index 36d84ec6f0..6abe20c91c 100644 --- a/app/client/src/pages/Settings/config/version.ts +++ b/app/client/src/pages/Settings/config/version.ts @@ -14,7 +14,7 @@ export const config: AdminConfigType = { settings: [ { id: "APPSMITH_CURRENT_VERSION", - category: "version", + category: SettingCategories.VERSION, controlType: SettingTypes.TEXT, label: "Current version", }, @@ -27,7 +27,7 @@ export const config: AdminConfigType = { payload: true, }); }, - category: "version", + category: SettingCategories.VERSION, controlType: SettingTypes.LINK, label: "Release Notes", }, diff --git a/app/client/src/sagas/SuperUserSagas.tsx b/app/client/src/sagas/SuperUserSagas.tsx index 9239a0f89b..29a00fb414 100644 --- a/app/client/src/sagas/SuperUserSagas.tsx +++ b/app/client/src/sagas/SuperUserSagas.tsx @@ -133,7 +133,7 @@ function* SendTestEmail(action: ReduxAction) { }); } catch (e) { Toaster.show({ - text: createMessage(TEST_EMAIL_FAILURE), + text: e?.message || createMessage(TEST_EMAIL_FAILURE), hideProgressBar: true, variant: Variant.danger, });