Skip to content

Commit 15ad8e7

Browse files
authored
Merge pull request #268 from RedisInsight/feature/RI-6910/disable-cloud-ads
RI-6910: disable cloud ads based on config
2 parents 7f1daa8 + 453bb26 commit 15ad8e7

File tree

9 files changed

+41
-26
lines changed

9 files changed

+41
-26
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ RI_ANALYTICS_START_EVENTS=true
1919
RI_AGREEMENTS_PATH='../../webviews/resources/agreements-spec.json'
2020
RI_ENCRYPTION_KEYTAR_SERVICE="redis-for-vscode"
2121
RI_SOCKETS_CORS=true
22+
RI_FEATURES_CLOUD_ADS_DEFAULT_FLAG=true
2223
# RI_SEGMENT_WRITE_KEY='SEGMENT_WRITE_KEY'
2324

src/webviews/src/actions/oauthCallback.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { INFINITE_MESSAGES } from 'uiSrc/components'
2-
import { CloudAuthStatus, CloudJobName, CloudJobStep, OAuthSocialAction, StorageItem } from 'uiSrc/constants'
2+
import { CLOUD_ADS, CloudAuthStatus, CloudJobName, CloudJobStep, OAuthSocialAction, StorageItem } from 'uiSrc/constants'
33
import { CustomError } from 'uiSrc/interfaces'
44
import { CloudAuthResponse } from 'uiSrc/modules/oauth/interfaces'
55
import { localStorageService } from 'uiSrc/services'
@@ -9,6 +9,10 @@ import { getApiErrorMessage, parseCustomError, removeInfinityToast, showErrorInf
99
let isFlowInProgress = false
1010

1111
export const processOauthCallback = ({ status, message = '', error }: CloudAuthResponse) => {
12+
if (!CLOUD_ADS) {
13+
return
14+
}
15+
1216
const {
1317
ssoFlow,
1418
isRecommendedSettings,

src/webviews/src/components/no-databases/NoDatabases.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as l10n from '@vscode/l10n'
44

55
import { PromoLink } from 'uiSrc/ui'
66
import { vscodeApi } from 'uiSrc/services'
7-
import { OAuthSocialSource, VscodeMessageAction } from 'uiSrc/constants'
7+
import { CLOUD_ADS, OAuthSocialSource, VscodeMessageAction } from 'uiSrc/constants'
88
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
99
import { useAppInfoStore } from 'uiSrc/store/hooks/use-app-info-store/useAppInfoStore'
1010
import DockerIcon from 'uiSrc/assets/database/docker.svg?react'
@@ -64,7 +64,7 @@ export const NoDatabases: FC = () => {
6464
<h2 className="pb-3 text-[24px]">
6565
{l10n.t('Links')}
6666
</h2>
67-
{contentCloud && (
67+
{CLOUD_ADS && contentCloud && (
6868
<PromoLink Icon={LogoSvg} onClick={handleClickFree} {...contentCloud} />
6969
)}
7070
{contentDocker && (

src/webviews/src/constants/environment/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { toNumber } from 'lodash'
44
export const BASE_APP_URL = import.meta.env.RI_BASE_APP_URL || 'http://localhost'
55
export const APP_PORT = toNumber(window.ri?.appPort) || import.meta.env.RI_APP_PORT || 5541
66
export const APP_PREFIX = import.meta.env.RI_APP_PREFIX || 'api'
7+
export const CLOUD_ADS = import.meta.env.RI_FEATURES_CLOUD_ADS_DEFAULT_FLAG !== 'false'
78

89
const isDevelopment = import.meta.env.NODE_ENV === 'development'
910
const hostedApiBaseUrl = import.meta.env.RI_HOSTED_API_BASE_URL

src/webviews/src/constants/window/helpTexts.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as l10n from '@vscode/l10n'
44
import { Link } from 'react-router-dom'
55

66
import { getUtmExternalLink } from 'uiSrc/utils'
7-
import { EXTERNAL_LINKS, UTM_CAMPAIGNS } from 'uiSrc/constants'
7+
import { CLOUD_ADS, EXTERNAL_LINKS, UTM_CAMPAIGNS } from 'uiSrc/constants'
88
import styles from 'uiSrc/components/popover-delete/styles.module.scss'
99

1010
export const helpTexts = {
@@ -23,16 +23,20 @@ export const helpTexts = {
2323
>
2424
{l10n.t('here. ')}
2525
</Link>
26-
{l10n.t('You can also create a ')}
27-
<Link
28-
onClick={onFreeTrialDbClick}
29-
className="underline hover:no-underline"
30-
data-testid="no-json-module-create-free-db"
31-
to=""
32-
>
33-
{l10n.t('free trial Redis Cloud database')}
34-
</Link>
35-
{l10n.t(' with built-in JSON support.')}
26+
{CLOUD_ADS && (
27+
<>
28+
{l10n.t('You can also create a ')}
29+
<Link
30+
onClick={onFreeTrialDbClick}
31+
className="underline hover:no-underline"
32+
data-testid="no-json-module-create-free-db"
33+
to=""
34+
>
35+
{l10n.t('free trial Redis Cloud database')}
36+
</Link>
37+
{l10n.t(' with built-in JSON support.')}
38+
</>
39+
)}
3640
</>
3741
),
3842
REMOVE_LAST_ELEMENT: (fieldType: string) => (

src/webviews/src/pages/AddDatabasePage/AddDatabasePage.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { VSCodeDivider } from '@vscode/webview-ui-toolkit/react'
22
import React, { FC, useEffect } from 'react'
33
import * as l10n from '@vscode/l10n'
44

5-
import { OAuthSocialSource } from 'uiSrc/constants'
5+
import { CLOUD_ADS, OAuthSocialSource } from 'uiSrc/constants'
66
import { CommonAppSubscription, DatabasePanel } from 'uiSrc/modules'
77
import { OAuthCreateFreeDb, OAuthSsoDialog, OAuthJobs, OAuthSelectPlan } from 'uiSrc/modules/oauth'
88
import { fetchCerts } from 'uiSrc/store'
@@ -22,13 +22,17 @@ export const AddDatabasePage: FC<any> = () => {
2222
{l10n.t('Add Redis database')}
2323
</h1>
2424
<VSCodeDivider className="divider" />
25-
<OAuthJobs />
26-
<CommonAppSubscription />
27-
<OAuthSsoDialog />
28-
<OAuthCreateFreeDb source={OAuthSocialSource.AddDbForm} />
29-
<VSCodeDivider className="divider" />
25+
{CLOUD_ADS && (
26+
<>
27+
<OAuthJobs />
28+
<CommonAppSubscription />
29+
<OAuthSsoDialog />
30+
<OAuthCreateFreeDb source={OAuthSocialSource.AddDbForm} />
31+
<OAuthSelectPlan />
32+
<VSCodeDivider className="divider" />
33+
</>
34+
)}
3035
<DatabasePanel />
31-
<OAuthSelectPlan />
3236
</div>
3337
)
3438
}

src/webviews/src/pages/AddKeyPage/AddKeyPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { FC } from 'react'
2+
import { CLOUD_ADS } from 'uiSrc/constants'
23
import { AddKey } from 'uiSrc/modules'
34
import { KeysStoreProvider } from 'uiSrc/modules/keys-tree/hooks/useKeys'
45
import { OAuthSsoDialog } from 'uiSrc/modules/oauth'
@@ -9,7 +10,7 @@ export const AddKeyPage: FC<any> = () => (
910
<ContextStoreProvider>
1011
<KeysStoreProvider>
1112
<AddKey />
12-
<OAuthSsoDialog />
13+
{CLOUD_ADS && <OAuthSsoDialog />}
1314
</KeysStoreProvider>
1415
</ContextStoreProvider>
1516
</div>

src/webviews/src/pages/SidebarPage/SidebarPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DatabaseWrapper } from 'uiSrc/modules'
55
import { useDatabasesStore } from 'uiSrc/store'
66
import { useAppInfoStore } from 'uiSrc/store/hooks/use-app-info-store/useAppInfoStore'
77
import { OAuthCreateFreeDb } from 'uiSrc/modules/oauth'
8-
import { OAuthSocialSource } from 'uiSrc/constants'
8+
import { CLOUD_ADS, OAuthSocialSource } from 'uiSrc/constants'
99

1010
export const SidebarPage: FC<any> = () => {
1111
const databases = useDatabasesStore((state) => state.data)
@@ -20,7 +20,7 @@ export const SidebarPage: FC<any> = () => {
2020

2121
return (
2222
<div className="flex w-full flex-wrap flex-col min-h-full text-vscode-icon-foreground" data-testid="tree-view-page">
23-
<OAuthCreateFreeDb compressed source={OAuthSocialSource.DatabasesList} />
23+
{CLOUD_ADS && <OAuthCreateFreeDb compressed source={OAuthSocialSource.DatabasesList} />}
2424
{databases.map((database) => (
2525
<DatabaseWrapper database={database} key={database.id} />
2626
))}

src/webviews/src/pages/WelcomePage/WelcomePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { VscAdd } from 'react-icons/vsc'
55
import { Link, PromoLink, Separator, Spacer } from 'uiSrc/ui'
66
import { vscodeApi } from 'uiSrc/services'
77
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/utils'
8-
import { OAuthSocialSource, VscodeMessageAction } from 'uiSrc/constants'
8+
import { CLOUD_ADS, OAuthSocialSource, VscodeMessageAction } from 'uiSrc/constants'
99
import { useAppInfoStore } from 'uiSrc/store/hooks/use-app-info-store/useAppInfoStore'
1010
import DockerIcon from 'uiSrc/assets/database/docker.svg?react'
1111
import GithubIcon from 'uiSrc/assets/database/github.svg?react'
@@ -69,7 +69,7 @@ export const WelcomePage: FC = () => {
6969
<Spacer size="xl" />
7070

7171
<h3>{l10n.t('Create new database')}</h3>
72-
{contentCloud && (
72+
{CLOUD_ADS && contentCloud && (
7373
<PromoLink Icon={ShortLogoSvg} onClick={handleClickFree} {...contentCloud} />
7474
)}
7575
{contentDocker && (

0 commit comments

Comments
 (0)