Merge lp:~hatch/juju-gui/ie10-upgrade-1246946 into lp:juju-gui/experimental

Proposed by Jeff Pihach
Status: Merged
Merged at revision: 1183
Proposed branch: lp:~hatch/juju-gui/ie10-upgrade-1246946
Merge into: lp:juju-gui/experimental
Diff against target: 60 lines (+24/-2)
2 files modified
app/views/viewlets/service-overview.js (+11/-2)
test/test_inspector_overview.js (+13/-0)
To merge this branch: bzr merge lp:~hatch/juju-gui/ie10-upgrade-1246946
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+193716@code.launchpad.net

Description of the change

Fixes upgrade charm page reload in IE10

When clicking a link in the inspector in the upgrade charm
section in IE10 the page would reload instead of dispatching
to the router. This fixes it by generating complete relative
links so that the faulty method in YUI's pjax.base class can
parse them and react accordingly.

https://codereview.appspot.com/21430043/

To post a comment you must log in.
Revision history for this message
Jeff Pihach (hatch) wrote :
Download full text (4.7 KiB)

Reviewers: mp+193716_code.launchpad.net,

Message:
Please take a look.

Description:
Fixes upgrade charm page reload in IE10

When clicking a link in the inspector in the upgrade charm
section in IE10 the page would reload instead of dispatching
to the router. This fixes it by monkey patching the offending
method in the YUI source.

https://code.launchpad.net/~hatch/juju-gui/ie10-upgrade-1246946/+merge/193716

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/21430043/

Affected files (+62, -2 lines):
   A [revision details]
   M app/app.js
   A app/assets/javascripts/app-patches-extension.js
   M app/modules-debug.js
   M bin/merge-files

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: app/app.js
=== modified file 'app/app.js'
--- app/app.js 2013-10-30 11:59:48 +0000
+++ app/app.js 2013-11-03 20:10:26 +0000
@@ -51,7 +51,8 @@

Y.juju.SubAppRegistration,
                                                    Y.juju.NSRouter,
                                                    Y.juju.Cookies,
