Skip to content

Commit a64cdff

Browse files
author
Akos Kitta
committed
feat: introduced cloud state in sketchbook view
Closes #1879 Signed-off-by: Akos Kitta <[email protected]>
1 parent 4deaf4f commit a64cdff

23 files changed

+584
-134
lines changed

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",

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
});

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

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
Loading

arduino-ide-extension/src/browser/style/account-icon.svg

-1
This file was deleted.

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

+39-4
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
.p-TabBar-tabIcon.cloud-sketchbook-tree-icon {
1717
background-color: var(--theia-foreground);
18-
-webkit-mask: url(./cloud-sketchbook-tree-icon.svg);
18+
-webkit-mask: url(../icons/cloud.svg);
1919
-webkit-mask-position: center;
2020
-webkit-mask-repeat: no-repeat;
21-
width: var(--theia-icon-size);
21+
width: 19px !important;
2222
height: var(--theia-icon-size);
2323
-webkit-mask-size: 100%;
2424
}
2525

2626
.p-mod-current
2727
.cloud-sketchbook-tree-icon {
2828
background-color: var(--theia-foreground);
29-
-webkit-mask: url(./cloud-sketchbook-tree-icon-filled.svg);
29+
-webkit-mask: url(../icons/cloud-filled.svg);
3030
-webkit-mask-position: center;
3131
-webkit-mask-repeat: no-repeat;
3232
-webkit-mask-size: 100%;
@@ -118,7 +118,6 @@
118118
}
119119

120120
.account-icon {
121-
background: url("./account-icon.svg") center center no-repeat;
122121
width: var(--theia-private-sidebar-icon-size);
123122
height: var(--theia-private-sidebar-icon-size);
124123
border-radius: 50%;
@@ -199,3 +198,39 @@
199198
.arduino-share-sketch-dialog .sketch-link-embed textarea {
200199
width: 100%;
201200
}
201+
202+
.theia-file-icons-js.file-icon > .sketch-folder-icon {
203+
-webkit-mask-position: center;
204+
-webkit-mask-repeat: no-repeat;
205+
-webkit-mask-size: 100%;
206+
width: var(--theia-icon-size);
207+
height: var(--theia-icon-size);
208+
background-color: var(--theia-foreground);
209+
}
210+
211+
.theia-file-icons-js.file-icon > .sketch-folder-icon.cloud {
212+
-webkit-mask: url('../icons/cloud.svg');
213+
}
214+
215+
.theia-file-icons-js.file-icon > .sketch-folder-icon.cloud.offline {
216+
-webkit-mask: url('../icons/cloud-offline.svg');
217+
background-color: var(--theia-activityBar-inactiveForeground);
218+
}
219+
220+
.theia-file-icons-js.file-icon > .sketch-folder-icon.cloud.synced {
221+
-webkit-mask: url('../icons/cloud-filled.svg');
222+
}
223+
224+
.theia-TreeNodeContent > .theia-file-icons-js.file-icon > .sketch-folder-icon.cloud.synced.offline {
225+
-webkit-mask: url('../icons/cloud-filled-offline.svg');
226+
}
227+
228+
.sketch-folder-icon.cloud.offline.action {
229+
-webkit-mask: url('../icons/cloud-offline.svg');
230+
-webkit-mask-position: center;
231+
-webkit-mask-repeat: no-repeat;
232+
-webkit-mask-size: 100%;
233+
width: var(--theia-icon-size);
234+
height: var(--theia-icon-size);
235+
background-color: var(--theia-foreground);
236+
}

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

-4
This file was deleted.

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)