Skip to content

Commit 8fcec12

Browse files
zzstoatzzclaude
andauthored
Add PREFECT_SERVER_UI_SHOW_PROMOTIONAL_CONTENT setting (#19299)
Co-authored-by: Claude <[email protected]>
1 parent a700392 commit 8fcec12

File tree

6 files changed

+43
-10
lines changed

6 files changed

+43
-10
lines changed

src/prefect/settings/models/server/ui.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ class ServerUISettings(PrefectBaseSettings):
4848
"prefect_ui_static_directory",
4949
),
5050
)
51+
52+
show_promotional_content: bool = Field(
53+
default=True,
54+
description="Whether or not to display promotional content in the UI, including upgrade prompts and marketing banners.",
55+
)

tests/test_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@
468468
"PREFECT_SERVER_UI_API_URL": {"test_value": "https://api.prefect.io"},
469469
"PREFECT_SERVER_UI_ENABLED": {"test_value": True},
470470
"PREFECT_SERVER_UI_SERVE_BASE": {"test_value": "/base"},
471+
"PREFECT_SERVER_UI_SHOW_PROMOTIONAL_CONTENT": {"test_value": False},
471472
"PREFECT_SERVER_UI_STATIC_DIRECTORY": {"test_value": "/path/to/static"},
472473
"PREFECT_SILENCE_API_URL_MISCONFIGURATION": {"test_value": True},
473474
"PREFECT_SQLALCHEMY_MAX_OVERFLOW": {"test_value": 10, "legacy": True},

ui/src/components/ApiStatusToast.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33
<PHeading :heading="6">
44
Oops. Something went wrong.
55
</PHeading>
6-
<div>
7-
You can use Prefect Cloud for free, anytime.
8-
</div>
9-
<div>
10-
<PButton to="https://app.prefect.cloud/auth/sign-up?utm_source=prefect-oss&utm_medium=toast" variant="default" target="_blank">
11-
Try it now
12-
</PButton>
13-
</div>
6+
<template v-if="showPromotionalContent">
7+
<div>
8+
You can use Prefect Cloud for free, anytime.
9+
</div>
10+
<div>
11+
<PButton to="https://app.prefect.cloud/auth/sign-up?utm_source=prefect-oss&utm_medium=toast" variant="default" target="_blank">
12+
Try it now
13+
</PButton>
14+
</div>
15+
</template>
16+
<template v-else>
17+
<div>
18+
Please check your connection and try again.
19+
</div>
20+
</template>
1421
</div>
1522
</template>
1623

1724
<script lang="ts" setup>
1825
import { PButton, PHeading } from '@prefecthq/prefect-design'
26+
import { computed } from 'vue'
27+
28+
// Read from localStorage, default to true
29+
const cachedSetting = localStorage.getItem('prefect-show-promotional-content')
30+
const showPromotionalContent = computed(() => cachedSetting !== 'false')
1931
</script>

ui/src/components/ContextSidebar.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<p-context-nav-item title="Concurrency" :to="routes.concurrencyLimits()" />
1919

2020
<template #footer>
21-
<a href="https://www.prefect.io/cloud-vs-oss?utm_source=oss&utm_medium=oss&utm_campaign=oss&utm_term=none&utm_content=none" target="_blank">
21+
<a v-if="showPromotionalContent" href="https://www.prefect.io/cloud-vs-oss?utm_source=oss&utm_medium=oss&utm_campaign=oss&utm_term=none&utm_content=none" target="_blank">
2222
<p-context-nav-item>
2323
<div>
2424
Ready to scale?
@@ -42,13 +42,20 @@
4242
<script lang="ts" setup>
4343
import JoinTheCommunityModal from '@/components/JoinTheCommunityModal.vue'
4444
import { useCan } from '@/compositions/useCan'
45+
import { usePrefectApi } from '@/compositions/usePrefectApi'
4546
import { routes } from '@/router'
4647
import { PContextNavItem, PContextSidebar } from '@prefecthq/prefect-design'
4748
import { localization, useShowModal } from '@prefecthq/prefect-ui-library'
4849
import { useStorage } from '@prefecthq/vue-compositions'
4950
import { computed } from 'vue'
5051
5152
const can = useCan()
53+
const api = usePrefectApi()
54+
const serverSettings = await api.admin.getSettings()
55+
const showPromotionalContent = computed(() => serverSettings.server.ui.show_promotional_content)
56+
57+
// Cache to localStorage for use in error toasts
58+
localStorage.setItem('prefect-show-promotional-content', String(showPromotionalContent.value))
5259
const canSeeWorkPools = computed(() => can.read.work_pool)
5360
5461
const { showModal: showJoinCommunityModal, open: openJoinCommunityModal } = useShowModal()

ui/src/models/ServerSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type ServerSettings = {
3838
PREFECT_SERVER_API_PORT: number,
3939
PREFECT_SERVER_UI_ENABLED: boolean,
4040
PREFECT_SERVER_UI_API_URL: string,
41+
PREFECT_SERVER_UI_SHOW_PROMOTIONAL_CONTENT: boolean,
4142
PREFECT_SERVER_ANALYTICS_ENABLED: boolean,
4243
PREFECT_SERVER_SERVICES_SCHEDULER_ENABLED: boolean,
4344
PREFECT_SERVER_SERVICES_LATE_RUNS_ENABLED: boolean,

ui/src/pages/Dashboard.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</template>
2929
</template>
3030
<MarketingBanner
31+
v-if="showPromotionalContent"
3132
title="Ready to scale?"
3233
subtitle="Webhooks, role and object-level security, and serverless push work pools on Prefect Cloud"
3334
>
@@ -62,13 +63,19 @@
6263
} from '@prefecthq/prefect-ui-library'
6364
import { useSubscription } from '@prefecthq/vue-compositions'
6465
import { computed, provide } from 'vue'
65-
66+
import { usePrefectApi } from '@/compositions/usePrefectApi'
6667
6768
provide(subscriptionIntervalKey, {
6869
interval: dateFunctions.secondsToMilliseconds(30),
6970
})
7071
7172
const api = useWorkspaceApi()
73+
const prefectApi = usePrefectApi()
74+
const serverSettings = await prefectApi.admin.getSettings()
75+
const showPromotionalContent = computed(() => serverSettings.server.ui.show_promotional_content)
76+
77+
// Cache to localStorage for use in error toasts
78+
localStorage.setItem('prefect-show-promotional-content', String(showPromotionalContent.value))
7279
const flowRunsCountAllSubscription = useSubscription(api.flowRuns.getFlowRunsCount, [{}])
7380
const loaded = computed(() => flowRunsCountAllSubscription.executed)
7481
const empty = computed(() => flowRunsCountAllSubscription.response === 0)

0 commit comments

Comments
 (0)