-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathversion-welcome-dialog.tsx
107 lines (94 loc) · 3.23 KB
/
version-welcome-dialog.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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';
import { sanitize } from 'dompurify';
@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.onDonateButtonClick.bind(this), 'click');
this.controlPanel.appendChild(donateButton);
donateButton.focus();
}
private onDonateButtonClick(): void {
this.openDonationPage();
this.close();
}
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.innerText = sanitize(
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);
}
}