-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Show donate dialog after the first time a first IDE version is loaded
- Loading branch information
1 parent
2ffe20d
commit 7eae0db
Showing
7 changed files
with
160 additions
and
2 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
93 changes: 93 additions & 0 deletions
93
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,93 @@ | ||
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(AppService) | ||
private readonly appService: AppService; | ||
|
||
@inject(WindowService) | ||
private readonly windowService: WindowService; | ||
|
||
constructor( | ||
@inject(VersionWelcomeDialogProps) | ||
protected override readonly props: VersionWelcomeDialogProps | ||
) { | ||
super({ title: '' }); | ||
|
||
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 }); | ||
}; | ||
|
||
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
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