-
-
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
Show donate dialog after the first time a first IDE version is loaded
- Loading branch information
1 parent
504c12e
commit 19cb517
Showing
7 changed files
with
168 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
99 changes: 99 additions & 0 deletions
99
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,99 @@ | ||
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: nls.localize( | ||
'arduino/versionWelcome/title', | ||
'Welcome to a new version of the 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 work on the free open source Arduino IDE.' | ||
)} | ||
</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; | ||
|
||
if (appVersion) { | ||
this.titleNode.innerHTML = nls.localize( | ||
'arduino/versionWelcome/titleWithVersion', | ||
'Welcome to the new Arduino IDE {0}!', | ||
appVersion | ||
); | ||
} | ||
} | ||
|
||
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