Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions apps/devhub/templates/devhub/includes/addons_edit_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@
<li {% if url in request.path %}class="selected"{% endif %}>
<a href="{{ url }}">{{ title }}</a></li>
{% endfor %}
<li class="addon-manage">
{% if check_addon_ownership(request, addon, dev=True) %}
{% if addon.disabled_by_user and addon.status != amo.STATUS_DISABLED %}
<a href="{{ addon.get_dev_url('enable') }}" class="enable-addon">{{ _('Enable Add-on') }}</a>
{% elif not addon.is_disabled %}
<a href="{{ addon.get_dev_url('versions') }}#disable-addon" class="disable-addon">{{ _('Disable Add-on') }}</a>
{% endif %}
{% endif %}
{% if check_addon_ownership(request, addon) and addon.can_be_deleted() %}
<a href="{{ addon.get_dev_url('versions') }}#delete-addon" class="delete-addon">{{ _('Delete Add-on') }}</a>
{% endif %}
</li>
</ul>
<ul class="refinements">
<li><a href="{{ addon.get_url_path() }}">
Expand Down
38 changes: 34 additions & 4 deletions apps/devhub/templates/devhub/versions/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,36 @@
<h2>{{ addon.name }}</h2>
</header>
<section id="edit-addon" class="primary devhub-form" role="main">
<h3>{{ _('Addon visibility') }}</h3>
<div class="item" id="addon-current-state">
<div class="item_wrapper">
{% set owner = check_addon_ownership(request, addon, dev=True) %}
<label><input name="addon-state" value="listed" type="radio"
{% if not owner or addon.status == amo.STATUS_DISABLED or not addon.is_listed %}disabled="disabled"{% endif %}
{% if not addon.is_disabled and addon.is_listed %}checked="checked"{% endif %}
data-url="{{ addon.get_dev_url('enable') }}"
class="enable-addon">
<strong>{{ _('Listed:') }}</strong> {{ _('Visible to everyone on {0} and included in search results and listing pages')|f(settings.SITE_URL) }}</label>
<br><br>
<label><input name="addon-state" value="hidden" type="radio"
{% if not owner or not addon.is_listed %}disabled="disabled"{% endif %}
{% if addon.is_disabled and addon.is_listed %}checked="checked"{% endif %}
class="disable-addon">
<strong>{{ _('Hidden:') }}</strong> {{ _('Hosted on {0}, but hidden to anyone but authors. Used to temporarily hide listings or discontinue them.')|f(settings.SITE_URL) }}</label>
<br><br>
<label><input name="addon-state" value="unlisted" type="radio"
disabled="disabled"
{% if not addon.is_listed %}checked="checked"{% endif %}
class="unlist-addon">
<strong>{{ _('Unlisted:') }}</strong> {{ _('Not distributed on {0}. Developers will upload new versions for signing and distribute the add-ons on their own.')|f(settings.SITE_URL) }}</label>
<br><br>
{% if check_addon_ownership(request, addon) and addon.can_be_deleted() %}
<a class="delete-button delete-addon" href="{{ addon.get_dev_url('versions') }}#delete-addon">{{ _('Delete Add-on') }}</a>
{% endif %}
</div>
</div>

<h3>{{ _('Current versions') }}</h3>
{% if addon.current_version %}
<div class="item" id="current-version-status">
<div class="item_wrapper">
Expand Down Expand Up @@ -221,25 +251,25 @@ <h3 data-tmpl="{{ _('Delete Version {version}') }}"></h3>
<div id="modal-disable" class="modal">
<form method="post" action="{{ addon.get_dev_url('disable') }}">
<h3>
{{ _('Disable Add-on') }}
{{ _('Hide Add-on') }}
</h3>
<p>
{% trans %}
Disabling your add-on will prevent it from appearing anywhere in our
Hiding your add-on will prevent it from appearing anywhere in our
gallery and will stop users from receiving automatic updates.
{% endtrans %}
</p>
<p>
{% trans %}
Are you sure you wish to disable your add-on?
Are you sure you wish to hide your add-on?
{% endtrans %}
</p>
{{ csrf() }}
<input type="hidden" name="version_id" class="version_id">
<input type="hidden" name="addon_id" class="addon_id" value="{{ addon.id }}">
<p>
<button type="submit">
{{ _('Disable Add-on') }}
{{ _('Hide Add-on') }}
</button>
{{ _('or') }} <a href="#" class="close">{{ _('Cancel') }}</a>
</p>
Expand Down
71 changes: 56 additions & 15 deletions apps/devhub/tests/test_views_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import amo.tests
from amo.urlresolvers import reverse
from amo.tests import formset, initial
from addons.models import Addon
from addons.models import Addon, AddonUser
from applications.models import AppVersion
from devhub.models import ActivityLog
from files.models import File
Expand Down Expand Up @@ -227,30 +227,71 @@ def test_non_owner_cant_enable_addon(self):
eq_(res.status_code, 403)
eq_(Addon.objects.get(id=3615).disabled_by_user, False)

