Skip to content

Commit

Permalink
Toggle all direct children from folder mockoon#1188
Browse files Browse the repository at this point in the history
 Toggle all direct children from folder mockoon mockoon#1188
  • Loading branch information
santiagocarod committed Feb 27, 2024
1 parent a057c5b commit f5ba4c0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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
3 changes: 2 additions & 1 deletion packages/desktop/test/libs/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export enum ContextMenuFolderActions {
ADD_CRUD = 1,
ADD_HTTP = 2,
ADD_FOLDER = 3,
DELETE = 4
TOGGLE_FOLDER = 4,
DELETE = 5
}

class ContextMenu {
Expand Down

0 comments on commit f5ba4c0

Please sign in to comment.