- Y.juju.GhostDeployer], {
+ Y.juju.GhostDeployer,
+ Y.juju.Patches], {

      /*
        Extension properties
@@ -1349,6 +1350,7 @@
      'juju-inspector-widget',
      'juju-ghost-inspector',
      'juju-view-bundle',
- 'viewmode-controls'
+ 'viewmode-controls',
+ 'app-patches-extension'
    ]
  });

Index: app/modules-debug.js
=== modified file 'app/modules-debug.js'
--- app/modules-debug.js 2013-10-18 16:47:34 +0000
+++ app/modules-debug.js 2013-11-03 20:10:26 +0000
@@ -181,6 +181,10 @@
            fullpath: '/juju-ui/assets/javascripts/app-cookies-extension.js'
          },

+ 'app-patches-extension': {
+ fullpath: '/juju-ui/assets/javascripts/app-patches-extension.js'
+ },
+
          'sub-app': {
            fullpath: '/juju-ui/assets/javascripts/sub-app.js'
          },

Index: bin/merge-files
=== modified file 'bin/merge-files'
--- bin/merge-files 2013-10-31 03:26:53 +0000
+++ bin/merge-files 2013-11-03 20:48:36 +0000
@@ -88,6 +88,7 @@
    filesToLoad.js.push.apply(filesToLoad.js, [
      'app/assets/javascripts/app-subapp-extension.js',
      'app/assets/javascripts/app-cookies-extension.js',
+ 'app/assets/javascripts/app-patches-extension.js',
      'app/assets/javascripts/d3-components.js',
      'app/assets/javascripts/d3.min.js',
      'app/assets/javascripts/d3.status.js',

Index: app/assets/javascripts/app-patches-extension.js
=== added file 'app/assets/javascripts/app-patches-extension.js'
--- app/assets/javascripts/app-patches-extension.js 1970-01-01 00:00:00
+0000
+++ app/assets/javascripts/app-patches-extension.js 2013-11-03 20:10:26
+0000
@@ -0,0 +1,51 @@
+/*
+This file i...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :

Does this break any external links then? We've got links to launchpad in
the charm details view for bugs and source that must work.

https://codereview.appspot.com/21430043/

Revision history for this message
Jeff Pihach (hatch) wrote :

Good catch! I'll implement a proper fix for this

https://codereview.appspot.com/21430043/

1178. By Jeff Pihach

Figured out alternative fix instead of monkeypatching broken YUI method

Revision history for this message
Jeff Pihach (hatch) wrote :
1179. By Jeff Pihach

merged trunk

1180. By Jeff Pihach

Added test to make sure that the links are generated properly for the upgrade charm detail links

Revision history for this message
Madison Scott-Clary (makyo) wrote :

QA ok, LGTM. Any way to test this?

https://codereview.appspot.com/21430043/

Revision history for this message
Jeff Pihach (hatch) wrote :
Revision history for this message
Jeff Pihach (hatch) wrote :
Revision history for this message
Jeff Pihach (hatch) wrote :

*** Submitted:

Fixes upgrade charm page reload in IE10

When clicking a link in the inspector in the upgrade charm
section in IE10 the page would reload instead of dispatching
to the router. This fixes it by generating complete relative
links so that the faulty method in YUI's pjax.base class can
parse them and react accordingly.

R=rharding, matthew.scott
CC=
https://codereview.appspot.com/21430043

https://codereview.appspot.com/21430043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/views/viewlets/service-overview.js'
2--- app/views/viewlets/service-overview.js 2013-11-05 03:30:06 +0000
3+++ app/views/viewlets/service-overview.js 2013-11-06 17:43:11 +0000
4@@ -192,6 +192,15 @@
5 var self = this,
6 buttonHeight;
7
8+ /*
9+ The _isLinkSameOrigin method in YUI's pjax.base class does not
10+ properly account for IE10's issues when parsing protocol and
11+ host from anchor tags unless the tags contain the full protocol
12+ and host for relative hrefs.
13+ */
14+ var wl = window.location;
15+ var locationPrefix = wl.protocol + '//' + wl.host;
16+
17 var categoryWrapperNodes = d3.select(node.getDOMNode())
18 .selectAll('.unit-list-wrapper')
19 .data(statuses, function(d) {
20@@ -237,7 +246,7 @@
21
22 serviceUpgradeLi.append('a')
23 .attr('href', function(d) {
24- return '/' + d.replace(/^cs:/, '');
25+ return locationPrefix + '/' + d.replace(/^cs:/, '');
26 })
27 .text(function(d) { return d; });
28
29@@ -284,7 +293,7 @@
30 serviceUpgradeOtherCharms
31 .append('a')
32 .attr('href', function(d) {
33- return '/' + d.replace(/^cs:/, '');
34+ return locationPrefix + '/' + d.replace(/^cs:/, '');
35 })
36 .text(function(d) { return d; });
37
38
39=== modified file 'test/test_inspector_overview.js'
40--- test/test_inspector_overview.js 2013-11-05 18:10:05 +0000
41+++ test/test_inspector_overview.js 2013-11-06 17:43:11 +0000
42@@ -675,6 +675,19 @@
43 assert.equal(serviceWrapper.one(SUC).all('.top-upgrade').size(), 5);
44 assert.equal(serviceWrapper.one(SUC).all('.other-charm').size(), 8);
45
46+ // Check to make sure that the links to view the charm details in the
47+ // upgrade section are full links instead of relative ones to allow
48+ // the YUI Pjax module to properly parse them in IE10
49+ serviceWrapper.one(SUC).all('.top-upgrade').each(function(node) {
50+ // Selects the first anchor tag which is the 'view charm details' link
51+ assert.isTrue(Y.PjaxBase.prototype._isLinkSameOrigin(node.one('a')));
52+ });
53+
54+ serviceWrapper.one(SUC).all('.other-charm').each(function(node) {
55+ // Selects the first anchor tag which is the 'view charm details' link
56+ assert.isTrue(Y.PjaxBase.prototype._isLinkSameOrigin(node.one('a')));
57+ });
58+
59 newContainer.remove(true);
60 });
61

Subscribers

People subscribed via source and target branches