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

feat: make isMutator public #6316

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion core/flyout_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
this.workspace_.setMetricsManager(
new FlyoutMetricsManager(this.workspace_, this));

this.workspace_.isFlyout = true;
this.workspace_.internalIsFlyout = true;
// Keep the workspace visibility consistent with the flyout's visibility.
this.workspace_.setVisible(this.isVisible_);

Expand Down
2 changes: 1 addition & 1 deletion core/mutator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class Mutator extends Icon {
workspaceOptions.languageTree = toolbox.convertToolboxDefToJson(quarkXml);
}
this.workspace_ = this.newWorkspaceSvg(workspaceOptions);
this.workspace_.isMutator = true;
this.workspace_.internalIsMutator = true;
this.workspace_.addChangeListener(eventUtils.disableOrphans);

// Mutator flyouts go inside the mutator workspace's <g> rather than in
Expand Down
17 changes: 15 additions & 2 deletions core/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,27 @@ export class Workspace implements IASTNodeLocation {
*/
rendered = false;

/**
* Is this workspace the surface for a flyout?
* @internal
*/
internalIsFlyout = false;

/** Is this workspace the surface for a flyout? */
isFlyout = false;
get isFlyout(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getters and setters are banned by the js style guide (we use them in limited cases involving moving/deprecating properties but shouldn't use them in regular code)

also i don't like having "internal" as part of the name of the property. so i would suggest flyout for the property and IsFlyout for the function, maybe? i think that would be the recommended pattern in java at least.

but i guess that would be a breaking change since isFlyout is public... so either isFlyout and getIsFlyout or something better you come up with or just scrap the idea and keep the properties only. what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getters and setters are banned by the js style guide

They are not banned by the ts style guide though.

but i guess that would be a breaking change since isFlyout is public... so either isFlyout and getIsFlyout

Yeah this is the problem I ran into, which is why I ended up going with the getters. Because getIsFlyout() is.... not great.

My vote is either go with the getters as they currently are, or just keep them as properties only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for the pointer to the right place in the TS style guide. They are still "not recommended" because closure compiler doesn't deal with them well but this seems to fit when they're a good choice, and for future uses let's try to avoid with better property names for new properties

return this.internalIsFlyout;
}

/**
* Is this workspace the surface for a mutator?
* @internal
*/
isMutator = false;
internalIsMutator = false;

/** Is this workspace the surface for a mutator? */
get isMutator(): boolean {
return this.internalIsMutator;
}

/**
* Returns `true` if the workspace is currently in the process of a bulk
Expand Down