Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace numeric enums with string enums #76

Open
wants to merge 1 commit into
base: v1.x/staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions base/src/dispatcher/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class Dispatcher implements ZLUX.Dispatcher {

private isConcreteAction(action: ZLUX.AbstractAction | undefined): boolean {
const actionAsAny: any = action as any;
return actionAsAny && actionAsAny.targetPluginID && typeof actionAsAny.type === 'number' && typeof actionAsAny.targetMode === 'number';
return actionAsAny && actionAsAny.targetPluginID && typeof actionAsAny.type === 'string' && typeof actionAsAny.targetMode === 'string';
}

registerAction(action: ZLUX.Action): void {
Expand Down Expand Up @@ -673,15 +673,6 @@ export class Dispatcher implements ZLUX.Dispatcher {
if (!targetPluginID) {
targetPluginID = actionAsAny.targetId;
}

if(typeof targetMode === 'string') {
targetMode = ZoweZLUX.dispatcher.constants.ActionTargetMode[targetMode];
}

if(typeof type === 'string') {
type = ZoweZLUX.dispatcher.constants.ActionType[type];
}

return new Action(id, defaultName, targetMode, type, targetPluginID, primaryArgument);
}

Expand Down Expand Up @@ -1201,22 +1192,22 @@ export class RecognizerProperty extends RecognitionClause {
}

export enum ActionTargetMode {
PluginCreate, // require pluginType
PluginFindUniqueOrCreate, // required AppInstance/ID
PluginFindAnyOrCreate, // plugin type
PluginCreate = "PluginCreate", // require pluginType
PluginFindUniqueOrCreate = "PluginFindUniqueOrCreate", // required AppInstance/ID
PluginFindAnyOrCreate = "PluginFindAnyOrCreate", // plugin type
//should have PluginFindAnyOrFail
System, // something that is always present
System = "System", // something that is always present
}

export enum ActionType { // not all actions are meaningful for all target modes
Launch, // essentially do nothing after target mode
Focus, // bring to fore, but nothing else
Route, // sub-navigate or "route" in target
Message, // "onMessage" style event to plugin
Method, // Method call on instance, more strongly typed
Minimize,
Maximize,
Close, // may need to call a "close handler"
Launch = "Launch", // essentially do nothing after target mode
Focus = "Focus", // bring to fore, but nothing else
Route = "Route", // sub-navigate or "route" in target
Message = "Message", // "onMessage" style event to plugin
Method = "Method", // Method call on instance, more strongly typed
Minimize = "Minimize",
Maximize = "Maximize",
Close = "Close", // may need to call a "close handler"
}


Expand Down