Put d2c buttons behind waffle flag.
This commit is contained in:
Родитель
bbd6879423
Коммит
9269e54b68
|
@ -12,8 +12,11 @@
|
|||
{% if compat %}
|
||||
data-min="{{ compat.min.version }}"
|
||||
data-max="{{ compat.max.version }}"
|
||||
data-is-compatible="{{ version.is_compatible|json }}"
|
||||
data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
|
||||
{% if waffle.switch('d2c-buttons') %}
|
||||
data-waffle-d2c-buttons="true"
|
||||
data-is-compatible="{{ version.is_compatible|json }}"
|
||||
data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
|
||||
{% endif %}
|
||||
data-version="{{ version.version }}"
|
||||
data-compatible-apps="{{ version.compatible_apps[request.APP] }}"
|
||||
data-lastupdated-isotime="{{ version.created|isotime }}"
|
||||
|
|
|
@ -16,8 +16,11 @@
|
|||
{% if compat %}
|
||||
data-min="{{ compat.min.version }}"
|
||||
data-max="{{ compat.max.version }}"
|
||||
data-is-compatible="{{ version.is_compatible|json }}"
|
||||
data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
|
||||
{% if waffle.switch('d2c-buttons') %}
|
||||
data-waffle-d2c-buttons="true"
|
||||
data-is-compatible="{{ version.is_compatible|json }}"
|
||||
data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if addon.is_webapp() %}
|
||||
data-manifest-url="{% if (addon.is_premium() and addon.has_purchased(amo_user)) or (not addon.is_premium()) -%}
|
||||
|
|
|
@ -605,6 +605,7 @@ class TestButtonHtml(ButtonTest):
|
|||
assert doc('.install-button').text('Not ready for purchase.')
|
||||
|
||||
def test_d2c_attrs(self):
|
||||
waffle.models.Switch.objects.create(name='d2c-buttons', active=True)
|
||||
compat = Mock()
|
||||
compat.min.version = '4.0'
|
||||
compat.max.version = '12.0'
|
||||
|
|
|
@ -98,6 +98,7 @@ var installButton = function() {
|
|||
accept_eula = $this.hasClass('accept'),
|
||||
webapp = $this.hasattr('data-manifest-url'),
|
||||
compatible = $this.attr('data-is-compatible') == 'true',
|
||||
waffle_d2c_buttons = $this.hasattr('data-waffle-d2c-buttons'),
|
||||
has_overrides = $this.hasattr('data-compat-overrides'),
|
||||
// L10n: {0} is an app name like Firefox.
|
||||
_s = accept_eula ? gettext('Accept and Install') : gettext('Add to {0}'),
|
||||
|
@ -123,21 +124,25 @@ var installButton = function() {
|
|||
newerBrowser = VersionCompare.compareVersions(z.browserVersion, max) > 0;
|
||||
}
|
||||
|
||||
// Firefox 10+ is compatible by default.
|
||||
var compatible = compatible && z.browserVersion != 0 &&
|
||||
if (waffle_d2c_buttons) {
|
||||
// Firefox 10+ is compatible by default.
|
||||
compatible = compatible && z.browserVersion != 0 &&
|
||||
VersionCompare.compareVersions(z.browserVersion, '10.0') >= 0;
|
||||
// If it's still compatible, check the overrides.
|
||||
if (compatible && has_overrides) {
|
||||
var overrides = JSON.parse($this.attr('data-compat-overrides'));
|
||||
_.each(overrides, function(override) {
|
||||
var _min = override[0],
|
||||
_max = override[1];
|
||||
if (VersionCompare.compareVersions(z.browserVersion, _min) >= 0 ||
|
||||
VersionCompare.compareVersions(z.browserVersion, _max) <= 0) {
|
||||
compatible = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
// If it's still compatible, check the overrides.
|
||||
if (compatible && has_overrides) {
|
||||
var overrides = JSON.parse($this.attr('data-compat-overrides'));
|
||||
_.each(overrides, function(override) {
|
||||
var _min = override[0],
|
||||
_max = override[1];
|
||||
if (VersionCompare.compareVersions(z.browserVersion, _min) >= 0 ||
|
||||
VersionCompare.compareVersions(z.browserVersion, _max) <= 0) {
|
||||
compatible = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
compatible = false; // We always assumed not compatible before.
|
||||
}
|
||||
|
||||
if (!$body.hasClass('acr-pitch') && newerBrowser && z.hasNightly && !z.hasACR) {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO waffle_switch_amo (name, active, note)
|
||||
VALUES ('d2c-buttons', 0, 'If active, this turns on default-to-compatible for the install buttons.');
|
|
@ -71,6 +71,7 @@
|
|||
<div class="install"
|
||||
data-min="4.0"
|
||||
data-max="5.0"
|
||||
data-waffle-d2c-buttons="true"
|
||||
data-is-compatible="true"
|
||||
data-compat-overrides="[]">
|
||||
<p class="install-button">
|
||||
|
@ -85,6 +86,7 @@
|
|||
<div class="install"
|
||||
data-min="4.0"
|
||||
data-max="5.0"
|
||||
data-waffle-d2c-buttons="true"
|
||||
data-is-compatible="true"
|
||||
data-compat-overrides="{{ [['10.0a1', '99.*']]|json }}">
|
||||
<p class="install-button">
|
||||
|
@ -99,6 +101,7 @@
|
|||
<div class="install"
|
||||
data-min="4.0"
|
||||
data-max="5.0"
|
||||
data-waffle-d2c-buttons="true"
|
||||
data-is-compatible="false"
|
||||
data-compat-overrides="[]">
|
||||
<p class="install-button">
|
||||
|
|
Загрузка…
Ссылка в новой задаче