Skip to content

Commit e65705e

Browse files
committed
Enhanced the user experience in the "Project Tasks" // Resolve platformio#3750
1 parent ad6877d commit e65705e

File tree

6 files changed

+67
-19
lines changed

6 files changed

+67
-19
lines changed
198 KB
Loading

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
## 3.3.0 (2023-07-??)
44

5-
* Added [Serial & UDP Plotter"](https://marketplace.visualstudio.com/items?itemName=alexnesnes.teleplot) item to the "PlatformIO IDE > Quick Access" menu
6-
* Updated PlatformIO Core Installer Script to [v1.2.0](https://github.com/platformio/platformio-core-installer/releases/tag/v1.2.0)
5+
* **Enhanced the user experience in the "Project Tasks" explorer by displaying tasks specific to the selected environment by default.** This improvement provides immediate visibility and access to the relevant tasks associated with the chosen environment, streamlining project navigation and task execution.
6+
* **Introduced a new option that allows seamless switching between multi-environment project tasks.** This addition empowers developers to effortlessly switch between different environments within a project and view their respective tasks, enabling efficient task management and execution within complex project setups.
7+
* **Expanded the functionality of the "Actvity Bar > PlatformIO IDE > Quick Access" menu by including a new item called** [Serial & UDP Plotter](https://marketplace.visualstudio.com/items?itemName=alexnesnes.teleplot). This addition simplifies and accelerates access to the Serial and UDP Plotter feature, allowing developers to quickly visualize and analyze data streams from connected devices.
8+
* **Updated the PlatformIO Core Installer Script to version** [v1.2.0](https://github.com/platformio/platformio-core-installer/releases/tag/v1.2.0). This update ensures that developers have the latest version of the Core Installer, benefiting from bug fixes, performance enhancements, and new features introduced in the latest release. Keeping the Core Installer up to date guarantees a more stable and reliable development environment for PlatformIO users.
9+
10+
![Toggle between Multi Environment Project Tasks](https://raw.githubusercontent.com/platformio/platformio-vscode-ide/develop/.github/media/platformio-toggle-multienv-tasks.gif)
711

812
## 3.2.0 (2023-06-09)
913

package.json

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,40 +142,47 @@
142142
"icon": "$(plug)",
143143
"enablement": "pioProjectReady"
144144
},
145+
{
146+
"command": "platformio-ide.toggleMultiEnvProjectTasks",
147+
"title": "Toggle between Multi Environment Project Tasks",
148+
"category": "PlatformIO",
149+
"icon": "$(layers)",
150+
"enablement": "pioProjectTasksReady"
151+
},
145152
{
146153
"command": "platformio-ide.refreshProjectTasks",
147154
"title": "Refresh Project Tasks",
148155
"category": "PlatformIO",
149156
"icon": "$(refresh)",
150-
"enablement": "pioProjectReady"
157+
"enablement": "pioProjectTasksReady"
151158
},
152159
{
153160
"command": "platformio-ide.build",
154161
"title": "Build",
155162
"category": "PlatformIO",
156163
"icon": "$(check)",
157-
"enablement": "pioProjectReady"
164+
"enablement": "pioProjectTasksReady"
158165
},
159166
{
160167
"command": "platformio-ide.upload",
161168
"title": "Upload",
162169
"category": "PlatformIO",
163170
"icon": "$(arrow-right)",
164-
"enablement": "pioProjectReady"
171+
"enablement": "pioProjectTasksReady"
165172
},
166173
{
167174
"command": "platformio-ide.uploadAndMonitor",
168175
"title": "Upload and Monitor",
169176
"category": "PlatformIO",
170177
"icon": "$(arrow-right)",
171-
"enablement": "pioProjectReady"
178+
"enablement": "pioProjectTasksReady"
172179
},
173180
{
174181
"command": "platformio-ide.clean",
175182
"title": "Clean",
176183
"category": "PlatformIO",
177184
"icon": "$(trashcan)",
178-
"enablement": "pioProjectReady"
185+
"enablement": "pioProjectTasksReady"
179186
},
180187
{
181188
"command": "platformio-ide.serialMonitor",
@@ -189,13 +196,13 @@
189196
"title": "Test",
190197
"category": "PlatformIO",
191198
"icon": "$(beaker)",
192-
"enablement": "pioProjectReady"
199+
"enablement": "pioProjectTasksReady"
193200
},
194201
{
195202
"command": "platformio-ide.rebuildProjectIndex",
196203
"title": "Rebuild IntelliSense Index",
197204
"category": "PlatformIO",
198-
"enablement": "pioProjectReady"
205+
"enablement": "pioProjectTasksReady"
199206
},
200207
{
201208
"command": "platformio-ide.startDebugging",
@@ -444,12 +451,17 @@
444451
"view/title": [
445452
{
446453
"command": "platformio-ide.pickProjectEnv",
447-
"when": "pioMultiEnvProject && view == platformio-ide.projectTasks",
454+
"when": "pioProjectTasksReady && pioMultiEnvProject && view == platformio-ide.projectTasks",
455+
"group": "navigation"
456+
},
457+
{
458+
"command": "platformio-ide.toggleMultiEnvProjectTasks",
459+
"when": "pioProjectTasksReady && view == platformio-ide.projectTasks",
448460
"group": "navigation"
449461
},
450462
{
451463
"command": "platformio-ide.refreshProjectTasks",
452-
"when": "pioProjectReady && view == platformio-ide.projectTasks",
464+
"when": "pioProjectTasksReady && view == platformio-ide.projectTasks",
453465
"group": "navigation"
454466
},
455467
{

src/project/manager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export default class ProjectManager {
112112
vscode.commands.registerCommand('platformio-ide.refreshProjectTasks', () =>
113113
this._taskManager.refresh({ force: true })
114114
),
115+
vscode.commands.registerCommand('platformio-ide.toggleMultiEnvProjectTasks', () =>
116+
this._taskManager.toggleMultiEnvExplorer()
117+
),
115118
vscode.commands.registerCommand('platformio-ide._runProjectTask', (task) =>
116119
this._taskManager.runTask(task)
117120
),

src/project/task-tree.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@ import * as vscode from 'vscode';
1111
export default class ProjectTasksTreeProvider {
1212
static DEFAULT_ENV_NAME = 'Default';
1313

14-
constructor(id, envs, tasks, selectedEnv = undefined) {
14+
constructor(id, envs, tasks, selectedEnv = undefined, multiEnvExplorer = false) {
1515
this.id = id;
1616
this.envs = envs;
1717
this.tasks = tasks;
1818
this.selectedEnv = selectedEnv;
1919
this.multiEnvProject = this.envs.length > 1;
20+
this.multiEnvExplorer = multiEnvExplorer;
21+
}
22+
23+
getEnvTasks(env = undefined, group = undefined) {
24+
const cmpGroup = (task) => {
25+
if (!group) {
26+
return true;
27+
}
28+
return task.group === group;
29+
};
30+
const result = this.tasks.filter((task) => cmpGroup(task) && task.coreEnv === env);
31+
// merge default/env-independent tasks
32+
if (env) {
33+
result.push(
34+
...this.tasks.filter(
35+
(task) =>
36+
cmpGroup(task) &&
37+
env !== ProjectTasksTreeProvider.DEFAULT_ENV_NAME &&
38+
!task.multienv
39+
)
40+
);
41+
}
42+
return result;
2043
}
2144

2245
getTreeItem(item) {
@@ -40,9 +63,11 @@ export default class ProjectTasksTreeProvider {
4063

4164
getChildren(element) {
4265
if (element && element.group) {
43-
return this.getEnvGroupChildren(element.env, element.group);
66+
return this.getEnvTasks(element.env, element.group);
4467
} else if (element) {
4568
return this.getEnvChildren(element.env);
69+
} else if (this.selectedEnv && !this.multiEnvExplorer) {
70+
return this.getEnvChildren(this.selectedEnv);
4671
}
4772
return this.getRootChildren();
4873
}
@@ -64,12 +89,8 @@ export default class ProjectTasksTreeProvider {
6489
return result;
6590
}
6691

67-
getEnvGroupChildren(env, group) {
68-
return this.tasks.filter((task) => task.coreEnv === env && task.group === group);
69-
}
70-
7192
getEnvChildren(env) {
72-
const envTasks = this.tasks.filter((task) => task.coreEnv === env);
93+
const envTasks = this.getEnvTasks(env);
7394
if (!envTasks.length) {
7495
return [new vscode.TreeItem('Loading...')];
7596
}

src/project/tasks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class ProjectTaskManager {
2525
this.subscriptions = [];
2626

2727
this._sid = Math.random();
28+
this._multienvTaskExplorer = false;
2829
this._refreshTimeout = undefined;
2930
this._startedTask = undefined;
3031
this._tasksToRestore = [];
@@ -38,6 +39,11 @@ export default class ProjectTaskManager {
3839
disposeSubscriptions(this.subscriptions);
3940
}
4041

42+
toggleMultiEnvExplorer() {
43+
this._multienvTaskExplorer = !this._multienvTaskExplorer;
44+
this.refresh({ force: true });
45+
}
46+
4147
requestRefresh() {
4248
if (this._refreshTimeout) {
4349
clearTimeout(this._refreshTimeout);
@@ -67,7 +73,8 @@ export default class ProjectTaskManager {
6773
this._sid,
6874
projectEnvs,
6975
projectTasks,
70-
this.projectObserver.getSelectedEnv()
76+
this.projectObserver.getSelectedEnv(),
77+
this._multienvTaskExplorer
7178
),
7279
showCollapseAll: true,
7380
});
@@ -95,6 +102,7 @@ export default class ProjectTaskManager {
95102

96103
this.registerTaskBasedCommands(projectTasks);
97104
this.registerPortSwitcher();
105+
vscode.commands.executeCommand('setContext', 'pioProjectTasksReady', true);
98106
vscode.commands.executeCommand(
99107
'setContext',
100108
'pioMultiEnvProject',

0 commit comments

Comments
 (0)