9
9
MODULE_APPLICATIONS_URL ,
10
10
QUERY_LIBRARY_URL ,
11
11
SETTING ,
12
+ SUPPORT ,
12
13
TRASH_URL ,
13
14
// ADMIN_APP_URL,
14
15
NEWS_URL ,
@@ -26,6 +27,7 @@ import {
26
27
HomeModuleIcon ,
27
28
HomeQueryLibraryIcon ,
28
29
HomeSettingIcon ,
30
+ SupportIcon ,
29
31
PlusIcon ,
30
32
PointIcon ,
31
33
RecyclerIcon ,
@@ -34,7 +36,7 @@ import {
34
36
EnterpriseIcon ,
35
37
UserIcon ,
36
38
} from "lowcoder-design" ;
37
- import React , { useEffect , useState } from "react" ;
39
+ import React , { useEffect , useState , useMemo } from "react" ;
38
40
import { fetchAllApplications , fetchHomeData } from "redux/reduxActions/applicationActions" ;
39
41
import { getHomeOrg , normalAppListSelector } from "redux/selectors/applicationSelector" ;
40
42
import { DatasourceHome } from "../datasource" ;
@@ -64,6 +66,7 @@ import Setting from "pages/setting";
64
66
import { TypographyText } from "../../components/TypographyText" ;
65
67
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances" ;
66
68
import { isEE } from "util/envUtils" ;
69
+ import { checkSubscriptions , SubscriptionProducts } from "@lowcoder-ee/api/subscriptionApi" ;
67
70
68
71
// adding App Editor, so we can show Apps inside the Admin Area
69
72
import AppEditor from "../editor/AppEditor" ;
@@ -149,24 +152,20 @@ const FolderName = (props: { id: string; name: string }) => {
149
152
) ;
150
153
} ;
151
154
152
- const MoreFoldersWrapper = styled . div < { $selected : boolean } > `
155
+ const MoreFoldersWrapper = styled . div `
153
156
${ ( props ) => {
154
- if ( props . $selected ) {
155
- return css `
156
- font-weight: 500;
157
- ` ;
158
- }
157
+ return css ` font-weight: 500;` ;
159
158
} }
160
159
` ;
161
160
162
- const MoreFoldersIcon = styled ( PointIcon ) < { $selected : boolean } > `
161
+ /* const MoreFoldersIcon = styled(PointIcon)<{ $selected: boolean }>`
163
162
cursor: pointer;
164
163
flex-shrink: 0;
165
164
166
165
g {
167
166
fill: ${(props) => (props.$selected ? "#4965f2" : "#8b8fa3")};
168
167
}
169
- ` ;
168
+ `; */
170
169
171
170
const PopoverIcon = styled ( PointIcon ) `
172
171
cursor: pointer;
@@ -188,26 +187,6 @@ const PopoverIcon = styled(PointIcon)`
188
187
}
189
188
` ;
190
189
191
- const InviteUser = styled . div `
192
- position: absolute;
193
- display: flex;
194
- align-items: center;
195
- left: 10px;
196
- top: calc(100vh - 60px);
197
- padding: 12px 26px;
198
- font-size: 14px;
199
- cursor: pointer;
200
- width: 219px;
201
-
202
- &:hover {
203
- color: #315efb;
204
-
205
- svg g g {
206
- stroke: #315efb;
207
- }
208
- }
209
- ` ;
210
-
211
190
const CreateFolderIcon = styled . div `
212
191
margin-left: auto;
213
192
cursor: pointer;
@@ -259,10 +238,29 @@ export default function ApplicationHome() {
259
238
const orgHomeId = "root" ;
260
239
const isSelfHost = window . location . host !== 'app.lowcoder.cloud' ;
261
240
262
- const handleFolderCreate = useCreateFolder ( ) ;
241
+ const subscriptions = useSelector ( state => state . subscriptions . subscriptions ) ;
242
+ const subscriptionDataLoaded = useSelector ( state => ! state . subscriptions . loading ) ;
243
+ const subscriptionDataError = useSelector ( state => state . subscriptions . error ) ;
244
+
245
+ // const handleFolderCreate = useCreateFolder();
263
246
264
247
const isOrgAdmin = org ?. createdBy == user . id ? true : false ;
265
248
249
+ // Fetch subscriptions once on component mount
250
+ useEffect ( ( ) => {
251
+ dispatch ( checkSubscriptions ( ) ) ;
252
+ } , [ dispatch ] ) ;
253
+
254
+ // Calculate support subscription status
255
+ const supportSubscription = useMemo ( ( ) => {
256
+ return subscriptions . some ( ( sub : { product : SubscriptionProducts ; } ) => sub . product === SubscriptionProducts . SUPPORT ) ;
257
+ } , [ subscriptions ] ) ;
258
+
259
+ // Early return if data is still loading or there was an error
260
+ if ( fetchingUser || ! subscriptionDataLoaded || subscriptionDataError ) {
261
+ return < ProductLoading /> ;
262
+ }
263
+
266
264
useEffect ( ( ) => {
267
265
dispatch ( fetchHomeData ( { } ) ) ;
268
266
} , [ user . currentOrgId ] ) ;
@@ -298,52 +296,8 @@ export default function ApplicationHome() {
298
296
return < ProductLoading /> ;
299
297
}
300
298
301
- let folderItems : SideBarItemType [ ] = allFolders
302
- . sort ( ( a , b ) => {
303
- if ( a . createAt === b . createAt ) {
304
- return 0 ;
305
- }
306
- return a . createAt < b . createAt ? 1 : - 1 ;
307
- } )
308
- . slice ( 0 , 5 )
309
- . map ( ( folder ) => {
310
- const path = FOLDER_URL_PREFIX + `/${ folder . folderId } ` ;
311
- return {
312
- onSelected : ( _ , currentPath ) => currentPath === path ,
313
- text : ( props : { selected ?: boolean } ) => (
314
- < FolderNameWrapper $selected = { Boolean ( props . selected ) } >
315
- < FolderName name = { folder . name } id = { folder . folderId } />
316
- </ FolderNameWrapper >
317
- ) ,
318
- routePath : FOLDER_URL ,
319
- routePathExact : false ,
320
- routeComp : FolderView ,
321
- icon : FolderIcon ,
322
- size : "small" ,
323
- onClick : ( currentPath ) => currentPath !== path && history . push ( path ) ,
324
- } ;
325
- } ) ;
326
-
327
- if ( allFolders . length > 1 ) {
328
- folderItems = [
329
- ...folderItems ,
330
- {
331
- text : ( props : { selected ?: boolean } ) => (
332
- < MoreFoldersWrapper $selected = { Boolean ( props . selected ) } > { trans ( "home.allFolders" ) } </ MoreFoldersWrapper >
333
- ) ,
334
- routePath : FOLDERS_URL ,
335
- routeComp : RootFolderListView ,
336
- icon : MoreFoldersIcon ,
337
- size : "small" ,
338
- } ,
339
- ] ;
340
- }
341
-
342
- if ( folderItems . length > 0 ) {
343
- folderItems [ folderItems . length - 1 ] = {
344
- ...folderItems [ folderItems . length - 1 ] ,
345
- style : { marginBottom : "4px" } ,
346
- } ;
299
+ if ( fetchingUser || ! isPreloadCompleted || ! subscriptionDataLoaded || subscriptionDataError ) {
300
+ return < ProductLoading /> ;
347
301
}
348
302
349
303
return (
@@ -386,41 +340,21 @@ export default function ApplicationHome() {
386
340
387
341
{
388
342
items : [
343
+ {
344
+ text : < MoreFoldersWrapper > { trans ( "home.allFolders" ) } </ MoreFoldersWrapper > ,
345
+ routePath : FOLDERS_URL ,
346
+ routeComp : RootFolderListView ,
347
+ icon : ( { selected, ...otherProps } ) => selected ? < FolderIcon { ...otherProps } width = { "24px" } /> : < FolderIcon { ...otherProps } width = { "24px" } /> ,
348
+ } ,
389
349
{
390
350
text : < TabLabel > { trans ( "home.allApplications" ) } </ TabLabel > ,
391
351
routePath : ALL_APPLICATIONS_URL ,
392
352
routeComp : HomeView ,
393
353
icon : ( { selected, ...otherProps } ) => selected ? < AppsIcon { ...otherProps } width = { "24px" } /> : < AppsIcon { ...otherProps } width = { "24px" } /> ,
394
354
} ,
395
- {
396
- text : < TabLabel > { trans ( "home.allModules" ) } </ TabLabel > ,
397
- routePath : MODULE_APPLICATIONS_URL ,
398
- routeComp : ModuleView ,
399
- icon : ( { selected, ...otherProps } ) => selected ? < HomeModuleIcon { ...otherProps } width = { "24px" } /> : < HomeModuleIcon { ...otherProps } width = { "24px" } /> ,
400
- visible : ( { user } ) => isOrgAdmin ,
401
- } ,
402
-
403
355
] ,
404
356
} ,
405
-
406
- allFolders . length > 0
407
- ? {
408
- title : (
409
- < FolderSectionLabel >
410
- { trans ( "home.yourFolders" ) }
411
- < FolderCountLabel > { `(${ allFolders . length } )` } </ FolderCountLabel >
412
- { user . orgDev && (
413
- < CreateFolderIcon onClick = { handleFolderCreate } >
414
- < PlusIcon />
415
- </ CreateFolderIcon >
416
- ) }
417
- </ FolderSectionLabel >
418
- ) ,
419
- items : folderItems ,
420
- style : { marginTop : "8px" } ,
421
- }
422
- : { items : [ ] } ,
423
-
357
+
424
358
{
425
359
items : [
426
360
@@ -455,6 +389,17 @@ export default function ApplicationHome() {
455
389
] ,
456
390
} : { items : [ ] } ,
457
391
392
+ supportSubscription ? {
393
+ items : [
394
+ {
395
+ text : < TabLabel > { trans ( "home.trash" ) } </ TabLabel > ,
396
+ routePath : TRASH_URL ,
397
+ routeComp : TrashView ,
398
+ icon : ( { selected, ...otherProps } ) => selected ? < RecyclerIcon { ...otherProps } width = { "24px" } /> : < RecyclerIcon { ...otherProps } width = { "24px" } /> ,
399
+ } ,
400
+ ] ,
401
+ } : { items : [ ] } ,
402
+
458
403
{
459
404
items : [
460
405
{
@@ -465,7 +410,7 @@ export default function ApplicationHome() {
465
410
icon : ( { selected, ...otherProps } ) => selected ? < HomeSettingIcon { ...otherProps } width = { "24px" } /> : < HomeSettingIcon { ...otherProps } width = { "24px" } /> ,
466
411
visible : ( { user } ) => user . orgDev ,
467
412
onSelected : ( _ , currentPath ) => currentPath . split ( "/" ) [ 1 ] === "setting" ,
468
- } ,
413
+ }
469
414
]
470
415
} ,
471
416
@@ -483,20 +428,6 @@ export default function ApplicationHome() {
483
428
484
429
] }
485
430
/>
486
-
487
- { /*
488
- // we have the invite dialog in the Admin Area, so we don't need it here
489
- {user.orgDev && (
490
- <InviteDialog
491
- trigger={
492
- <InviteUser>
493
- <InviteUserIcon style={{ marginRight: "8px" }} />
494
- {trans("home.inviteUser")}
495
- </InviteUser>
496
- }
497
- style={{ marginLeft: "auto" }}
498
- />
499
- )} */ }
500
431
</ DivStyled >
501
432
) ;
502
433
}
0 commit comments