Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
#289 replace switch with map
Browse files Browse the repository at this point in the history
  • Loading branch information
wowshakhov committed Aug 3, 2017
1 parent c87a0d1 commit 3f382b7
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/app/vm/shared/vm-actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,17 @@ export class VmActionsService implements ActionsService<VirtualMachine, VirtualM
) {}

public getActionByName(name: VirtualMachineActionType): VirtualMachineAction {
switch (name) {
case VmActions.START:
return this.vmStartAction;
case VmActions.STOP:
return this.vmStopAction;
case VmActions.REBOOT:
return this.vmRebootAction;
case VmActions.RESTORE:
return this.vmRestoreAction;
case VmActions.DESTROY:
return this.vmDestroyAction;
case VmActions.RESET_PASSWORD:
return this.vmResetPasswordAction;
case VmActions.CONSOLE:
return this.vmConsoleAction;
case VmActions.WEB_SHELL:
return this.vmWebShellAction;
default:
throw new Error('Unknown VM action');
}
const actions = {
[VmActions.START]: this.vmStartAction,
[VmActions.STOP]: this.vmStopAction,
[VmActions.REBOOT]: this.vmRebootAction,
[VmActions.RESTORE]: this.vmRestoreAction,
[VmActions.DESTROY]: this.vmDestroyAction,
[VmActions.RESET_PASSWORD]: this.vmResetPasswordAction,
[VmActions.CONSOLE]: this.vmConsoleAction,
[VmActions.WEB_SHELL]: this.vmWebShellAction
};

return actions[name];
}
}

0 comments on commit 3f382b7

Please sign in to comment.