зеркало из https://github.com/mozilla/buddyup.git
Bug 1154257 - Helpees should not see "Choose a category" when viewing questions
This commit is contained in:
Родитель
fdc2fe1425
Коммит
5edba372d7
|
@ -140,21 +140,24 @@
|
||||||
*/
|
*/
|
||||||
function add_thread_header(question) {
|
function add_thread_header(question) {
|
||||||
var date_posted = Utils.time_since(new Date(question.updated));
|
var date_posted = Utils.time_since(new Date(question.updated));
|
||||||
var author = question.creator.display_name || question.creator.username;
|
|
||||||
|
|
||||||
var displayable_metadata =
|
var displayable_metadata =
|
||||||
Utils.convert_metadata_for_display(question.metadata);
|
Utils.convert_metadata_for_display(question.metadata);
|
||||||
|
|
||||||
|
User.is_helper().then(function(is_helper) {
|
||||||
var html = nunjucks.render('thread_header.html', {
|
var html = nunjucks.render('thread_header.html', {
|
||||||
date_posted: date_posted,
|
date_posted: date_posted,
|
||||||
displayable_metadata: displayable_metadata,
|
displayable_metadata: displayable_metadata,
|
||||||
author: author,
|
viewer_is_helper: is_helper,
|
||||||
categories: CATEGORIES,
|
categories: CATEGORIES,
|
||||||
selected_category: question.category
|
selected_category: question.category
|
||||||
});
|
});
|
||||||
question_thread.insertAdjacentHTML('afterbegin', html);
|
question_thread.insertAdjacentHTML('afterbegin', html);
|
||||||
|
|
||||||
var category_chooser = document.getElementById('category_chooser');
|
var category_chooser = document.getElementById('category_chooser');
|
||||||
|
if (!category_chooser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
category_chooser.addEventListener('change', function(evt) {
|
category_chooser.addEventListener('change', function(evt) {
|
||||||
var category = evt.target.value;
|
var category = evt.target.value;
|
||||||
if (category == question.category) {
|
if (category == question.category) {
|
||||||
|
@ -162,6 +165,7 @@
|
||||||
}
|
}
|
||||||
SumoDB.set_category_for_question(category, question.id);
|
SumoDB.set_category_for_question(category, question.id);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The logic should mirror views/thread.html */
|
/* The logic should mirror views/thread.html */
|
||||||
|
|
|
@ -497,6 +497,8 @@ output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLook
|
||||||
output += "</span>\n</div>\n<h3 class=\"QuestionThread-date text-blue\">\n ";
|
output += "</span>\n</div>\n<h3 class=\"QuestionThread-date text-blue\">\n ";
|
||||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "date_posted"), env.autoesc);
|
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "date_posted"), env.autoesc);
|
||||||
output += "\n</h3>\n\n";
|
output += "\n</h3>\n\n";
|
||||||
|
if(runtime.contextOrFrameLookup(context, frame, "viewer_is_helper")) {
|
||||||
|
output += "\n ";
|
||||||
output += "\n <ul>\n <li>\n <div class=\"button\" data-icon=\"forward\">\n <select id=\"category_chooser\">\n ";
|
output += "\n <ul>\n <li>\n <div class=\"button\" data-icon=\"forward\">\n <select id=\"category_chooser\">\n ";
|
||||||
frame = frame.push();
|
frame = frame.push();
|
||||||
var t_3 = runtime.contextOrFrameLookup(context, frame, "categories");
|
var t_3 = runtime.contextOrFrameLookup(context, frame, "categories");
|
||||||
|
@ -558,6 +560,9 @@ output += "\n </option>\n ";
|
||||||
}
|
}
|
||||||
frame = frame.pop();
|
frame = frame.pop();
|
||||||
output += "\n </select>\n </div>\n </li>\n </ul>\n";
|
output += "\n </select>\n </div>\n </li>\n </ul>\n";
|
||||||
|
;
|
||||||
|
}
|
||||||
|
output += "\n";
|
||||||
cb(null, output);
|
cb(null, output);
|
||||||
;
|
;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
var MockUser = {
|
var MockUser = {
|
||||||
get_user: function() {},
|
get_user: function() {},
|
||||||
|
is_helper: function() {},
|
||||||
get_credentials: function() {},
|
get_credentials: function() {},
|
||||||
reauthenticate_user: function() {}
|
reauthenticate_user: function() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,6 +86,8 @@ suite('QuestionController', function() {
|
||||||
window.parent.Notif = MockNotif;
|
window.parent.Notif = MockNotif;
|
||||||
|
|
||||||
this.sinon.stub(User, 'get_user').returns(Promise.resolve(FAKE_USER));
|
this.sinon.stub(User, 'get_user').returns(Promise.resolve(FAKE_USER));
|
||||||
|
this.sinon.stub(User, 'is_helper').returns(Promise.resolve(true));
|
||||||
|
|
||||||
this.sinon.stub(Utils, 'get_url_parameters')
|
this.sinon.stub(Utils, 'get_url_parameters')
|
||||||
.returns({id: DISPLAYED_QUESTION_ID});
|
.returns({id: DISPLAYED_QUESTION_ID});
|
||||||
this.sinon.stub(Utils, 'time_since');
|
this.sinon.stub(Utils, 'time_since');
|
||||||
|
@ -125,6 +127,6 @@ suite('QuestionController', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('only display new answers since last time', function() {
|
test('only display new answers since last time', function() {
|
||||||
sinon.assert.calledOnce(nunjucks.render);
|
sinon.assert.calledOnce(nunjucks.render.withArgs('thread.html'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
{{ date_posted }}
|
{{ date_posted }}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
{% if viewer_is_helper %}
|
||||||
{# This <ul><li> is needed to get the right Building block styling for that button #}
|
{# This <ul><li> is needed to get the right Building block styling for that button #}
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
@ -26,3 +27,4 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче