Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit 181a186

Browse files
author
Rob Hudson
committed
Added version info to buttons for non-supported add-ons (bug 733089)
1 parent 474c3d1 commit 181a186

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

apps/addons/templates/addons/button.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
data-addon="{{ addon.id }}"
88
data-icon="{{ addon.icon_url }}"
99
data-developers="{{ addon.meet_the_dev_url() }}"
10+
data-versions="{{ url('addons.versions', addon.id) }}"
1011
data-name="{{ addon.name }}"
1112
{{ b.attrs()|xmlattr }}
1213
{% if compat %}

apps/addons/templates/addons/includes/button_data_attributes.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
data-addon="{{ addon.id }}"
55
data-icon="{{ addon.icon_url }}"
66
data-developers="{{ addon.meet_the_dev_url() }}"
7+
data-versions="{{ url('addons.versions', addon.id) }}"
78
data-name="{{ addon.name }}"
89
{{ b.attrs()|xmlattr }}
910
{# TODO: Fix this when we move purchases logic into mkt/. #}

apps/addons/tests/test_buttons.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class TestButtonHtml(ButtonTest):
434434

435435
def test_basics(self):
436436
a = self.addon
437-
a.id = 'addon id'
437+
a.id = '12345'
438438
a.icon_url = 'icon url'
439439
a.meet_the_dev_url.return_value = 'meet.dev'
440440
a.name = 'addon name'
@@ -448,9 +448,11 @@ def test_basics(self):
448448
eq_(doc('.button').length, 1)
449449

450450
install = doc('.install')
451-
eq_('addon id', install.attr('data-addon'))
451+
eq_('12345', install.attr('data-addon'))
452452
eq_('icon url', install.attr('data-icon'))
453453
eq_('meet.dev', install.attr('data-developers'))
454+
eq_(reverse('addons.versions', args=[a.id]),
455+
install.attr('data-versions'))
454456
eq_('addon name', install.attr('data-name'))
455457
eq_(None, install.attr('data-min'))
456458
eq_(None, install.attr('data-max'))

media/css/impala/buttons.less

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,33 @@ button.bad, .button.bad, .button.developer, .button.scary { // Red
230230
.extra {
231231
margin-top: 8px;
232232
}
233-
.notavail {
233+
.notavail,
234+
.notsupported {
234235
color: @error-red;
235236
display: block;
236237
font-size: 11px;
237238
margin: 0 0 4px;
238239
}
239-
.acr-incompat {
240+
.acr-incompat,
241+
.notsupported {
240242
color: @note-gray;
241243
}
244+
.notsupported span:before {
245+
content: "\0B7";
246+
padding: 0 4px;
247+
}
248+
}
249+
250+
.listing .notsupported span {
251+
display: block;
252+
margin-top: 4px;
253+
&:before {
254+
content: "";
255+
}
256+
}
257+
258+
.versions .notsupported {
259+
display: none;
242260
}
243261

244262
.listing-grid {

media/js/zamboni/buttons.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ z.button.after = {'contrib': function(xpi_url, status) {
1919

2020
var notavail = '<div class="extra"><span class="notavail">{0}</span></div>',
2121
incompat = '<div class="extra"><span class="notavail acr-incompat">{0}</span></div>',
22+
noappsupport = '<div class="extra"><span class="notsupported">{0}</span></div>',
2223
download_re = new RegExp('(/downloads/(?:latest|file)/\\d+)');
2324

2425

@@ -100,6 +101,7 @@ var installButton = function() {
100101
compatible = $this.attr('data-is-compatible') == 'true',
101102
waffle_d2c_buttons = $this.hasattr('data-waffle-d2c-buttons'),
102103
has_overrides = $this.hasattr('data-compat-overrides'),
104+
versions_url = $this.attr('data-versions'),
103105
// L10n: {0} is an app name like Firefox.
104106
_s = accept_eula ? gettext('Accept and Install') : gettext('Add to {0}'),
105107
addto = format(_s, [z.appName]),
@@ -309,6 +311,14 @@ var installButton = function() {
309311
// Good version, good platform.
310312
$button.addClass('installer');
311313
$button.closest('div').attr('data-version-supported', true);
314+
} else if (!appSupported) {
315+
var tpl = template('Works with {app} {min} - {max}' +
316+
'<span class="more-versions"><a href="{versions_url}">' +
317+
'{versions_link}</a></span>');
318+
var context = {'app': z.appName, 'min': min, 'max': max,
319+
'versions_url': versions_url,
320+
'versions_link': gettext('View other versions')};
321+
addWarning(tpl(context), noappsupport);
312322
}
313323
return false;
314324
};

0 commit comments

Comments
 (0)