Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: make the console license expiry badge optional (#39972)
Xiyuan Chen4b2c5ac4ae5d
diff --git a/api/.env.example b/api/.env.exampleindex c207c2eaa10..2c1e3180265 100644--- a/api/.env.example+++ b/api/.env.example@@ -39,6 +39,9 @@ ENABLE_COLLABORATION_MODE=true# Learn app feature toggleENABLE_LEARN_APP=true+# Show the license expiry countdown badge in the console (enterprise only)+ENABLE_LICENSE_EXPIRY_NOTICE=true+# Access token expiration time in minutesACCESS_TOKEN_EXPIRE_MINUTES=60diff --git a/api/configs/enterprise/__init__.py b/api/configs/enterprise/__init__.pyindex ecce58193b8..a6afbefce91 100644--- a/api/configs/enterprise/__init__.py+++ b/api/configs/enterprise/__init__.py@@ -25,6 +25,12 @@ class EnterpriseFeatureConfig(BaseSettings):default=False,)+ ENABLE_LICENSE_EXPIRY_NOTICE: bool = Field(+ description="Show the license expiry countdown badge in the console when the license is expiring. "+ "Disable to hide the badge; license status and all enforcement remain unaffected.",+ default=True,+ )+ENTERPRISE_REQUEST_TIMEOUT: int = Field(ge=1, description="Maximum timeout in seconds for enterprise requests", default=5)diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.mdindex 67e1a4f9e99..d6e3b3edefb 100644--- a/api/openapi/markdown/console-openapi.md+++ b/api/openapi/markdown/console-openapi.md@@ -22276,6 +22276,7 @@ Non-sensitive bootstrap snapshot exposed before Console or Web authentication.| enable_email_password_login | boolean, <br>**Default:** true | | Yes || enable_explore_banner | boolean | | Yes || enable_learn_app | boolean, <br>**Default:** true | | Yes |+| enable_license_expiry_notice | boolean, <br>**Default:** true | | Yes || enable_marketplace | boolean | | Yes || enable_social_oauth_login | boolean | | Yes || enable_step_by_step_tour | boolean | | Yes |diff --git a/api/openapi/markdown/web-openapi.md b/api/openapi/markdown/web-openapi.mdindex 36f2f7a084a..a5ca2a44077 100644--- a/api/openapi/markdown/web-openapi.md+++ b/api/openapi/markdown/web-openapi.md@@ -1566,6 +1566,7 @@ Non-sensitive bootstrap snapshot exposed before Console or Web authentication.| enable_email_password_login | boolean, <br>**Default:** true | | Yes || enable_explore_banner | boolean | | Yes || enable_learn_app | boolean, <br>**Default:** true | | Yes |+| enable_license_expiry_notice | boolean, <br>**Default:** true | | Yes || enable_marketplace | boolean | | Yes || enable_social_oauth_login | boolean | | Yes || enable_step_by_step_tour | boolean | | Yes |diff --git a/api/services/entities/feature_entities.py b/api/services/entities/feature_entities.pyindex c6f9412da93..938e49cc26e 100644--- a/api/services/entities/feature_entities.py+++ b/api/services/entities/feature_entities.py@@ -197,3 +197,4 @@ class SystemFeatureModel(FeatureResponseModel):enable_step_by_step_tour: bool = Falserbac_enabled: bool = Falseknowledge_fs_enabled: bool = False+ enable_license_expiry_notice: bool = Truediff --git a/api/services/feature_service.py b/api/services/feature_service.pyindex 2051774cde6..8a0f0b42204 100644--- a/api/services/feature_service.py+++ b/api/services/feature_service.py@@ -173,6 +173,7 @@ class FeatureService:system_features.webapp_auth.allow_public_access = dify_config.WEBAPP_PUBLIC_ACCESS_ENABLEDsystem_features.enable_step_by_step_tour = dify_config.ENABLE_STEP_BY_STEP_TOURsystem_features.knowledge_fs_enabled = dify_config.KNOWLEDGE_FS_ENABLED+ system_features.enable_license_expiry_notice = dify_config.ENABLE_LICENSE_EXPIRY_NOTICE@classmethoddef _fulfill_trial_models_from_env(cls) -> list[str]:diff --git a/api/tests/unit_tests/services/test_feature_service_license_expiry_notice.py b/api/tests/unit_tests/services/test_feature_service_license_expiry_notice.pynew file mode 100644index 00000000000..89438685ef8--- /dev/null+++ b/api/tests/unit_tests/services/test_feature_service_license_expiry_notice.py@@ -0,0 +1,21 @@+import pytest++from enums.deployment_edition import DeploymentEdition+from services import feature_service as feature_service_module+from services.entities.feature_entities import SystemFeatureModel+from services.feature_service import FeatureService+++def test_system_feature_model_defaults_enable_license_expiry_notice() -> None:+ system_features = SystemFeatureModel(deployment_edition=DeploymentEdition.COMMUNITY)++ assert system_features.enable_license_expiry_notice is True++[email protected]("enabled", [True, False])+def test_get_system_features_reads_enable_license_expiry_notice(monkeypatch: pytest.MonkeyPatch, enabled: bool) -> None:+ monkeypatch.setattr(feature_service_module.dify_config, "ENABLE_LICENSE_EXPIRY_NOTICE", enabled)++ result = FeatureService.get_system_features()++ assert result.enable_license_expiry_notice is enableddiff --git a/docker/envs/core-services/shared.env.example b/docker/envs/core-services/shared.env.exampleindex 5bd365e65df..425ff1b8028 100644--- a/docker/envs/core-services/shared.env.example+++ b/docker/envs/core-services/shared.env.example@@ -31,6 +31,7 @@ ENABLE_EXPLORE_BANNER=falseENABLE_LEARN_APP=trueENABLE_STEP_BY_STEP_TOUR=falseRBAC_ENABLED=false+ENABLE_LICENSE_EXPIRY_NOTICE=trueCELERY_BROKER_URL=redis://:difyai123456@redis:6379/1CELERY_TASK_ANNOTATIONS=nullAZURE_BLOB_ACCOUNT_URL=https://<your_account_name>.blob.core.windows.netdiff --git a/packages/contracts/generated/api/console/system-features/types.gen.ts b/packages/contracts/generated/api/console/system-features/types.gen.tsindex 47bc300d800..7f6a33b6d3e 100644--- a/packages/contracts/generated/api/console/system-features/types.gen.ts+++ b/packages/contracts/generated/api/console/system-features/types.gen.ts@@ -15,6 +15,7 @@ export type SystemFeatureModel = {enable_email_password_login: booleanenable_explore_banner: booleanenable_learn_app: boolean+ enable_license_expiry_notice: booleanenable_marketplace: booleanenable_social_oauth_login: booleanenable_step_by_step_tour: booleandiff --git a/packages/contracts/generated/api/console/system-features/zod.gen.ts b/packages/contracts/generated/api/console/system-features/zod.gen.tsindex bfbc6d53d1b..be1845162ff 100644--- a/packages/contracts/generated/api/console/system-features/zod.gen.ts+++ b/packages/contracts/generated/api/console/system-features/zod.gen.ts@@ -127,6 +127,7 @@ export const zSystemFeatureModel = z.object({enable_email_password_login: z.boolean().default(true),enable_explore_banner: z.boolean().default(false),enable_learn_app: z.boolean().default(true),+ enable_license_expiry_notice: z.boolean().default(true),enable_marketplace: z.boolean().default(false),enable_social_oauth_login: z.boolean().default(false),enable_step_by_step_tour: z.boolean().default(false),diff --git a/packages/contracts/generated/api/web/types.gen.ts b/packages/contracts/generated/api/web/types.gen.tsindex f95ed066bb5..ba5288e1b5e 100644--- a/packages/contracts/generated/api/web/types.gen.ts+++ b/packages/contracts/generated/api/web/types.gen.ts@@ -520,6 +520,7 @@ export type SystemFeatureModel = {enable_email_password_login: booleanenable_explore_banner: booleanenable_learn_app: boolean+ enable_license_expiry_notice: booleanenable_marketplace: booleanenable_social_oauth_login: booleanenable_step_by_step_tour: booleandiff --git a/packages/contracts/generated/api/web/zod.gen.ts b/packages/contracts/generated/api/web/zod.gen.tsindex 36ebdd700fc..7a40b1490f0 100644--- a/packages/contracts/generated/api/web/zod.gen.ts+++ b/packages/contracts/generated/api/web/zod.gen.ts@@ -788,6 +788,7 @@ export const zSystemFeatureModel = z.object({enable_email_password_login: z.boolean().default(true),enable_explore_banner: z.boolean().default(false),enable_learn_app: z.boolean().default(true),+ enable_license_expiry_notice: z.boolean().default(true),enable_marketplace: z.boolean().default(false),enable_social_oauth_login: z.boolean().default(false),enable_step_by_step_tour: z.boolean().default(false),diff --git a/web/app/components/header/license-env/__tests__/index.spec.tsx b/web/app/components/header/license-badge/__tests__/index.spec.tsxsimilarity index 57%rename from web/app/components/header/license-env/__tests__/index.spec.tsxrename to web/app/components/header/license-badge/__tests__/index.spec.tsxindex 00ec3edce57..ecc1e0f2a91 100644--- a/web/app/components/header/license-env/__tests__/index.spec.tsx+++ b/web/app/components/header/license-badge/__tests__/index.spec.tsx@@ -1,3 +1,4 @@+import type { ConsoleQueryTestOptions } from '@/test/console/query-data'import { zLicenseStatus } from '@dify/contracts/api/console/system-features/zod.gen'import { screen } from '@testing-library/react'import dayjs from 'dayjs'@@ -7,9 +8,12 @@ import {renderWithConsoleQuery,seedSystemFeaturesLicense,} from '@/test/console/query-data'-import LicenseNav from '../index'+import LicenseBadge from '../index'-const renderLicenseNav = (license?: Parameters<typeof seedSystemFeaturesLicense>[1]) => {+const renderLicenseBadge = (+ license?: Parameters<typeof seedSystemFeaturesLicense>[1],+ systemFeatures?: ConsoleQueryTestOptions['systemFeatures'],+) => {const queryClient = createConsoleQueryClient()if (license) seedSystemFeaturesLicense(queryClient, license)else {@@ -18,10 +22,10 @@ const renderLicenseNav = (license?: Parameters<typeof seedSystemFeaturesLicense>queryFn: () => new Promise(() => {}),})}- return renderWithConsoleQuery(<LicenseNav />, { queryClient })+ return renderWithConsoleQuery(<LicenseBadge />, { queryClient, systemFeatures })}-describe('LicenseNav', () => {+describe('LicenseBadge', () => {beforeEach(() => {vi.clearAllMocks()vi.useFakeTimers()@@ -34,38 +38,56 @@ describe('LicenseNav', () => {})it('should render nothing while license detail is loading', () => {- const { container } = renderLicenseNav()+ const { container } = renderLicenseBadge()expect(container).toBeEmptyDOMElement()})it('should render nothing when license status is NONE', () => {- const { container } = renderLicenseNav({})+ const { container } = renderLicenseBadge({})expect(container).toBeEmptyDOMElement()})it('should render Enterprise badge when license status is ACTIVE', () => {- renderLicenseNav({ status: zLicenseStatus.enum.active })+ renderLicenseBadge({ status: zLicenseStatus.enum.active })expect(screen.getByText('Enterprise')).toBeInTheDocument()})it('should render singular expiring message when license expires in 0 days', () => {const expiredAt = dayjs().add(2, 'hours').toISOString()- renderLicenseNav({ status: zLicenseStatus.enum.expiring, expired_at: expiredAt })+ renderLicenseBadge({ status: zLicenseStatus.enum.expiring, expired_at: expiredAt })expect(screen.getByText(/license\.expiring/)).toBeInTheDocument()expect(screen.getByText(/count":0/)).toBeInTheDocument()})it('should render singular expiring message when license expires in 1 day', () => {const tomorrow = dayjs().add(1, 'day').add(1, 'hour').toISOString()- renderLicenseNav({ status: zLicenseStatus.enum.expiring, expired_at: tomorrow })+ renderLicenseBadge({ status: zLicenseStatus.enum.expiring, expired_at: tomorrow })expect(screen.getByText(/license\.expiring/)).toBeInTheDocument()expect(screen.getByText(/count":1/)).toBeInTheDocument()})it('should render plural expiring message when license expires in 5 days', () => {const fiveDaysLater = dayjs().add(5, 'day').add(1, 'hour').toISOString()- renderLicenseNav({ status: zLicenseStatus.enum.expiring, expired_at: fiveDaysLater })+ renderLicenseBadge({ status: zLicenseStatus.enum.expiring, expired_at: fiveDaysLater })expect(screen.getByText(/license\.expiring_plural/)).toBeInTheDocument()expect(screen.getByText(/count":5/)).toBeInTheDocument()})++ it('should fall back to the Enterprise badge when the expiry notice is disabled', () => {+ const fiveDaysLater = dayjs().add(5, 'day').add(1, 'hour').toISOString()+ renderLicenseBadge(+ { status: zLicenseStatus.enum.expiring, expired_at: fiveDaysLater },+ { enable_license_expiry_notice: false },+ )+ expect(screen.queryByText(/license\.expiring/)).not.toBeInTheDocument()+ expect(screen.getByText('Enterprise')).toBeInTheDocument()+ })++ it('should keep rendering the Enterprise badge for an active license when the expiry notice is disabled', () => {+ renderLicenseBadge(+ { status: zLicenseStatus.enum.active },+ { enable_license_expiry_notice: false },+ )+ expect(screen.getByText('Enterprise')).toBeInTheDocument()+ })})diff --git a/web/app/components/header/license-env/index.tsx b/web/app/components/header/license-badge/index.tsxsimilarity index 70%rename from web/app/components/header/license-env/index.tsxrename to web/app/components/header/license-badge/index.tsxindex 192059c2142..6d7af6d2e7e 100644--- a/web/app/components/header/license-env/index.tsx+++ b/web/app/components/header/license-badge/index.tsx@@ -1,17 +1,23 @@'use client'import { zLicenseStatus } from '@dify/contracts/api/console/system-features/zod.gen'-import { useQuery } from '@tanstack/react-query'+import { useQuery, useSuspenseQuery } from '@tanstack/react-query'import dayjs from 'dayjs'import { useTranslation } from 'react-i18next'+import { systemFeaturesQueryOptions } from '@/features/system-features/client'import { consoleQuery } from '@/service/client'import PremiumBadge from '../../base/premium-badge'-function LicenseNav() {+function LicenseBadge() {const { t } = useTranslation()const { data: license } = useQuery(consoleQuery.systemFeatures.license.get.queryOptions())+ const { data: expiryNoticeEnabled } = useSuspenseQuery({+ ...systemFeaturesQueryOptions(),+ select: ({ enable_license_expiry_notice }) => enable_license_expiry_notice,+ })+ const isExpiring = license?.status === zLicenseStatus.enum.expiring- if (license?.status === zLicenseStatus.enum.expiring) {+ if (isExpiring && expiryNoticeEnabled) {const count = dayjs(license.expired_at).diff(dayjs(), 'days')return (<PremiumBadge color="orange" className="select-none">@@ -34,7 +40,7 @@ function LicenseNav() {</PremiumBadge>)}- if (license?.status === zLicenseStatus.enum.active) {+ if (license?.status === zLicenseStatus.enum.active || isExpiring) {return (<PremiumBadge color="indigo" className="select-none"><span className="px-1 system-xs-medium">Enterprise</span>@@ -44,4 +50,4 @@ function LicenseNav() {return null}-export default LicenseNav+export default LicenseBadgediff --git a/web/app/components/main-nav/components/workspace-card.tsx b/web/app/components/main-nav/components/workspace-card.tsxindex b194b89f59f..53a7159247c 100644--- a/web/app/components/main-nav/components/workspace-card.tsx+++ b/web/app/components/main-nav/components/workspace-card.tsx@@ -16,7 +16,7 @@ import {settingsQueryParamName,settingsQueryParser,} from '@/app/components/header/account-setting/query-params'-import LicenseNav from '@/app/components/header/license-env'+import LicenseBadge from '@/app/components/header/license-badge'import { buildIntegrationPath } from '@/app/components/integrations/routes'import { useModalContext } from '@/context/modal-context'import { workspacePermissionKeysAtom } from '@/context/permission-state'@@ -287,7 +287,7 @@ export function WorkspaceCard() {const renderWorkspaceStatus = () => {if (deploymentEdition === 'CLOUD')return workspacePlan ? <WorkspacePlanBadge plan={workspacePlan} /> : null- if (deploymentEdition === 'ENTERPRISE') return <LicenseNav />+ if (deploymentEdition === 'ENTERPRISE') return <LicenseBadge />return null}diff --git a/web/test/console/system-features.ts b/web/test/console/system-features.tsindex e3d779d9fb7..732d27a7394 100644--- a/web/test/console/system-features.ts+++ b/web/test/console/system-features.ts@@ -57,6 +57,7 @@ const baseSystemFeatures = {enable_learn_app: true,enable_step_by_step_tour: false,knowledge_fs_enabled: false,+ enable_license_expiry_notice: true,} satisfies GetSystemFeaturesResponseconst baseSystemFeaturesLicense = {