mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
Merge branch 'feat/license-supports' into deploy/dev
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
This commit is contained in:
commit
b7595231a7
|
@ -109,7 +109,7 @@ class CodeExecutionSandboxConfig(BaseSettings):
|
|||
)
|
||||
|
||||
CODE_MAX_PRECISION: PositiveInt = Field(
|
||||
description="mMaximum number of decimal places for floating-point numbers in code execution",
|
||||
description="Maximum number of decimal places for floating-point numbers in code execution",
|
||||
default=20,
|
||||
)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const Category: FC<ICategoryProps> = ({
|
|||
allCategoriesEn,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const isAllCategories = !list.includes(value as AppCategory)
|
||||
const isAllCategories = !list.includes(value as AppCategory) || value === allCategoriesEn
|
||||
|
||||
const itemClassName = (isSelected: boolean) => cn(
|
||||
'flex items-center px-3 py-[7px] h-[32px] rounded-lg border-[0.5px] border-transparent text-gray-700 font-medium leading-[18px] cursor-pointer hover:bg-gray-200',
|
||||
|
@ -44,7 +44,7 @@ const Category: FC<ICategoryProps> = ({
|
|||
<ThumbsUp className='mr-1 w-3.5 h-3.5' />
|
||||
{t('explore.apps.allCategories')}
|
||||
</div>
|
||||
{list.map(name => (
|
||||
{list.filter(name => name !== allCategoriesEn).map(name => (
|
||||
<div
|
||||
key={name}
|
||||
className={itemClassName(name === value)}
|
||||
|
|
|
@ -12,6 +12,7 @@ import EnvNav from './env-nav'
|
|||
import ExploreNav from './explore-nav'
|
||||
import ToolsNav from './tools-nav'
|
||||
import GithubStar from './github-star'
|
||||
import LicenseNav from './license-env'
|
||||
import { WorkspaceProvider } from '@/context/workspace-context'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import LogoSite from '@/app/components/base/logo/logo-site'
|
||||
|
@ -79,6 +80,7 @@ const Header = () => {
|
|||
</div>
|
||||
)}
|
||||
<div className='flex items-center flex-shrink-0'>
|
||||
<LicenseNav />
|
||||
<EnvNav />
|
||||
{enableBilling && (
|
||||
<div className='mr-3 select-none'>
|
||||
|
|
29
web/app/components/header/license-env/index.tsx
Normal file
29
web/app/components/header/license-env/index.tsx
Normal file
|
@ -0,0 +1,29 @@
|
|||
'use client'
|
||||
|
||||
import AppContext from '@/context/app-context'
|
||||
import { LicenseStatus } from '@/types/feature'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useContextSelector } from 'use-context-selector'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const LicenseNav = () => {
|
||||
const { t } = useTranslation()
|
||||
const systemFeatures = useContextSelector(AppContext, s => s.systemFeatures)
|
||||
|
||||
if (systemFeatures.license?.status === LicenseStatus.EXPIRING) {
|
||||
const expiredAt = systemFeatures.license?.expired_at
|
||||
const count = dayjs(expiredAt).diff(dayjs(), 'days')
|
||||
return <div className='px-2 py-1 mr-4 rounded-full bg-util-colors-orange-orange-50 border-util-colors-orange-orange-100 system-xs-medium text-util-colors-orange-orange-600'>
|
||||
{count <= 1 && <span>{t('common.license.expiring', { count })}</span>}
|
||||
{count > 1 && <span>{t('common.license.expiring_plural', { count })}</span>}
|
||||
</div>
|
||||
}
|
||||
if (systemFeatures.license.status === LicenseStatus.ACTIVE) {
|
||||
return <div className='px-2 py-1 mr-4 rounded-md bg-util-colors-indigo-indigo-50 border-util-colors-indigo-indigo-100 system-xs-medium text-util-colors-indigo-indigo-600'>
|
||||
Enterprise
|
||||
</div>
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export default LicenseNav
|
|
@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import Link from 'next/link'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { RiDoorLockLine } from '@remixicon/react'
|
||||
import { RiContractLine, RiDoorLockLine, RiErrorWarningFill } from '@remixicon/react'
|
||||
import Loading from '../components/base/loading'
|
||||
import MailAndCodeAuth from './components/mail-and-code-auth'
|
||||
import MailAndPasswordAuth from './components/mail-and-password-auth'
|
||||
|
@ -10,7 +10,7 @@ import SocialAuth from './components/social-auth'
|
|||
import SSOAuth from './components/sso-auth'
|
||||
import cn from '@/utils/classnames'
|
||||
import { getSystemFeatures, invitationCheck } from '@/service/common'
|
||||
import { defaultSystemFeatures } from '@/types/feature'
|
||||
import { LicenseStatus, defaultSystemFeatures } from '@/types/feature'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { IS_CE_EDITION } from '@/config'
|
||||
|
||||
|
@ -83,6 +83,34 @@ const NormalForm = () => {
|
|||
<Loading type='area' />
|
||||
</div>
|
||||
}
|
||||
if (systemFeatures.license?.status === LicenseStatus.EXPIRED) {
|
||||
return <div className='w-full mx-auto mt-8'>
|
||||
<div className='bg-white'>
|
||||
<div className="p-4 rounded-lg bg-gradient-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2">
|
||||
<div className='flex items-center justify-center w-10 h-10 rounded-xl bg-components-card-bg shadow shadows-shadow-lg mb-2 relative'>
|
||||
<RiContractLine className='w-5 h-5' />
|
||||
<RiErrorWarningFill className='absolute w-4 h-4 text-text-warning-secondary -top-1 -right-1' />
|
||||
</div>
|
||||
<p className='system-sm-medium text-text-primary'>{t('login.licenseExpired')}</p>
|
||||
<p className='system-xs-regular text-text-tertiary mt-1'>{t('login.licenseExpiredTip')}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
if (systemFeatures.license?.status === LicenseStatus.INACTIVE) {
|
||||
return <div className='w-full mx-auto mt-8'>
|
||||
<div className='bg-white'>
|
||||
<div className="p-4 rounded-lg bg-gradient-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2">
|
||||
<div className='flex items-center justify-center w-10 h-10 rounded-xl bg-components-card-bg shadow shadows-shadow-lg mb-2 relative'>
|
||||
<RiContractLine className='w-5 h-5' />
|
||||
<RiErrorWarningFill className='absolute w-4 h-4 text-text-warning-secondary -top-1 -right-1' />
|
||||
</div>
|
||||
<p className='system-sm-medium text-text-primary'>{t('login.licenseInactive')}</p>
|
||||
<p className='system-xs-regular text-text-tertiary mt-1'>{t('login.licenseInactiveTip')}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -144,7 +144,7 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
|
|||
theme,
|
||||
setTheme: handleSetTheme,
|
||||
apps: appList.data,
|
||||
systemFeatures,
|
||||
systemFeatures: { ...systemFeatures, ...defaultSystemFeatures },
|
||||
mutateApps,
|
||||
userProfile,
|
||||
mutateUserProfile,
|
||||
|
|
|
@ -591,6 +591,10 @@ const translation = {
|
|||
created: 'Tag created successfully',
|
||||
failed: 'Tag creation failed',
|
||||
},
|
||||
license: {
|
||||
expiring: 'Expiring in one day',
|
||||
expiring_plural: 'Expiring in {{count}} days',
|
||||
},
|
||||
}
|
||||
|
||||
export default translation
|
||||
|
|
|
@ -98,6 +98,10 @@ const translation = {
|
|||
back: 'Back',
|
||||
noLoginMethod: 'Authentication method not configured',
|
||||
noLoginMethodTip: 'Please contact the system admin to add an authentication method.',
|
||||
licenseExpired: 'License Expired',
|
||||
licenseExpiredTip: 'The Dify Enterprise license for your workspace has expired. Please contact your administrator to continue using Dify.',
|
||||
licenseInactive: 'License Inactive',
|
||||
licenseInactiveTip: 'The Dify Enterprise license for your workspace is inactive. Please contact your administrator to continue using Dify.',
|
||||
}
|
||||
|
||||
export default translation
|
||||
|
|
|
@ -591,6 +591,10 @@ const translation = {
|
|||
created: '标签创建成功',
|
||||
failed: '标签创建失败',
|
||||
},
|
||||
license: {
|
||||
expiring: '许可证还有 1 天到期',
|
||||
expiring_plural: '许可证还有 {{count}} 天到期',
|
||||
},
|
||||
}
|
||||
|
||||
export default translation
|
||||
|
|
|
@ -99,6 +99,10 @@ const translation = {
|
|||
back: '返回',
|
||||
noLoginMethod: '未配置身份认证方式',
|
||||
noLoginMethodTip: '请联系系统管理员添加身份认证方式',
|
||||
licenseExpired: '许可证已过期',
|
||||
licenseExpiredTip: '您所在空间的 Dify Enterprise 许可证已过期,请联系管理员以继续使用 Dify。',
|
||||
licenseInactive: '许可证未激活',
|
||||
licenseInactiveTip: '您所在空间的 Dify Enterprise 许可证尚未激活,请联系管理员以继续使用 Dify。',
|
||||
}
|
||||
|
||||
export default translation
|
||||
|
|
|
@ -4,6 +4,20 @@ export enum SSOProtocol {
|
|||
OAuth2 = 'oauth2',
|
||||
}
|
||||
|
||||
export enum LicenseStatus {
|
||||
NONE = 'none',
|
||||
INACTIVE = 'inactive',
|
||||
ACTIVE = 'active',
|
||||
EXPIRING = 'expiring',
|
||||
EXPIRED = 'expired',
|
||||
LOST = 'lost',
|
||||
}
|
||||
|
||||
type License = {
|
||||
status: LicenseStatus
|
||||
expired_at: string | null
|
||||
}
|
||||
|
||||
export type SystemFeatures = {
|
||||
sso_enforced_for_signin: boolean
|
||||
sso_enforced_for_signin_protocol: SSOProtocol | ''
|
||||
|
@ -15,6 +29,7 @@ export type SystemFeatures = {
|
|||
enable_social_oauth_login: boolean
|
||||
is_allow_create_workspace: boolean
|
||||
is_allow_register: boolean
|
||||
license: License
|
||||
}
|
||||
|
||||
export const defaultSystemFeatures: SystemFeatures = {
|
||||
|
@ -28,4 +43,8 @@ export const defaultSystemFeatures: SystemFeatures = {
|
|||
enable_social_oauth_login: false,
|
||||
is_allow_create_workspace: false,
|
||||
is_allow_register: false,
|
||||
license: {
|
||||
status: LicenseStatus.NONE,
|
||||
expired_at: '',
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user