Skip to content

Commit 874c3ef

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-663: Indicate alpha status. Updated the About dialog.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 7b364eb commit 874c3ef

File tree

13 files changed

+114
-49
lines changed

13 files changed

+114
-49
lines changed

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ import { TabBarDecoratorService } from './theia/core/tab-bar-decorator';
5757
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser';
5858
import { ProblemManager } from './theia/markers/problem-manager';
5959
import { BoardsAutoInstaller } from './boards/boards-auto-installer';
60-
import { AboutDialog as TheiaAboutDialog } from '@theia/core/lib/browser/about-dialog';
61-
import { AboutDialog } from './theia/core/about-dialog';
6260
import { ShellLayoutRestorer } from './theia/core/shell-layout-restorer';
6361
import { EditorMode } from './editor-mode';
6462
import { ListItemRenderer } from './widgets/component-list/list-item-renderer';
@@ -121,11 +119,12 @@ import { OutputServiceImpl } from './output-service-impl';
121119
import { OutputServicePath, OutputService } from '../common/protocol/output-service';
122120
import { NotificationCenter } from './notification-center';
123121
import { NotificationServicePath, NotificationServiceServer } from '../common/protocol';
122+
import { About } from './contributions/about';
124123

125124
const ElementQueries = require('css-element-queries/src/ElementQueries');
126125

