Skip to content

Commit

Permalink
chore: introduce a new property to switch to the new task manager panel
Browse files Browse the repository at this point in the history
related to podman-desktop#9924
Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed Dec 3, 2024
1 parent d008854 commit a5c4419
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/api/src/tasks-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export enum ExperimentalTasksSettings {
SectionName = 'tasks',
StatusBar = 'StatusBar',
Toast = 'Toast',
Manager = 'Manager',
}
14 changes: 14 additions & 0 deletions packages/main/src/plugin/tasks/task-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ test('task manager init should register a configuration option', async () => {
}),
]),
);

expect(configurationRegistry.registerConfigurations).toHaveBeenCalledWith(
expect.arrayContaining([
expect.objectContaining({
properties: expect.objectContaining({
'tasks.Manager': {
type: 'boolean',
description: 'Replace the current task manager widget by the new one',
default: false,
},
}),
}),
]),
);
});

test('create task with title', async () => {
Expand Down
14 changes: 13 additions & 1 deletion packages/main/src/plugin/tasks/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export class TaskManager {
this.setStatusBarEntry(false);

this.commandRegistry.registerCommand('show-task-manager', () => {
this.apiSender.send('toggle-task-manager', '');
// get the current value of the configuration flag for the task manager
const useExperimentalTaskManager = this.configurationRegistry
.getConfiguration(ExperimentalTasksSettings.SectionName)
.get<boolean>(ExperimentalTasksSettings.Manager, false);

const showEventName = useExperimentalTaskManager ? 'toggle-task-manager' : 'toggle-legacy-task-manager';

this.apiSender.send(showEventName, '');
this.setStatusBarEntry(false);
});

Expand All @@ -67,6 +74,11 @@ export class TaskManager {
type: 'boolean',
default: false,
},
[`${ExperimentalTasksSettings.SectionName}.${ExperimentalTasksSettings.Manager}`]: {
description: 'Replace the current task manager widget by the new one',
type: 'boolean',
default: false,
},
},
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function handleEscape({ key }: any) {
}
}
// listen to the event "toggle-task-manager" to toggle the task manager
window.events?.receive('toggle-task-manager', () => {
// listen to the event "toggle-legacy-task-manager" to toggle the task manager
window.events?.receive('toggle-legacy-task-manager', () => {
showTaskManager = !showTaskManager;
});
</script>
Expand Down

0 comments on commit a5c4419

Please sign in to comment.