def test_show_disable_button(self):
def test_non_owner_cant_change_status(self):
"""A non-owner can't use the radio buttons."""
self.addon.update(disabled_by_user=False)
addon_user = AddonUser.objects.get(addon=self.addon)
addon_user.role = amo.AUTHOR_ROLE_VIEWER
addon_user.save()
res = self.client.get(self.url)
doc = pq(res.content)
assert doc('.enable-addon').attr('checked') == 'checked'
assert doc('.enable-addon').attr('disabled') == 'disabled'
assert not doc('.disable-addon').attr('checked')
assert doc('.disable-addon').attr('disabled') == 'disabled'
assert not doc('.unlist-addon').attr('checked')
assert doc('.unlist-addon').attr('disabled') == 'disabled' # Readonly.

def test_published_addon_radio(self):
"""Published (listed) addon is selected: can hide or publish."""
self.addon.update(disabled_by_user=False)
res = self.client.get(self.url)
doc = pq(res.content)
assert doc('.enable-addon').attr('checked') == 'checked'
enable_url = self.addon.get_dev_url('enable')
assert doc('.enable-addon').attr('data-url') == enable_url
assert not doc('.enable-addon').attr('disabled')
assert doc('#modal-disable')
assert doc('.disable-addon')
assert not doc('.enable-addon')
assert not doc('.disable-addon').attr('checked')
assert not doc('.disable-addon').attr('disabled')
assert not doc('.unlist-addon').attr('checked')
assert doc('.unlist-addon').attr('disabled') == 'disabled' # Readonly.

def test_not_show_disable(self):
def test_hidden_addon_radio(self):
"""Hidden (disabled) addon is selected: can hide or publish."""
self.addon.update(disabled_by_user=True)
res = self.client.get(self.url)
doc = pq(res.content)
assert not doc('.enable-addon').attr('checked')
assert not doc('.enable-addon').attr('disabled')
assert doc('.disable-addon').attr('checked') == 'checked'
assert not doc('.disable-addon').attr('disabled')
assert not doc('.unlist-addon').attr('checked')
assert doc('.unlist-addon').attr('disabled') == 'disabled' # Readonly.

def test_status_disabled_addon_radio(self):
"""Disabled by Mozilla addon: hidden selected, can't change status."""
self.addon.update(status=amo.STATUS_DISABLED, disabled_by_user=False)
res = self.client.get(self.url)
doc = pq(res.content)
assert not doc('#modal-disable')
assert not doc('.disable-addon')

def test_show_enable_button(self):
self.addon.update(disabled_by_user=True)
assert not doc('.enable-addon').attr('checked')
assert doc('.enable-addon').attr('disabled') == 'disabled'
assert doc('.disable-addon').attr('checked') == 'checked'
assert doc('.disable-addon').attr('disabled') == 'disabled'
assert not doc('.unlist-addon').attr('checked')
assert doc('.unlist-addon').attr('disabled') == 'disabled' # Readonly.

def test_unlisted_addon_cant_change_status(self):
"""Unlisted addon: can't change its status."""
self.addon.update(disabled_by_user=False, is_listed=False)
res = self.client.get(self.url)
doc = pq(res.content)
a = doc('.enable-addon')
assert a, "Expected Enable addon link"
eq_(a.attr('href'), self.enable_url)
assert not doc('#modal-disable')
assert not doc('.disable-addon')
assert not doc('.enable-addon').attr('checked')
assert doc('.enable-addon').attr('disabled') == 'disabled'
assert not doc('.disable-addon').attr('checked')
assert doc('.disable-addon').attr('disabled') == 'disabled'
assert doc('.unlist-addon').attr('checked') == 'checked'
assert doc('.unlist-addon').attr('disabled') == 'disabled' # Readonly.

def test_cancel_get(self):
cancel_url = reverse('devhub.addons.cancel', args=['a3615'])
Expand Down
3 changes: 3 additions & 0 deletions static/css/devhub/listing.less
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@
.item:hover a.delete-addon {
color: #d33;
}
#addon-current-state.item:hover a.delete-addon {
color: #fff;
}
23 changes: 23 additions & 0 deletions static/css/zamboni/developers.css
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,29 @@ a.extra {
border-color: #ad1212;
text-shadow: 0 -1px #e00;
}
a.delete-button:hover,
a.delete-button {
border: 1px solid #ad1212;
-moz-border-radius: .95em;
-webkit-border-radius: .95em;
border-radius: .95em;
-moz-box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
-webkit-box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
color: #fff;
display: inline-block;
font-weight: bold;
line-height: 1.538;
padding: 0 .95em;
text-decoration: none;
text-shadow: 0 -1px 0 #e00;
}
a.delete-button:hover {
-moz-box-shadow: inset 0 0 2px rgba(255,255,255,1);
-webkit-box-shadow: inset 0 0 2px rgba(255,255,255,1);
box-shadow: inset 0 0 2px rgba(255,255,255,1);
color: #fff;
}

.email_comment {
white-space: pre-wrap;
Expand Down
6 changes: 3 additions & 3 deletions static/js/zamboni/devhub.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ $(document).ready(function() {
}
}

$('.enable-addon').bind('click', _pd(function() {
$('.enable-addon').bind('click', function() {
$.ajax({
'type': 'POST',
'url': $(this).attr('href'),
'url': $(this).data('url'),
'success': function() {
window.location.reload();
}
});
}));
});

// In-app payments config.
if ($('#in-app-config').length) {
Expand Down