Skip to content

Commit

Permalink
Toggle all direct children from folder mockoon#1188
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagocarod committed Feb 26, 2024
1 parent a057c5b commit 2a9005d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/desktop/src/renderer/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ export class AppComponent extends Logger implements OnInit {
if (payload.subject === 'route') {
this.environmentsService.toggleRoute(payload.subjectUUID);
}
if (payload.subject === 'folder') {
this.environmentsService.toggleFolder(payload.subjectUUID);
}
break;
case 'duplicateToEnv':
this.startEntityDuplicationToAnotherEnvironment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ export const FoldersContextMenu = (folderUUID: string): ContextMenuItem[] => [
icon: 'folder',
disabled: false
},
{
payload: {
subject: 'folder',
action: 'toggle',
subjectUUID: folderUUID
},
label: 'Toggle folder',
icon: 'power_settings_new',
disabled: false
},
{
payload: {
subject: 'folder',
Expand Down
15 changes: 15 additions & 0 deletions packages/desktop/src/renderer/app/services/environments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,21 @@ export class EnvironmentsService extends Logger {
}
}

/**
* Enable and disable routes in a folder
*/
public toggleFolder(folderId: string | 'root') {
const activeEnvironment = this.store.getActiveEnvironment();
const selectedFolder = activeEnvironment.folders.find(
(folder) => folder.uuid === folderId
);
for (const child of selectedFolder.children) {
if (child.type === 'route') {
this.toggleRoute(child.uuid);
}
}
}

/**
* Update a folder and save it in the store
*/
Expand Down

0 comments on commit 2a9005d

Please sign in to comment.