127126
MonacoThemingService.register({
128-
id: 'arduinoTheme',
127+
id: 'arduino-theme',
129128
label: 'Light (Arduino)',
130129
uiTheme: 'vs',
131130
json: require('../../src/browser/data/arduino.color-theme.json')
@@ -289,10 +288,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
289288
bind(ProblemManager).toSelf().inSingletonScope();
290289
rebind(TheiaProblemManager).toService(ProblemManager);
291290

292-
// About dialog to show the CLI version
293-
bind(AboutDialog).toSelf().inSingletonScope();
294-
rebind(TheiaAboutDialog).toService(AboutDialog);
295-
296291
// Customized layout restorer that can restore the state in async way: https://github.com/eclipse-theia/theia/issues/6579
297292
bind(ShellLayoutRestorer).toSelf().inSingletonScope();
298293
rebind(TheiaShellLayoutRestorer).toService(ShellLayoutRestorer);
@@ -324,6 +319,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
324319
Contribution.configure(bind, BuiltInExamples);
325320
Contribution.configure(bind, LibraryExamples);
326321
Contribution.configure(bind, IncludeLibrary);
322+
Contribution.configure(bind, About);
327323

328324
bind(OutputServiceImpl).toSelf().inSingletonScope().onActivation(({ container }, outputService) => {
329325
WebSocketConnectionProvider.createProxy(container, OutputServicePath, outputService);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { inject, injectable } from 'inversify';
2+
import { remote } from 'electron';
3+
import { isOSX, isWindows } from '@theia/core/lib/common/os';
4+
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
5+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
6+
import { Contribution, Command, MenuModelRegistry, CommandRegistry } from './contribution';
7+
import { ArduinoMenus } from '../menu/arduino-menus';
8+
import { ConfigService } from '../../common/protocol';
9+
10+
@injectable()
11+
export class About extends Contribution {
12+
13+
@inject(ClipboardService)
14+
protected readonly clipboardService: ClipboardService;
15+
16+
@inject(ConfigService)
17+
protected readonly configService: ConfigService;
18+
19+
registerCommands(registry: CommandRegistry): void {
20+
registry.registerCommand(About.Commands.ABOUT_APP, {
21+
execute: () => this.showAbout()
22+
});
23+
}
24+
25+
registerMenus(registry: MenuModelRegistry): void {
26+
// On macOS we will get the `Quit ${YOUR_APP_NAME}` menu item natively, no need to duplicate it.
27+
registry.registerMenuAction(ArduinoMenus.HELP__ABOUT_GROUP, {
28+
commandId: About.Commands.ABOUT_APP.id,
29+
label: `About${isOSX ? ` ${this.applicationName}` : ''}`,
30+
order: '0'
31+
});
32+
}
33+
34+
async showAbout(): Promise<void> {
35+
const ideStatus = FrontendApplicationConfigProvider.get()['status'];
36+
const { version, commit, status: cliStatus } = await this.configService.getVersion();
37+
const detail = `
38+
Version: ${remote.app.getVersion()}
39+
CLI Version: ${version}${cliStatus ? ` ${cliStatus}` : ''} [${commit}]
40+
41+
Copyright © ${new Date().getFullYear()} Arduino SA
42+
`;
43+
const ok = 'OK';
44+
const copy = 'Copy';
45+
const buttons = !isWindows && !isOSX ? [copy, ok] : [ok, copy];
46+
const { response } = await remote.dialog.showMessageBox(remote.getCurrentWindow(), {
47+
message: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
48+
title: `${this.applicationName}${ideStatus ? ` – ${ideStatus}` : ''}`,
49+
type: 'info',
50+
detail,
51+
buttons,
52+
noLink: true,
53+
defaultId: buttons.indexOf(ok),
54+
cancelId: buttons.indexOf(ok)
55+
});
56+
57+
if (buttons[response] === copy) {
58+
await this.clipboardService.writeText(detail);
59+
}
60+
}
61+
62+
protected get applicationName(): string {
63+
return FrontendApplicationConfigProvider.get().applicationName;
64+
}
65+
66+
}
67+
68+
export namespace About {
69+
export namespace Commands {
70+
export const ABOUT_APP: Command = {
71+
id: 'arduino-about'
72+
};
73+
}
74+
}

arduino-ide-extension/src/browser/menu/arduino-menus.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { MAIN_MENU_BAR } from '@theia/core/lib/common/menu';
1+
import { isOSX } from '@theia/core/lib/common/os';
22
import { CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
3-
import { isOSX } from '@theia/core';
3+
import { MAIN_MENU_BAR } from '@theia/core/lib/common/menu';
44

55
export namespace ArduinoMenus {
66

@@ -40,7 +40,14 @@ export namespace ArduinoMenus {
4040
// Core settings, such as `Processor` and `Programmers` for the board and `Burn Bootloader`
4141
export const TOOLS__BOARD_SETTINGS_GROUP = [...TOOLS, '1_board_settings'];
4242

43-
// Context menu
43+
// -- Help
44+
// `About` group
45+
// XXX: on macOS, the about group is not under `Help`
46+
export const HELP__ABOUT_GROUP = [...(isOSX ? MAIN_MENU_BAR : CommonMenus.HELP), '999_about'];
47+
48+
// ------------
49+
50+
// Context menus
4451
// -- Open
4552
export const OPEN_SKETCH__CONTEXT = ['arduino-open-sketch--context'];
4653
export const OPEN_SKETCH__CONTEXT__OPEN_GROUP = [...OPEN_SKETCH__CONTEXT, '0_open'];

arduino-ide-extension/src/browser/theia/core/about-dialog.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

arduino-ide-extension/src/browser/theia/core/common-frontend-contribution.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export class CommonFrontendContribution extends TheiaCommonFrontendContribution
1919
CommonCommands.AUTO_SAVE,
2020
CommonCommands.OPEN_PREFERENCES,
2121
CommonCommands.SELECT_ICON_THEME,
22-
CommonCommands.SELECT_COLOR_THEME
22+
CommonCommands.SELECT_COLOR_THEME,
23+
CommonCommands.ABOUT_COMMAND
2324
]) {
2425
registry.unregisterMenuAction(command);
2526
}

arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
77
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
88
import { FocusTracker, Widget } from '@theia/core/lib/browser';
99
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
10+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
1011
import { ConfigService } from '../../../common/protocol/config-service';
1112
import { SketchesService } from '../../../common/protocol/sketches-service';
1213
import { ArduinoWorkspaceRootResolver } from '../../arduino-workspace-resolver';
@@ -97,8 +98,9 @@ export class WorkspaceService extends TheiaWorkspaceService {
9798
}
9899

99100
protected formatTitle(title?: string): string {
101+
const status = FrontendApplicationConfigProvider.get()['status'];
100102
const version = this.version ? ` ${this.version}` : '';
101-
const name = `${this.applicationName} ${version}`;
103+
const name = `${this.applicationName}${status ? ` – ${status}` : ''} ${version}`;
102104
return title ? `${title} | ${name}` : name;
103105
}
104106

arduino-ide-extension/src/common/protocol/config-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const ConfigServicePath = '/services/config-service';
22
export const ConfigService = Symbol('ConfigService');
33
export interface ConfigService {
4-
getVersion(): Promise<string>;
4+
getVersion(): Promise<Readonly<{ version: string, commit: string, status?: string }>>;
55
getConfiguration(): Promise<Config>;
66
getCliConfigFileUri(): Promise<string>;
77
getConfigurationFileSchemaUri(): Promise<string>;

arduino-ide-extension/src/electron-browser/theia/core/electron-main-menu-factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ export class ElectronMainMenuFactory extends TheiaElectronMainMenuFactory {
2020
const { submenu } = super.createOSXMenu();
2121
const label = 'Arduino Pro IDE';
2222
if (!!submenu && !(submenu instanceof remote.Menu)) {
23-
const [about, , ...rest] = submenu;
24-
const menuModel = this.menuProvider.getMenu(ArduinoMenus.FILE__SETTINGS_GROUP);
25-
const settings = this.fillMenuTemplate([], menuModel);
23+
const [/* about */, /* settings */, ...rest] = submenu;
24+
const about = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.HELP__ABOUT_GROUP));
25+
const settings = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__SETTINGS_GROUP));
2626
return {
2727
label,
2828
submenu: [
29-
about, // TODO: we have two about dialogs! one from electron the other from Theia.
29+
...about,
3030
{ type: 'separator' },
3131
...settings,
3232
{ type: 'separator' },

arduino-ide-extension/src/node/arduino-daemon-impl.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,20 @@ export class ArduinoDaemonImpl implements ArduinoDaemon, BackendApplicationContr
105105
return this._execPath;
106106
}
107107

108-
async getVersion(): Promise<string> {
108+
async getVersion(): Promise<Readonly<{ version: string, commit: string, status?: string }>> {
109109
const execPath = await this.getExecPath();
110-
return spawnCommand(`"${execPath}"`, ['version'], this.onError.bind(this));
110+
const raw = await spawnCommand(`"${execPath}"`, ['version', '--format', 'json'], this.onError.bind(this));
111+
try {
112+
// The CLI `Info` object: https://github.com/arduino/arduino-cli/blob/17d24eb901b1fdaa5a4ec7da3417e9e460f84007/version/version.go#L31-L34
113+
const { VersionString, Commit, Status } = JSON.parse(raw);
114+
return {
115+
version: VersionString,
116+
commit: Commit,
117+
status: Status
118+
};
119+
} catch {
120+
return { version: raw, commit: raw };
121+
}
111122
}
112123

113124
protected async getSpawnArgs(): Promise<string[]> {

arduino-ide-extension/src/node/config-service-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class ConfigServiceImpl implements BackendApplicationContribution, Config
8484
return this.configChangeEmitter.event;
8585
}
8686

87-
async getVersion(): Promise<string> {
87+
async getVersion(): Promise<Readonly<{ version: string, commit: string, status?: string }>> {
8888
return this.daemon.getVersion();
8989
}
9090

browser-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"config": {
3535
"applicationName": "Arduino Pro IDE",
3636
"defaultTheme": "arduino-theme",
37+
"status": "Alpha",
3738
"preferences": {
3839
"editor.autoSave": "on",
3940
"editor.minimap.enabled": false,

electron-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"config": {
3838
"applicationName": "Arduino Pro IDE",
3939
"defaultTheme": "arduino-theme",
40+
"status": "Alpha",
4041
"preferences": {
4142
"editor.autoSave": "on",
4243
"editor.minimap.enabled": false,

electron/build/template-package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,17 @@
3838
"target": "electron",
3939
"frontend": {
4040
"config": {
41-
"applicationName": "Arduino Pro IDE",
4241
"disallowReloadKeybinding": true
4342
}
4443
},
4544
"backend": {
4645
"config": {
47-
"singleInstance": true,
48-
"configDirName": ".arduinoProIDE"
46+
"singleInstance": true
4947
}
5048
}
5149
},
5250
"build": {
5351
"productName": "Arduino Pro IDE",
54-
"appId": "arduino.ProIDE",
5552
"asar": false,
5653
"directories": {
5754
"buildResources": "resources"

0 commit comments

Comments
 (0)