-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce
VersionWelcomeDialog
- Loading branch information
1 parent
51c40fa
commit 8b97650
Showing
6 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
arduino-ide-extension/src/browser/dialogs/version-welcome-dialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import React from '@theia/core/shared/react'; | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { Message } from '@theia/core/shared/@phosphor/messaging'; | ||
import { ReactDialog } from '../theia/dialogs/dialogs'; | ||
import { nls } from '@theia/core'; | ||
import { DialogProps } from '@theia/core/lib/browser'; | ||
import { WindowService } from '@theia/core/lib/browser/window/window-service'; | ||
import { AppService } from '../app-service'; | ||
|
||
@injectable() | ||
export class VersionWelcomeDialogProps extends DialogProps {} | ||
|
||
@injectable() | ||
export class VersionWelcomeDialog extends ReactDialog<void> { | ||
// @inject(LocalStorageService) | ||
// private readonly localStorageService: LocalStorageService; | ||
|
||
@inject(AppService) | ||
private readonly appService: AppService; | ||
|
||
@inject(WindowService) | ||
private readonly windowService: WindowService; | ||
|
||
constructor( | ||
@inject(VersionWelcomeDialogProps) | ||
protected override readonly props: VersionWelcomeDialogProps | ||
) { | ||
super({ | ||
title: nls.localize( | ||
'arduino/versionWelcome/versionWelcomeDialog', | ||
'Welcome to the new Arduino IDE!' | ||
), | ||
}); | ||
|
||
this.node.id = 'version-welcome-dialog-container'; | ||
this.contentNode.classList.add('version-welcome-dialog'); | ||
} | ||
|
||
protected render(): React.ReactNode { | ||
return ( | ||
<div> | ||
<p> | ||
{nls.localize( | ||
'arduino/versionWelcome/donateMessage', | ||
'Arduino is committed to keeping software free and open-source for everyone. Your donation helps us develop new features, improve libraries, and support millions of users worldwide.' | ||
)} | ||
</p> | ||
<p className="bold"> | ||
{nls.localize( | ||
'arduino/versionWelcome/donateMessage2', | ||
'Please consider supporting our efforts to keep Arduino IDE free.' | ||
)} | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
override get value(): void { | ||
return; | ||
} | ||
|
||
private appendButtons(): void { | ||
const cancelButton = this.createButton( | ||
nls.localize('arduino/versionWelcome/cancelButton', 'Maybe later') | ||
); | ||
cancelButton.classList.add('secondary'); | ||
cancelButton.classList.add('cancel-button'); | ||
this.addAction(cancelButton, this.close.bind(this), 'click'); | ||
this.controlPanel.appendChild(cancelButton); | ||
|
||
const donateButton = this.createButton( | ||
nls.localize('arduino/versionWelcome/donateButton', 'Donate now') | ||
); | ||
this.addAction(donateButton, this.openDonationPage.bind(this), 'click'); | ||
this.controlPanel.appendChild(donateButton); | ||
donateButton.focus(); | ||
} | ||
|
||
private readonly openDonationPage = () => { | ||
const url = 'https://www.arduino.cc/en/donate'; | ||
this.windowService.openNewWindow(url, { external: true }); | ||
}; | ||
|
||
// FIXME: AppInfo is not available in the browser? | ||
private async updateTitleVersion(): Promise<void> { | ||
const appInfo = await this.appService.info(); | ||
const { appVersion } = appInfo; | ||
const title = nls.localize( | ||
'arduino/versionWelcome/versionWelcomeDialog', | ||
`Welcome to the new Arduino IDE ${appVersion}!`, | ||
appVersion | ||
); | ||
this.titleNode.innerHTML = title; | ||
} | ||
|
||
protected override onAfterAttach(msg: Message): void { | ||
this.update(); | ||
this.appendButtons(); | ||
this.updateTitleVersion(); | ||
super.onAfterAttach(msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
arduino-ide-extension/src/browser/style/version-welcome-dialog.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#version-welcome-dialog-container > .dialogBlock { | ||
width: 546px; | ||
|
||
.bold { | ||
font-weight: bold; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters