Merge lp:~sinzui/launchpad/obsolete-js into lp:launchpad

Proposed by Curtis Hovey on 2012-03-29
Status: Merged
Approved by: j.c.sackett on 2012-03-29
Approved revision: no longer in the source branch.
Merged at revision: 15043
Proposed branch: lp:~sinzui/launchpad/obsolete-js
Merge into: lp:launchpad
Diff against target: 0 lines
To merge this branch: bzr merge lp:~sinzui/launchpad/obsolete-js
Reviewer Review Type Date Requested Status
j.c.sackett (community) 2012-03-29 Approve on 2012-03-29
Richard Harding (community) code* 2012-03-29 Approve on 2012-03-29
Review via email: mp+99978@code.launchpad.net

Commit Message

Remove obsolete JavaScript.

Description of the Change

Pre-implementation: no one

While investigating a forbidden error during an ajax request, I was
surprised to see comments by kiko about obsolete code. While the
forbidden error should have been handled gracefully by the ajax request,
there is a separate issue that every page in Lp is serving obsolete
JavaScript functions via base-layout-macros.pt.

All the functions in <metal:page-javascript define-macro="page-javascript"...
need review:
    * VOID_URL is already inlined in it's only callsite, remove it.
    * registerLaunchpadFunction() is only used by codeimport-new.pt; inline
      the function.
    * updateField() is only used by codeimport-new.pt; inline the function.
    * setBetaRedirect() is used by the deprecated edge server; remove it.
    * popup_window() has no callsites; remove it.
    * switchBugBranchFormAndWhiteboard() has no callsites; remove it.
    * switchSpecBranchFormAndSummary() is used by branch-related-bug-specs.pt
      and branch-macros.pt. It could be inlined but it might belong in a
      code/javascript module.

--------------------------------------------------------------------

RULES

    * Delete and move until happiness is achieved.

    ADDENDUM
    * Bug #968310 javascript error editing a branch's related blueprints
      switchSpecBranchFormAndSummary() errors on the branch page because
      the form/markup that it used was removed. The function is 5 years
      old an probably broke in the 2x or 3x redesign.

    DOUBLE ADDENDUM
    * WTF. The switchSpecBranchFormAndSummary() function is not only
      causing scripting errors on the branch page, it was disabled
      on the merge page years ago because it just does not work.
      * delete switchSpecBranchFormAndSummary()

QA

    * Visit https://code.qastaging.launchpad.net/+code-imports/+new
    * Verify that when a repo type is selectected, its url field is
      is enabled and the other are disabled.

    * Visit https://code.qastaging.launchpad.net/~sinzui/gdp/incubation
    * Verify there is not a green 'Edit' text after the blueprint link.
    * Verify there is not a JS error when the edit link is followed.

LINT

    lib/lp/app/templates/base-layout-macros.pt
    lib/lp/code/templates/branch-macros.pt
    lib/lp/code/templates/branch-related-bugs-specs.pt
    lib/lp/code/templates/codeimport-new.pt

TEST

    None. These were untested functions though I do know exactly how I will
    QA the moved functions.

IMPLEMENTATION

Inlined updateWidgets() and registerLaunchpadFunction()'s LPJS setup. I
changed the call to run on DOMREADY and I chose to make it clear that
that the functions are global vars.
    lib/lp/code/templates/codeimport-new.pt

I deleted the uses of switchSpecBranchFormAndSummary() which broke the
branch page (branch-related-bugs-specs) and was disabled on the merge
proposal page (branch-macros). In the former case I chose to keep the
edit link which is what my browser failed over to use. In the later
case, the edit links were never generated, so I choose to just deleted.
    lib/lp/code/templates/branch-macros.pt
    lib/lp/code/templates/branch-related-bugs-specs.pt

I removed all the unused functions. The two remaining functions are used
by LaunchpadForm and Widgets to set the field that has focus and ensure
that keyboard commands are not misinterpreted by <select>.
    lib/lp/app/templates/base-layout-macros.pt

To post a comment you must log in.
Richard Harding (rharding) wrote :

Thanks for this. We definitely new these 'global' functions needed some clean up and research after moving them there during the thunder epic.

My only nitpick is just a lint issue in that the spacing around function () isn't consistent. Since I don't think JSLint hits the .pt files. Most of the cases have no space, but I think JSLint and updateField in the code below does have the space.

review: Approve (code*)
j.c.sackett (jcsackett) wrote :

This looks good to land; I agree the spacing is inconsistent, I leave how (and if) to resolve that to you.

review: Approve
Curtis Hovey (sinzui) wrote :

Indeed the spaces was inconsistent...neither files has kosher spacing.

Curtis Hovey (sinzui) wrote :

I got brutal with the script block. It was using == instead of === and the indentation was not 4-space. Lint likes it now.

Preview Diff

Empty