Skip to content

Commit dcc7cc9

Browse files
author
Akos Kitta
committed
feat: introduced cloud state in sketchbook view
Closes #1879 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 4deaf4f commit dcc7cc9

23 files changed

+578
-157
lines changed

Diff for: arduino-ide-extension/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"glob": "^7.1.6",
7878
"google-protobuf": "^3.20.1",
7979
"hash.js": "^1.1.7",
80+
"is-online": "^9.0.1",
8081
"js-yaml": "^3.13.1",
8182
"just-diff": "^5.1.1",
8283
"jwt-decode": "^3.1.2",

Diff for: arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+4-25
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import * as remote from '@theia/core/electron-shared/@electron/remote';
2-
import {
3-
inject,
4-
injectable,
5-
postConstruct,
6-
} from '@theia/core/shared/inversify';
2+
import { inject, injectable } from '@theia/core/shared/inversify';
73
import * as React from '@theia/core/shared/react';
84
import {
95
MAIN_MENU_BAR,
@@ -23,7 +19,6 @@ import {
2319
CommandContribution,
2420
CommandRegistry,
2521
} from '@theia/core/lib/common/command';
26-
import { MessageService } from '@theia/core/lib/common/message-service';
2722
import { EditorCommands, EditorMainMenu } from '@theia/editor/lib/browser';
2823
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
2924
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
@@ -46,9 +41,6 @@ export class ArduinoFrontendContribution
4641
MenuContribution,
4742
ColorContribution
4843
{
49-
@inject(MessageService)
50-
private readonly messageService: MessageService;
51-
5244
@inject(BoardsServiceProvider)
5345
private readonly boardsServiceProvider: BoardsServiceProvider;
5446

@@ -61,19 +53,6 @@ export class ArduinoFrontendContribution
6153
@inject(FrontendApplicationStateService)
6254
private readonly appStateService: FrontendApplicationStateService;
6355

64-
@postConstruct()
65-
protected async init(): Promise<void> {
66-
if (!window.navigator.onLine) {
67-
// tslint:disable-next-line:max-line-length
68-
this.messageService.warn(
69-
nls.localize(
70-
'arduino/common/offlineIndicator',
71-
'You appear to be offline. Without an Internet connection, the Arduino CLI might not be able to download the required resources and could cause malfunction. Please connect to the Internet and restart the application.'
72-
)
73-
);
74-
}
75-
}
76-
7756
onStart(): void {
7857
this.electronWindowPreferences.onPreferenceChanged((event) => {
7958
if (event.newValue !== event.oldValue) {
@@ -87,14 +66,14 @@ export class ArduinoFrontendContribution
8766
}
8867
}
8968
});
90-
this.appStateService.reachedState('ready').then(() =>
69+
this.appStateService.reachedState('ready').then(() => {
9170
this.electronWindowPreferences.ready.then(() => {
9271
const webContents = remote.getCurrentWebContents();
9372
const zoomLevel =
9473
this.electronWindowPreferences.get('window.zoomLevel');
9574
webContents.setZoomLevel(zoomLevel);
96-
})
97-
);
75+
});
76+
});
9877
}
9978

10079
registerToolbarItems(registry: TabBarToolbarRegistry): void {

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ import { EditorCommandContribution as TheiaEditorCommandContribution } from '@th
9090
import {
9191
FrontendConnectionStatusService,
9292
ApplicationConnectionStatusContribution,
93+
DaemonPort,
94+
IsOnline,
9395
} from './theia/core/connection-status-service';
9496
import {
9597
FrontendConnectionStatusService as TheiaFrontendConnectionStatusService,
@@ -1021,4 +1023,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
10211023

10221024
bind(SidebarBottomMenuWidget).toSelf();
10231025
rebind(TheiaSidebarBottomMenuWidget).toService(SidebarBottomMenuWidget);
1026+
bind(DaemonPort).toSelf().inSingletonScope();
1027+
bind(FrontendApplicationContribution).toService(DaemonPort);
1028+
bind(IsOnline).toSelf().inSingletonScope();
1029+
bind(FrontendApplicationContribution).toService(IsOnline);
10241030
});

