@@ -8,6 +8,7 @@ import { inject, injectable } from '@theia/core/shared/inversify';
8
8
import { CloudUserCommands , LEARN_MORE_URL } from '../auth/cloud-user-commands' ;
9
9
import { CreateFeatures } from '../create/create-features' ;
10
10
import { ArduinoMenus } from '../menu/arduino-menus' ;
11
+ import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service' ;
11
12
import {
12
13
Command ,
13
14
CommandRegistry ,
@@ -29,6 +30,8 @@ export class Account extends Contribution {
29
30
private readonly windowService : WindowService ;
30
31
@inject ( CreateFeatures )
31
32
private readonly createFeatures : CreateFeatures ;
33
+ @inject ( ApplicationConnectionStatusContribution )
34
+ private readonly connectionStatus : ApplicationConnectionStatusContribution ;
32
35
33
36
private readonly toDispose = new DisposableCollection ( ) ;
34
37
private app : FrontendApplication ;
@@ -50,21 +53,28 @@ export class Account extends Contribution {
50
53
override registerCommands ( registry : CommandRegistry ) : void {
51
54
const openExternal = ( url : string ) =>
52
55
this . windowService . openNewWindow ( url , { external : true } ) ;
56
+ const loggedIn = ( ) => Boolean ( this . createFeatures . session ) ;
57
+ const loggedInWithInternetConnection = ( ) =>
58
+ loggedIn ( ) && this . connectionStatus . offlineStatus !== 'internet' ;
53
59
registry . registerCommand ( Account . Commands . LEARN_MORE , {
54
60
execute : ( ) => openExternal ( LEARN_MORE_URL ) ,
55
- isEnabled : ( ) => ! Boolean ( this . createFeatures . session ) ,
61
+ isEnabled : ( ) => ! loggedIn ( ) ,
62
+ isVisible : ( ) => ! loggedIn ( ) ,
56
63
} ) ;
57
64
registry . registerCommand ( Account . Commands . GO_TO_PROFILE , {
58
65
execute : ( ) => openExternal ( 'https://id.arduino.cc/' ) ,
59
- isEnabled : ( ) => Boolean ( this . createFeatures . session ) ,
66
+ isEnabled : ( ) => loggedInWithInternetConnection ( ) ,
67
+ isVisible : ( ) => loggedIn ( ) ,
60
68
} ) ;
61
69
registry . registerCommand ( Account . Commands . GO_TO_CLOUD_EDITOR , {
62
70
execute : ( ) => openExternal ( 'https://create.arduino.cc/editor' ) ,
63
- isEnabled : ( ) => Boolean ( this . createFeatures . session ) ,
71
+ isEnabled : ( ) => loggedInWithInternetConnection ( ) ,
72
+ isVisible : ( ) => loggedIn ( ) ,
64
73
} ) ;
65
74
registry . registerCommand ( Account . Commands . GO_TO_IOT_CLOUD , {
66
75
execute : ( ) => openExternal ( 'https://create.arduino.cc/iot/' ) ,
67
- isEnabled : ( ) => Boolean ( this . createFeatures . session ) ,
76
+ isEnabled : ( ) => loggedInWithInternetConnection ( ) ,
77
+ isVisible : ( ) => loggedIn ( ) ,
68
78
} ) ;
69
79
}
70
80
0 commit comments