mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-09 12:26:34 +00:00
Show the CLI version from the about dialog.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
cebe15ef69
commit
2f84b5c6b7
@ -68,6 +68,8 @@ import { ArduinoTabBarDecoratorService } from './shell/arduino-tab-bar-decorator
|
||||
import { ProblemManager } from '@theia/markers/lib/browser';
|
||||
import { ArduinoProblemManager } from './markers/arduino-problem-manager';
|
||||
import { BoardsAutoInstaller } from './boards/boards-auto-installer';
|
||||
import { AboutDialog } from '@theia/core/lib/browser/about-dialog';
|
||||
import { ArduinoAboutDialog } from './customization/arduino-about-dialog';
|
||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
||||
|
||||
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
|
||||
@ -175,13 +177,12 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
id: MonitorWidget.ID,
|
||||
createWidget: () => context.container.get(MonitorWidget)
|
||||
}));
|
||||
// Frontend binding for the monitor service.
|
||||
// Frontend binding for the monitor service
|
||||
bind(MonitorService).toDynamicValue(context => {
|
||||
const connection = context.container.get(WebSocketConnectionProvider);
|
||||
const client = context.container.get(MonitorServiceClientImpl);
|
||||
return connection.createProxy(MonitorServicePath, client);
|
||||
}).inSingletonScope();
|
||||
// MonitorConnection
|
||||
bind(MonitorConnection).toSelf().inSingletonScope();
|
||||
// Monitor service client to receive and delegate notifications from the backend.
|
||||
bind(MonitorServiceClientImpl).toSelf().inSingletonScope();
|
||||
@ -197,7 +198,7 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
const themeService = ThemeService.get();
|
||||
themeService.register(...ArduinoTheme.themes);
|
||||
|
||||
// customizing default theia
|
||||
// Customizing default Theia layout
|
||||
if (!ArduinoAdvancedMode.TOGGLED) {
|
||||
unbind(OutlineViewContribution);
|
||||
bind(OutlineViewContribution).to(SilentOutlineViewContribution).inSingletonScope();
|
||||
@ -218,24 +219,29 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
unbind(SearchInWorkspaceFrontendContribution);
|
||||
bind(SearchInWorkspaceFrontendContribution).to(SilentSearchInWorkspaceContribution).inSingletonScope();
|
||||
} else {
|
||||
// We use this CSS class on the body to modify the visibbility of the close button for the editors and views.
|
||||
// We use this CSS class on the body to modify the visibility of the close button for the editors and views.
|
||||
document.body.classList.add(ArduinoAdvancedMode.LS_ID);
|
||||
}
|
||||
unbind(FrontendApplication);
|
||||
bind(FrontendApplication).to(ArduinoFrontendApplication).inSingletonScope();
|
||||
|
||||
// monaco customizations
|
||||
// Monaco customizations
|
||||
unbind(MonacoEditorProvider);
|
||||
bind(ArduinoMonacoEditorProvider).toSelf().inSingletonScope();
|
||||
bind(MonacoEditorProvider).toService(ArduinoMonacoEditorProvider);
|
||||
|
||||
// decorator customizations
|
||||
// Decorator customizations
|
||||
unbind(TabBarDecoratorService);
|
||||
bind(ArduinoTabBarDecoratorService).toSelf().inSingletonScope();
|
||||
bind(TabBarDecoratorService).toService(ArduinoTabBarDecoratorService);
|
||||
|
||||
// problem markers
|
||||
// Problem markers
|
||||
unbind(ProblemManager);
|
||||
bind(ArduinoProblemManager).toSelf().inSingletonScope();
|
||||
bind(ProblemManager).toService(ArduinoProblemManager);
|
||||
|
||||
// About dialog to show the CLI version
|
||||
unbind(AboutDialog);
|
||||
bind(ArduinoAboutDialog).toSelf().inSingletonScope();
|
||||
bind(AboutDialog).toService(ArduinoAboutDialog);
|
||||
});
|
||||
|
@ -0,0 +1,25 @@
|
||||
import { injectable, inject, postConstruct } from 'inversify';
|
||||
import { AboutDialog, ABOUT_CONTENT_CLASS } from '@theia/core/lib/browser/about-dialog';
|
||||
import { ConfigService } from '../../common/protocol/config-service';
|
||||
|
||||
@injectable()
|
||||
export class ArduinoAboutDialog extends AboutDialog {
|
||||
|
||||
@inject(ConfigService)
|
||||
protected readonly configService: ConfigService;
|
||||
|
||||
@postConstruct()
|
||||
protected async init(): Promise<void> {
|
||||
const [, version] = await Promise.all([super.init(), this.configService.getVersion()]);
|
||||
if (version) {
|
||||
const { firstChild } = this.contentNode;
|
||||
if (firstChild instanceof HTMLElement && firstChild.classList.contains(ABOUT_CONTENT_CLASS)) {
|
||||
const cliVersion = document.createElement('div');
|
||||
cliVersion.textContent = version;
|
||||
firstChild.appendChild(cliVersion);
|
||||
// TODO: anchor to the commit in the `arduino-cli` repository.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ export const ConfigServicePath = '/services/config-service';
|
||||
export const ConfigService = Symbol('ConfigService');
|
||||
|
||||
export interface ConfigService {
|
||||
getVersion(): Promise<string>;
|
||||
getConfiguration(): Promise<Config>;
|
||||
isInDataDir(uri: string): Promise<boolean>;
|
||||
isInSketchDir(uri: string): Promise<boolean>;
|
||||
|
@ -13,6 +13,10 @@ export class ConfigServiceImpl implements ConfigService {
|
||||
return this.cli.getDefaultConfig();
|
||||
}
|
||||
|
||||
async getVersion(): Promise<string> {
|
||||
return this.cli.getVersion();
|
||||
}
|
||||
|
||||
async isInDataDir(uri: string): Promise<boolean> {
|
||||
return this.getConfiguration().then(({ dataDirUri }) => new URI(dataDirUri).isEqualOrParent(new URI(uri)));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user