1
1
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info' ;
2
+ import { ServerService } from '@affine/core/modules/cloud' ;
2
3
import type { SettingTab } from '@affine/core/modules/dialogs/constant' ;
3
4
import { WorkspaceService } from '@affine/core/modules/workspace' ;
5
+ import { ServerDeploymentType } from '@affine/graphql' ;
4
6
import { useI18n } from '@affine/i18n' ;
5
7
import {
6
8
CollaborationIcon ,
@@ -9,11 +11,12 @@ import {
9
11
SaveIcon ,
10
12
SettingsIcon ,
11
13
} from '@blocksuite/icons/rc' ;
12
- import { useService } from '@toeverything/infra' ;
14
+ import { useLiveData , useService } from '@toeverything/infra' ;
13
15
import { useMemo } from 'react' ;
14
16
15
17
import type { SettingSidebarItem , SettingState } from '../types' ;
16
18
import { WorkspaceSettingBilling } from './billing' ;
19
+ import { WorkspaceSettingLicense } from './license' ;
17
20
import { MembersPanel } from './members' ;
18
21
import { WorkspaceSettingDetail } from './preference' ;
19
22
import { WorkspaceSettingProperties } from './properties' ;
@@ -44,6 +47,8 @@ export const WorkspaceSetting = ({
44
47
return < WorkspaceSettingBilling /> ;
45
48
case 'workspace:storage' :
46
49
return < WorkspaceSettingStorage onCloseSetting = { onCloseSetting } /> ;
50
+ case 'workspace:license' :
51
+ return < WorkspaceSettingLicense /> ;
47
52
default :
48
53
return null ;
49
54
}
@@ -52,10 +57,18 @@ export const WorkspaceSetting = ({
52
57
export const useWorkspaceSettingList = ( ) : SettingSidebarItem [ ] => {
53
58
const workspaceService = useService ( WorkspaceService ) ;
54
59
const information = useWorkspaceInfo ( workspaceService . workspace ) ;
60
+ const serverService = useService ( ServerService ) ;
61
+
62
+ const isSelfhosted = useLiveData (
63
+ serverService . server . config$ . selector (
64
+ c => c . type === ServerDeploymentType . Selfhosted
65
+ )
66
+ ) ;
55
67
56
68
const t = useI18n ( ) ;
57
69
58
70
const showBilling = information ?. isTeam && information ?. isOwner ;
71
+ const showLicense = information ?. isOwner && isSelfhosted ;
59
72
const items = useMemo < SettingSidebarItem [ ] > ( ( ) => {
60
73
return [
61
74
{
@@ -88,10 +101,14 @@ export const useWorkspaceSettingList = (): SettingSidebarItem[] => {
88
101
icon : < PaymentIcon /> ,
89
102
testId : 'workspace-setting:billing' ,
90
103
} ,
91
-
92
- // todo(@pengx17): add selfhost's team license
104
+ showLicense && {
105
+ key : 'workspace:license' as SettingTab ,
106
+ title : t [ 'com.affine.settings.workspace.license' ] ( ) ,
107
+ icon : < PaymentIcon /> ,
108
+ testId : 'workspace-setting:license' ,
109
+ } ,
93
110
] . filter ( ( item ) : item is SettingSidebarItem => ! ! item ) ;
94
- } , [ showBilling , t ] ) ;
111
+ } , [ showBilling , showLicense , t ] ) ;
95
112
96
113
return items ;
97
114
} ;
0 commit comments