Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add 403 to app dashboard, bug fixes to thread create

  • Loading branch information...
commit 53a70ba961eb6ce2cba30cd80a5857223898f4c0 1 parent 108c601
@ngokevin ngokevin authored
View
2  src/media/css/comm.styl
@@ -127,7 +127,7 @@ tick() {
}
a.selected {
border-radius: 3px;
- box-shadow: 0px 4px 5px darken($faint-gray, 10%) inset;
+ box-shadow: 0 0 2px 1px darken($faint-gray, 10%);
color: #666;
}
li {
View
29 src/media/js/views/comm.js
@@ -75,14 +75,22 @@ define('views/comm',
// Send attachment with XHR2.
var formData = new FormData();
+ var hasInput;
$attachments.each(function(i, attachment) {
var $attachment = $(attachment);
+ if ($('[type="file"]', $attachment).val() != '') {
+ hasInput = true;
+ }
formData.append('form-' + i + '-attachment', $attachment.find('.realfileinput').get(0).files[0]);
formData.append('form-' + i + '-description', $attachment.find('.attach-description input').val());
});
+ if (!hasInput) {
+ return;
+ }
var xhr = new XMLHttpRequest();
xhr.onload = function() {
+ // Add attachment response to note.
var data = JSON.parse(this.responseText);
var $attachmentList = $('.note-detail[data-note-id="' + note_id + '"] .note-attachments');
@@ -99,6 +107,10 @@ define('views/comm',
};
xhr.open('POST', attachUrl);
xhr.send(formData);
+
+ // Clear input.
+ $thread.find('.attachment-field:first-child input').val('');
+ $thread.find('.attachment-field:not(:first-child)').remove();
};
z.page.on('click', '.reply.button.open-reply', function(e) {
@@ -126,26 +138,17 @@ define('views/comm',
var $this = $(this);
$this.siblings('button.post').toggleClass('disabled', !$this.val().length);
- }).on('click', 'button.post:not(.create-thread)', function(e) {
+ }).on('click', 'button.post', function(e) {
// Post the note.
var $this = $(this);
var replyBox = $this.closest('.thread-header').find('.reply-box').addClass('hidden');
if (postNoteEnabled) {
- postNote($this.siblings('.reply-text')).done(function(note) {
+ postNote($this.siblings('.reply-text'), $this.hasClass('create-thread')).done(function(note) {
replyBox.val('');
postAttachments($this.closest('.thread-item'), note.id);
});
}
- }).on('click', 'button.post.create-thread', function(e) {
- // Create thread (i.e. posting to a thread with 0 notes.).
- var replyBox = $(this).closest('.thread-header').find('.reply-box').addClass('hidden');
- if (postNoteEnabled) {
- postNote($(this).siblings('.reply-text'), true).done(function() {
- replyBox.val('');
- });
- }
-
}).on('click', '.notes-filter', function(e) {
var $this = $(this);
var $threadItem = $this.closest('.thread-item');
@@ -153,6 +156,10 @@ define('views/comm',
var filterMode = $this.data('filter-mode');
var params = {ordering: '-created', limit: 5};
+ if (!threadId) {
+ return;
+ }
+
$threadItem.data('notes-filter', filterMode);
$threadItem.data('notes-page', 1);
View
8 src/templates/_macros/thread_header.html
@@ -43,9 +43,11 @@ <h3 class="note-count" data-count="{{ thread.notes_count }}">
{% if thread %}
<li><a href="#show-unread-{{ thread.id }}" class="notes-filter filter-unread" data-filter-mode="unread">{{ _('Unread') }}</a></li>
<li><a href="#show-read-{{ thread.id }}" class="notes-filter filter-read" data-filter-mode="read">{{ _('Read') }}</a></li>
- {% if user and user.get_permission('reviewer') %}
- <li><a class="review-link" href="{{ thread.addon_meta.review_url }}">{{ _('Review') }}</a></li>
- {% endif %}
+ {% endif %}
+ {% if user and user.get_permission('reviewer') %}
+ <li><a class="review-link" href="{{ thread.addon_meta.review_url }}">{{ _('Review') }}</a></li>
+ {% endif %}
+ {% if thread %}
<li><b title="{{ _('Mark All Read') }}" class="mark-thread-read tick"></b></li>
{% endif %}
</ul>
View
12 src/templates/comm/app_dashboard.html
@@ -25,13 +25,21 @@
{% else %}
{% defer (url=app_endpoint) %}
{# Show create thread widget for most recent version. #}
- {{ create_thread(this, max.apply(Math, this.versions.keys())) }}
+ {% for version in this.versions.keys() %}
+ {{ create_thread(this, version) }}
+ {% endfor %}
{% end %}
{% endif %}
{% placeholder %}
<div class="spinner alt"></div>
{% except %}
- <p>{{ _('Error loading threads') }}</p>
+ {% if error == 403 %}
+ <p>{{ _("You are not allowed to access this app's threads.") }}</p>
+ {% else %}
+ <p>{{ _('Error loading threads') }}</p>
+ {% endif %}
{% end %}
+
+ {% include '_includes/attachment_field.html' %}
</section>
Please sign in to comment.
Something went wrong with that request. Please try again.