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

Fix the problem that the last flow tab can be deleted #1614

Merged
merged 3 commits into from
Feb 23, 2018

Conversation

Kazuki-Nakanishi
Copy link
Member

Before you hit that Submit button....

Please read our contribution guidelines
before submitting a pull-request.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

If you want to raise a pull-request with a new feature, or a refactoring
of existing code, it may well get rejected if it hasn't been discussed on
the mailing list or
slack team first.

Proposed changes

see #1613.
I checked all callers of workspace_tabs.count(). It looks that all of them expect that the count does not include subflow tabs.

Checklist

Put an x in the boxes that apply

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the mailing list/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@coveralls
Copy link

Coverage Status

Coverage remained the same at 87.755% when pulling c316284 on node-red-hitachi:no-tabs into 8d98b22 on node-red:master.

@coveralls
Copy link

coveralls commented Feb 7, 2018

Coverage Status

Coverage remained the same at 87.755% when pulling 3ed112c on node-red-hitachi:no-tabs into 8d98b22 on node-red:master.

@knolleary
Copy link
Member

Hi, thanks for this.

Not sure checking the icon path is the safest way to implement this check. RED.tabs is also a reusable component so we should avoid adding instance-specific logic in there.

I would suggest this logic belongs in workspace.js which manages the visible tabs - it should track how many tabs/subflows it has open.

@Kazuki-Nakanishi
Copy link
Member Author

Thank you for pointing it out. Yes, we should have managed the number of tabs in workspace.js. Sorry I did not notice it in advance.
I revised the code as you mentioned. Thanks.

Copy link
Member

@knolleary knolleary left a comment

Choose a reason for hiding this comment

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

The basic approach is good - just two small code-style changes requested.

@@ -240,18 +241,20 @@ RED.workspaces = (function() {
}
},
onadd: function(tab) {
workspaceTabCount = tab.type === "tab"?workspaceTabCount+1:workspaceTabCount;
Copy link
Member

Choose a reason for hiding this comment

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

From a code style point of view, I'd prefer if this was the easier to read alternative:

if (tab.type === "tab") {
   workspaceTabCount++;
}

showWorkspace();
}
},
onremove: function(tab) {
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() <= 1);
if (workspace_tabs.count() === 0) {
workspaceTabCount = tab.type === "tab"?workspaceTabCount-1:workspaceTabCount;
Copy link
Member

Choose a reason for hiding this comment

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

Same as the comment on line 244.

@Kazuki-Nakanishi
Copy link
Member Author

Thank you for pointing it out. I've pushed another commit following your suggestion.

@knolleary
Copy link
Member

Great thanks!

@knolleary knolleary merged commit af94787 into node-red:master Feb 23, 2018
@Kazuki-Nakanishi Kazuki-Nakanishi deleted the no-tabs branch February 28, 2018 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants