Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix #2902: Externalize debug menu as an extension #2942

Merged
merged 9 commits into from
Feb 26, 2013

Conversation

TomMalbran
Copy link
Contributor

This request fixes #2902 by moving the DebugCommandHandlers, NodeDebugUtils and all the Debug menu creation to a new DebugCommands extension.

@ghost ghost assigned jasonsanjose Feb 25, 2013
@@ -36815,7 +36815,7 @@ define('editor/EditorCommandHandlers',['require','exports','module','command/Com
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
Copy link
Member

Choose a reason for hiding this comment

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

Please revert this file. This is only for performance testing and we need this snapshot to stay intact. Thanks!

@jasonsanjose
Copy link
Member

Initial review complete

@TomMalbran
Copy link
Contributor Author

@jasonsanjose Thanks for the fast review!

I addressed all the comments, although I am not sure if moving _handleWindowGoingAway to Global.js was the best option since it added new dependencies on that File. Would be better to just leave it in DocumentCommandHandlers and export just that function and use it this extension? Anyway, is in Global.js now.

@TomMalbran
Copy link
Contributor Author

There is a problem with the dependencies now by moving _handleWindowGoingAway to Global.js.

Global.js requires ProjectManager.js to be loaded first to be able to register the trigger handler, but PreojectManager loads PrefUtils.js that requires Global.js to be defined first. So by requiring ProjectManager.js before Global.js brackets loads, but the tests don't (and maybe something else).

A solution would be what I mentioned first or make other file trigger the "beforeAppClose" event.

@jasonsanjose
Copy link
Member

Ah, should have seen that coming. Ok, let's back those changes out of Global.js. How about in DebugCommands/main.js...forgive any early morning copy paste errors:

function handleReload(commandData) {
    CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true }).done(function () {
        // Give everyone a chance to save their state - but don't let any problems block
        // us from quitting
        try {
            $(ProjectManager).triggerHandler("beforeAppClose");
        } catch (ex) {
            console.error(ex);
        }

        // Disable the cache to make reloads work
        _disableCache().always(function () {
            window.location.reload(true);
        });
    });
}

@jasonsanjose
Copy link
Member

Need to merge with master again to kick off a new build on travis. JSHint dependencies were updated, causing the build to fail...see #2956.

@TomMalbran
Copy link
Contributor Author

@jasonsanjose Now is everything working after backing the changes on Global.js and using your code in main.js!

Should we move the commands ids from Commands.js to the extension?

@@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define */
/*global define, $ */
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there are some leftover edits in this file Global.js. It should be completely clean.

@jasonsanjose
Copy link
Member

Yes to moving the Commands. Just a few minor comments and this should be ready to go.

@TomMalbran
Copy link
Contributor Author

@jasonsanjose Done!

@jasonsanjose
Copy link
Member

Looks good. Merging.

jasonsanjose added a commit that referenced this pull request Feb 26, 2013
Fix #2902: Externalize debug menu as an extension
@jasonsanjose jasonsanjose merged commit 30c2751 into adobe:master Feb 26, 2013
@TomMalbran TomMalbran deleted the tom/debug-extension branch February 26, 2013 23:17
@jbalsas
Copy link
Contributor

jbalsas commented Feb 28, 2013

@jasonsanjose I just noticed that this change may break extensions adding menu items to the debug menu since Menus.AppMenuBar.DEBUG_MENU is no longer available. I'm not sure if there are any out there, but just in case you'd want to note it somewhere.

On the other hand, should we discourage developers to add items to the debug menu, or even prevent it somehow?

@TomMalbran
Copy link
Contributor Author

I noticed that this breaks the menu add in your extension. I don't think developers should add items to the debug menu since it might or not be present. Up until now it was available only in Brackets and not in Edge Code, so the extension would only work in Brackets.

It seems harder now to add to the debug menu since you need to look for the id and it will fail to add if your extension loads before the debug extension.

@jbalsas
Copy link
Contributor

jbalsas commented Feb 28, 2013

@TomMalbran I totally agree (I guess I put my extension there because I couldn't figure out where it fit ;)).

The wiki page for extensions says:

Add a menu item: Get a top-level menu by calling Menus.getMenu() with one of the AppMenuBar constants.

Just by reading that, I'd say people probably won't be trying to add items to the debug menu anymore, but maybe a explicit note in there about this wouldn't hurt in case someone goes looking for it.

@jasonsanjose
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Externalize debug menu as an extension
3 participants