This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Disable and enable extensions #11184
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
314d7ff
Support disabling extensions via .disabled file.
busykai c8af09f
Support disabling/enabling extensions in UI.
busykai 04e0ae1
Fix improper chaining of promises.
busykai 6bd7c64
Address review comments.
busykai e4394af
Ignore .disabled.
busykai 97755d4
Handle error condition correctly.
busykai 6cc7685
Merge branch 'master' into kai/disable-enable-extensions
prksingh 03b1e44
Change layout to show the update button separately
busykai d7b6675
Make .disabled file rule more concise.
busykai 1eef654
Change the extension manager layout.
busykai 753c84c
Use a common function to handle enabling/disabling
busykai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function enable() and the former disable() have almost the same definition, do we want to merge them into a single function with an additional parameter- enable flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rroshan1, I don't feel attracted by the idea. Two separate functions are in line with the rest of the actions (e.g.
install
/remove
). It would be OK ifPackage
had a single function, but the actual logic underneath is completely different. Do you feel strong about it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@busykai In my opinion, there should be an internal function (e.g.
_setDisabledState
), taking the argumentboolean disable
, which does both. It can then be called from both of these.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rroshan1, @marcelgerber if we had a single function in
Package
to enable/disable an extension, I would undoubtedly do something like what you guys suggest. However, I am reluctant to sacrifice readability of the code for "compactness". Firstly, the code will have to callPackage.(enable|disabled)
via variable; secondly, instead of using clear literals (true
,false
,DISABLED
,ENABLED
) variables should first evaluated and then used. I don't see how it makes the code more readable or, in general, how it is useful.The reason we don't have single function in
Package
and instead have two is because the logic is very different for the actions which need to be taken.For what it's worth,
remove()
is very similar in how it calls and treats the result. Should we start creating "unifying" functions with a bigswitch
at the beginning? Sometimes it's worth to repeat 10-15 lines for expressiveness. If I would duplicated 40+ lines (which I wouldn't), then it would be worth discussion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, whenever we have to make any changes, we need to apply these not once, but twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes!! Thanks @TomMalbran for pointing out..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so how this is nicer? Why not do
enableDisableRemove
then to eliminateremove
function as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, whatever. I disagree completely and I don't understand why this was worth such a discussion. I will make the change you're asking for just to end it. Added lines count will be more than remove lines count.
P.S. I think it would be helpful if someone with the authority would document this in code style guides so that nobody would have to lose their time in a discussion like this.
P.P.S. bikeshed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, I think @marcelgerber had the best suggestion in this little thread which amounted to a private function that toggled but allowing for separate public functions for enable and disable.
But that doesn't change that I agree with @busykai that having 1 function for each of the actions (install, remove, enable, disable) is the most readable and conveys the intent of the functions for future readers of the code.
@marcelgerber 's suggestion was a blend of efficiency and readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the change, let's not discuss this any longer.