Diff for: arduino-ide-extension/src/browser/contributions/account.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { inject, injectable } from '@theia/core/shared/inversify';
88
import { CloudUserCommands, LEARN_MORE_URL } from '../auth/cloud-user-commands';
99
import { CreateFeatures } from '../create/create-features';
1010
import { ArduinoMenus } from '../menu/arduino-menus';
11+
import { ApplicationConnectionStatusContribution } from '../theia/core/connection-status-service';
1112
import {
1213
Command,
1314
CommandRegistry,
@@ -29,6 +30,8 @@ export class Account extends Contribution {
2930
private readonly windowService: WindowService;
3031
@inject(CreateFeatures)
3132
private readonly createFeatures: CreateFeatures;
33+
@inject(ApplicationConnectionStatusContribution)
34+
private readonly connectionStatus: ApplicationConnectionStatusContribution;
3235

3336
private readonly toDispose = new DisposableCollection();
3437
private app: FrontendApplication;
@@ -50,21 +53,28 @@ export class Account extends Contribution {
5053
override registerCommands(registry: CommandRegistry): void {
5154
const openExternal = (url: string) =>
5255
this.windowService.openNewWindow(url, { external: true });
56+
const loggedIn = () => Boolean(this.createFeatures.session);
57+
const loggedInWithInternetConnection = () =>
58+
loggedIn() && this.connectionStatus.offlineStatus !== 'internet';
5359
registry.registerCommand(Account.Commands.LEARN_MORE, {
5460
execute: () => openExternal(LEARN_MORE_URL),
55-
isEnabled: () => !Boolean(this.createFeatures.session),
61+
isEnabled: () => !loggedIn(),
62+
isVisible: () => !loggedIn(),
5663
});
5764
registry.registerCommand(Account.Commands.GO_TO_PROFILE, {
5865
execute: () => openExternal('https://id.arduino.cc/'),
59-
isEnabled: () => Boolean(this.createFeatures.session),
66+
isEnabled: () => loggedInWithInternetConnection(),
67+
isVisible: () => loggedIn(),
6068
});
6169
registry.registerCommand(Account.Commands.GO_TO_CLOUD_EDITOR, {
6270
execute: () => openExternal('https://create.arduino.cc/editor'),
63-
isEnabled: () => Boolean(this.createFeatures.session),
71+
isEnabled: () => loggedInWithInternetConnection(),
72+
isVisible: () => loggedIn(),
6473
});
6574
registry.registerCommand(Account.Commands.GO_TO_IOT_CLOUD, {
6675
execute: () => openExternal('https://create.arduino.cc/iot/'),
67-
isEnabled: () => Boolean(this.createFeatures.session),
76+
isEnabled: () => loggedInWithInternetConnection(),
77+
isVisible: () => loggedIn(),
6878
});
6979
}
7080

Diff for: arduino-ide-extension/src/browser/contributions/contribution.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
1414
import { MessageService } from '@theia/core/lib/common/message-service';
1515
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
1616
import { open, OpenerService } from '@theia/core/lib/browser/opener-service';
17-
1817
import {
1918
MenuModelRegistry,
2019
MenuContribution,
@@ -58,7 +57,7 @@ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
5857
import { ExecuteWithProgress } from '../../common/protocol/progressible';
5958
import { BoardsServiceProvider } from '../boards/boards-service-provider';
6059
import { BoardsDataStore } from '../boards/boards-data-store';
61-
import { NotificationManager } from '../theia/messages/notifications-manager';
60+
import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager';
6261
import { MessageType } from '@theia/core/lib/common/message-service-protocol';
6362
import { WorkspaceService } from '../theia/workspace/workspace-service';
6463
import { MainMenuManager } from '../../common/main-menu-manager';
@@ -295,7 +294,7 @@ export abstract class CoreServiceContribution extends SketchContribution {
295294
}
296295

297296
private notificationId(message: string, ...actions: string[]): string {
298-
return this.notificationManager.getMessageId({
297+
return this.notificationManager['getMessageId']({
299298
text: message,
300299
actions,
301300
type: MessageType.Error,
Loading
Loading
Loading

Diff for: arduino-ide-extension/src/browser/icons/cloud.svg

+3
Loading

Diff for: arduino-ide-extension/src/browser/style/cloud-sketchbook.css

+40
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,43 @@
199199
.arduino-share-sketch-dialog .sketch-link-embed textarea {
200200
width: 100%;
201201
}
202+
203+
.cloud-sketch-folder-icon {
204+
-webkit-mask: url('../icons/cloud.svg');
205+
background-color: var(--theia-foreground);
206+
-webkit-mask-position: center;
207+
-webkit-mask-repeat: no-repeat;
208+
width: var(--theia-icon-size);
209+
height: var(--theia-icon-size);
210+
-webkit-mask-size: 100%;
211+
}
212+
213+
.cloud-sketch-folder-icon.offline {
214+
-webkit-mask: url('../icons/cloud-offline.svg');
215+
background-color: var(--theia-activityBar-inactiveForeground);
216+
-webkit-mask-position: center;
217+
-webkit-mask-repeat: no-repeat;
218+
width: var(--theia-icon-size);
219+
height: var(--theia-icon-size);
220+
-webkit-mask-size: 100%;
221+
}
222+
223+
.cloud-sketch-folder-icon.synced {
224+
-webkit-mask: url('../icons/cloud-filled.svg');
225+
background-color: var(--theia-foreground);
226+
-webkit-mask-position: center;
227+
-webkit-mask-repeat: no-repeat;
228+
width: var(--theia-icon-size);
229+
height: var(--theia-icon-size);
230+
-webkit-mask-size: 100%;
231+
}
232+
233+
.cloud-sketch-folder-icon.synced.offline {
234+
-webkit-mask: url('../icons/cloud-filled-offline.svg');
235+
background-color: var(--theia-foreground);
236+
-webkit-mask-position: center;
237+
-webkit-mask-repeat: no-repeat;
238+
width: var(--theia-icon-size);
239+
height: var(--theia-icon-size);
240+
-webkit-mask-size: 100%;
241+
}

Diff for: arduino-ide-extension/src/browser/style/sketch-folder-icon.svg

-4
This file was deleted.

Diff for: arduino-ide-extension/src/browser/style/sketchbook.css

-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
mask: url('./sketchbook.svg');
44
}
55

6-
.sketch-folder-icon {
7-
background: url('./sketch-folder-icon.svg') center center no-repeat;
8-
background-position-x: 1px;
9-
width: var(--theia-icon-size);
10-
height: var(--theia-icon-size);
11-
}
12-
136
.p-TabBar-tabIcon.sketchbook-tree-icon {
147
background-color: var(--theia-foreground);
158
-webkit-mask: url(./sketchbook-tree-icon.svg);

0 commit comments

Comments
 (0)