Skip to content

Commit 848f794

Browse files
add donate link to update flow
1 parent d106588 commit 848f794

File tree

6 files changed

+107
-11
lines changed

6 files changed

+107
-11
lines changed

arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-component.tsx

+57-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from '@theia/core/shared/react';
44
import type { Options } from 'react-markdown';
55
import { ProgressInfo, UpdateInfo } from '../../../common/protocol/ide-updater';
66
import ProgressBar from '../../components/ProgressBar';
7+
import { createPortal } from '@theia/core/shared/react-dom';
78

89
const ReactMarkdown = React.lazy<React.ComponentType<Options>>(
910
// @ts-expect-error see above
@@ -21,6 +22,8 @@ export interface IDEUpdaterComponentProps {
2122
updateInfo: UpdateInfo;
2223
updateProgress: UpdateProgress;
2324
openExternal: (url: string) => undefined;
25+
hasControls: boolean;
26+
controlPanel: HTMLDivElement;
2427
}
2528

2629
export const IDEUpdaterComponent = ({
@@ -32,6 +35,8 @@ export const IDEUpdaterComponent = ({
3235
error,
3336
},
3437
openExternal,
38+
hasControls,
39+
controlPanel,
3540
}: IDEUpdaterComponentProps): React.ReactElement => {
3641
const { version, releaseNotes } = updateInfo;
3742
const [changelog, setChangelog] = React.useState<string>('');
@@ -139,17 +144,60 @@ export const IDEUpdaterComponent = ({
139144
</div>
140145
);
141146

147+
const DonateFooter = (
148+
<div
149+
className={
150+
hasControls
151+
? 'ide-updater-dialog--content--child--footer-with-controls'
152+
: 'ide-updater-dialog--content--child--footer'
153+
}
154+
>
155+
<hr />
156+
<span>
157+
{nls.localize(
158+
'arduino/ide-updater/donate-preface',
159+
'Open source is love, '
160+
)}
161+
<a
162+
className="donate-link"
163+
onClick={() => openExternal('https://www.arduino.cc/en/donate/')}
164+
>
165+
{nls.localize(
166+
'arduino/ide-updater/donate-link-text',
167+
'donate to support us'
168+
)}
169+
<div
170+
className="donate-link-icon"
171+
title={nls.localize(
172+
'arduino/ide-updater/donate-link-text',
173+
'donate to support us'
174+
)}
175+
/>
176+
</a>
177+
</span>
178+
</div>
179+
);
180+
181+
const DonateFooterToRender =
182+
hasControls && controlPanel.parentElement
183+
? createPortal(DonateFooter, controlPanel.parentElement)
184+
: DonateFooter;
185+
186+
const isPreDownload = !error && !downloadFinished && !downloadStarted;
142187
return (
143188
<div className="ide-updater-dialog--content">
144-
{!!error ? (
145-
<GoToDownloadPage />
146-
) : downloadFinished ? (
147-
<DownloadCompleted />
148-
) : downloadStarted ? (
149-
<DownloadStarted />
150-
) : (
151-
<PreDownload />
152-
)}
189+
<div>
190+
{!!error ? (
191+
<GoToDownloadPage />
192+
) : downloadFinished ? (
193+
<DownloadCompleted />
194+
) : downloadStarted ? (
195+
<DownloadStarted />
196+
) : (
197+
<PreDownload />
198+
)}
199+
{isPreDownload ? null : DonateFooterToRender}
200+
</div>
153201
</div>
154202
);
155203
};

arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ export class IDEUpdaterDialog extends ReactDialog<UpdateInfo | undefined> {
6969
}
7070

7171
protected render(): React.ReactNode {
72+
const hasControls = !!this.controlPanel.firstChild;
73+
const controlPanel = this.controlPanel;
74+
7275
return (
7376
this.updateInfo && (
7477
<IDEUpdaterComponent
7578
updateInfo={this.updateInfo}
7679
updateProgress={this.updateProgress}
7780
openExternal={this.openExternal}
81+
hasControls={hasControls}
82+
controlPanel={controlPanel}
7883
/>
7984
)
8085
);
Loading

arduino-ide-extension/src/browser/style/ide-updater-dialog.css

+38
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,44 @@
3434
min-width: 0;
3535
}
3636

37+
.ide-updater-dialog--content--child--footer {
38+
margin: 16px 0px 16px 0px;
39+
}
40+
41+
.ide-updater-dialog--content--child--footer-with-controls {
42+
margin: -16px 0px 16px 0px;
43+
}
44+
45+
.ide-updater-dialog--content--child--footer > span,
46+
.ide-updater-dialog--content--child--footer-with-controls > span {
47+
float: right;
48+
display: flex;
49+
justify-content: space-between;
50+
align-items: center;
51+
}
52+
53+
.donate-link {
54+
margin-left: 6px;
55+
display: flex;
56+
flex-direction: row;
57+
align-items: center;
58+
color: var(--theia-textLink-foreground);
59+
font-weight: 500;
60+
}
61+
62+
.donate-link:hover {
63+
color: var(--theia-textLink-foreground);
64+
cursor: pointer;
65+
}
66+
67+
.donate-link-icon {
68+
-webkit-mask: url(../icons/link-open-icon.svg) center no-repeat;
69+
background-color: var(--theia-textLink-foreground);
70+
height: 24px;
71+
width: 24px;
72+
cursor: pointer;
73+
}
74+
3775
.ide-updater-dialog .changelog {
3876
color: var(--theia-editor-foreground);
3977
background-color: var(--theia-editor-background);

arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class IDEUpdaterImpl implements IDEUpdater {
6262
await this.updater.checkForUpdates();
6363

6464
this.cancellationToken = cancellationToken;
65-
if (this.updater.currentVersion.compare(updateInfo.version) === -1) {
65+
if (true) {
6666
/*
6767
'latest.txt' points to the latest changelog that has been generated by the CI,
6868
so we need to make a first GET request to get the filename of the changelog

i18n/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@
286286
"notNowButton": "Not now",
287287
"skipVersionButton": "Skip Version",
288288
"updateAvailable": "Update Available",
289-
"versionDownloaded": "Arduino IDE {0} has been downloaded."
289+
"versionDownloaded": "Arduino IDE {0} has been downloaded.",
290+
"donate-prefix": "Open source is love,",
291+
"donate-link-text": "donate to support us"
290292
},
291293
"installable": {
292294
"libraryInstallFailed": "Failed to install library: '{0}{1}'.",

0 commit comments

Comments
 (0)