Skip to content

Commit b3d1fe8

Browse files
author
Akos Kitta
committed
Updated message when running tasks.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 337f48a commit b3d1fe8

File tree

2 files changed

+49
-29
lines changed

2 files changed

+49
-29
lines changed

arduino-ide-extension/src/browser/contributions/check-for-updates.ts

+45-27
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,22 @@ const NoUpdates = nls.localize(
2323
'arduino/checkForUpdates/noUpdates',
2424
'There are no recent updates available.'
2525
);
26-
const UpdateBoards = nls.localize(
27-
'arduino/checkForUpdates/updatedBoth',
26+
const PromptUpdateBoards = nls.localize(
27+
'arduino/checkForUpdates/promptUpdateBoards',
2828
'Updates are available for some of your boards.'
2929
);
30-
const UpdateLibraries = nls.localize(
31-
'arduino/checkForUpdates/updatedBoth',
30+
const PromptUpdateLibraries = nls.localize(
31+
'arduino/checkForUpdates/promptUpdateLibraries',
3232
'Updates are available for some of your libraries.'
3333
);
34+
const UpdatingBoards = nls.localize(
35+
'arduino/checkForUpdates/updatingBoards',
36+
'Updating boards...'
37+
);
38+
const UpdatingLibraries = nls.localize(
39+
'arduino/checkForUpdates/updatingLibraries',
40+
'Updating libraries...'
41+
);
3442
const InstallAll = nls.localize(
3543
'arduino/checkForUpdates/installAll',
3644
'Install All'
@@ -47,12 +55,12 @@ const Updatable = { type: 'Updatable' } as const;
4755
export class CheckForUpdates extends Contribution {
4856
@inject(WindowServiceExt)
4957
private readonly windowService: WindowServiceExt;
50-
@inject(LibraryService)
51-
private readonly libraryService: LibraryService;
52-
@inject(BoardsService)
53-
private readonly boardsService: BoardsService;
5458
@inject(ResponseServiceClient)
5559
private readonly responseService: ResponseServiceClient;
60+
@inject(BoardsService)
61+
private readonly boardsService: BoardsService;
62+
@inject(LibraryService)
63+
private readonly libraryService: LibraryService;
5664
@inject(BoardsListWidgetFrontendContribution)
5765
private readonly boardsContribution: BoardsListWidgetFrontendContribution;
5866
@inject(LibraryListWidgetFrontendContribution)
@@ -87,23 +95,25 @@ export class CheckForUpdates extends Contribution {
8795
}
8896
}
8997

90-
private promptUpdateLibraries(items: LibraryPackage[]): void {
98+
private promptUpdateBoards(items: BoardsPackage[]): void {
9199
this.prompt({
92100
items,
93-
installable: this.libraryService,
94-
viewContribution: this.librariesContribution,
95-
viewSearchOptions: { query: '', topic: 'All', ...Updatable },
96-
message: UpdateLibraries,
101+
installable: this.boardsService,
102+
viewContribution: this.boardsContribution,
103+
viewSearchOptions: { query: '', ...Updatable },
104+
promptMessage: PromptUpdateBoards,
105+
updatingMessage: UpdatingBoards,
97106
});
98107
}
99108

100-
private promptUpdateBoards(items: BoardsPackage[]): void {
109+
private promptUpdateLibraries(items: LibraryPackage[]): void {
101110
this.prompt({
102111
items,
103-
installable: this.boardsService,
104-
viewContribution: this.boardsContribution,
105-
viewSearchOptions: { query: '', ...Updatable },
106-
message: UpdateBoards,
112+
installable: this.libraryService,
113+
viewContribution: this.librariesContribution,
114+
viewSearchOptions: { query: '', topic: 'All', ...Updatable },
115+
promptMessage: PromptUpdateLibraries,
116+
updatingMessage: UpdatingLibraries,
107117
});
108118
}
109119

@@ -115,10 +125,18 @@ export class CheckForUpdates extends Contribution {
115125
installable: Installable<T>;
116126
viewContribution: AbstractViewContribution<ListWidget<T, S>>;
117127
viewSearchOptions: S;
118-
message: string;
128+
promptMessage: string;
129+
updatingMessage: string;
119130
}): void {
120-
const { items, installable, viewContribution, message, viewSearchOptions } =
121-
options;
131+
const {
132+
items,
133+
installable,
134+
viewContribution,
135+
promptMessage: message,
136+
viewSearchOptions,
137+
updatingMessage,
138+
} = options;
139+
122140
if (!items.length) {
123141
return;
124142
}
@@ -129,7 +147,7 @@ export class CheckForUpdates extends Contribution {
129147
const tasks = items.map((item) =>
130148
this.createInstallTask(item, installable)
131149
);
132-
this.executeTasks(tasks);
150+
this.executeTasks(updatingMessage, tasks);
133151
} else if (answer === InstallManually) {
134152
viewContribution
135153
.openView({ reveal: true })
@@ -138,19 +156,19 @@ export class CheckForUpdates extends Contribution {
138156
});
139157
}
140158

141-
private async executeTasks(tasks: Task<ArduinoComponent>[]): Promise<void> {
159+
private async executeTasks(
160+
message: string,
161+
tasks: Task<ArduinoComponent>[]
162+
): Promise<void> {
142163
if (tasks.length) {
143164
return ExecuteWithProgress.withProgress(
144-
nls.localize('arduino/checkForUpdates/updating', 'Updating'),
165+
message,
145166
this.messageService,
146167
async (progress) => {
147168
try {
148169
const total = tasks.length;
149170
let count = 0;
150171
for (const { run, item } of tasks) {
151-
// progress.report({
152-
// message: item.name,
153-
// });
154172
try {
155173
await run(); // runs update sequentially. // TODO: is parallel update desired?
156174
} catch (err) {

i18n/en.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
"checkForUpdates": "Check for Arduino Updates",
6868
"installAll": "Install All",
6969
"noUpdates": "There are no recent updates available.",
70-
"updatedBoth": "Updates are available for some of your libraries.",
71-
"updating": "Updating"
70+
"promptUpdateBoards": "Updates are available for some of your boards.",
71+
"promptUpdateLibraries": "Updates are available for some of your libraries.",
72+
"updatingBoards": "Updating boards...",
73+
"updatingLibraries": "Updating libraries..."
7274
},
7375
"cli-error-parser": {
7476
"keyboardError": "'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?",

0 commit comments

Comments
 (0)