mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FEATURE: Add toggle topic visibility button in popup menu.
This commit is contained in:
parent
16a383ea1e
commit
36ddb1787e
7 changed files with 107 additions and 11 deletions
|
@ -63,6 +63,7 @@ export default Ember.Controller.extend({
|
|||
isUploading: false,
|
||||
topic: null,
|
||||
linkLookup: null,
|
||||
whisperOrUnlistTopic: Ember.computed.or('model.whisper', 'model.unlistTopic'),
|
||||
|
||||
@computed('model.replyingToTopic', 'model.creatingPrivateMessage', 'model.targetUsernames')
|
||||
focusTarget(replyingToTopic, creatingPM, usernames) {
|
||||
|
@ -109,10 +110,26 @@ export default Ember.Controller.extend({
|
|||
!creatingPrivateMessage;
|
||||
},
|
||||
|
||||
@computed('model.action')
|
||||
canWhisper(action) {
|
||||
@computed('model.whisper', 'model.unlistTopic')
|
||||
whisperOrUnlistTopicText(whisper, unlistTopic) {
|
||||
if (whisper) {
|
||||
return I18n.t("composer.whisper");
|
||||
} else if (unlistTopic) {
|
||||
return I18n.t("composer.unlist");
|
||||
}
|
||||
},
|
||||
|
||||
@computed
|
||||
isStaffUser() {
|
||||
const currentUser = this.currentUser;
|
||||
return currentUser && currentUser.get('staff') && this.siteSettings.enable_whispers && action === Composer.REPLY;
|
||||
return currentUser && currentUser.get('staff');
|
||||
},
|
||||
|
||||
canUnlistTopic: Em.computed.and('model.creatingTopic', 'isStaffUser'),
|
||||
|
||||
@computed('model.action', 'isStaffUser')
|
||||
canWhisper(action, isStaffUser) {
|
||||
return isStaffUser && this.siteSettings.enable_whispers && action === Composer.REPLY;
|
||||
},
|
||||
|
||||
@computed("popupMenuOptions")
|
||||
|
@ -132,11 +149,20 @@ export default Ember.Controller.extend({
|
|||
return option;
|
||||
},
|
||||
|
||||
@computed("model.composeState")
|
||||
@computed("model.composeState", "model.creatingTopic")
|
||||
popupMenuOptions(composeState) {
|
||||
if (composeState === 'open') {
|
||||
let options = [];
|
||||
|
||||
options.push(this._setupPopupMenuOption(() => {
|
||||
return {
|
||||
action: 'toggleInvisible',
|
||||
icon: 'eye-slash',
|
||||
label: 'composer.toggle_unlisted',
|
||||
condition: "canUnlistTopic"
|
||||
};
|
||||
}));
|
||||
|
||||
options.push(this._setupPopupMenuOption(() => {
|
||||
return {
|
||||
action: 'toggleWhisper',
|
||||
|
@ -210,6 +236,10 @@ export default Ember.Controller.extend({
|
|||
this.toggleProperty('model.whisper');
|
||||
},
|
||||
|
||||
toggleInvisible() {
|
||||
this.toggleProperty('model.unlistTopic');
|
||||
},
|
||||
|
||||
toggleToolbar() {
|
||||
this.toggleProperty('showToolbar');
|
||||
},
|
||||
|
@ -503,7 +533,6 @@ export default Ember.Controller.extend({
|
|||
this.set('scopedCategoryId', opts.categoryId);
|
||||
}
|
||||
|
||||
|
||||
this.setProperties({ showEditReason: false, editReason: null });
|
||||
|
||||
// If we want a different draft than the current composer, close it and clear our model.
|
||||
|
@ -545,6 +574,12 @@ export default Ember.Controller.extend({
|
|||
}).then(resolve, reject);
|
||||
}
|
||||
|
||||
if (composerModel) {
|
||||
if (composerModel.get('action') !== opts.action) {
|
||||
composerModel.setProperties({ unlistTopic: false, whisper: false });
|
||||
}
|
||||
}
|
||||
|
||||
self._setModel(composerModel, opts);
|
||||
resolve();
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ const CLOSED = 'closed',
|
|||
_create_serializer = {
|
||||
raw: 'reply',
|
||||
title: 'title',
|
||||
unlist_topic: 'unlistTopic',
|
||||
category: 'categoryId',
|
||||
topic_id: 'topic.id',
|
||||
is_warning: 'isWarning',
|
||||
|
@ -41,6 +42,7 @@ const CLOSED = 'closed',
|
|||
|
||||
const Composer = RestModel.extend({
|
||||
_categoryId: null,
|
||||
unlistTopic: false,
|
||||
|
||||
archetypes: function() {
|
||||
return this.site.get('archetypes');
|
||||
|
@ -504,6 +506,7 @@ const Composer = RestModel.extend({
|
|||
reply: null,
|
||||
post: null,
|
||||
title: null,
|
||||
unlistTopic: false,
|
||||
editReason: null,
|
||||
stagedPost: false,
|
||||
typingTime: 0,
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
<div class='reply-to'>
|
||||
{{{model.actionTitle}}}
|
||||
{{#unless site.mobileView}}
|
||||
{{#if model.whisper}}
|
||||
<span class='whisper'>({{i18n "composer.whisper"}})</span>
|
||||
{{#if whisperOrUnlistTopicText}}
|
||||
<span class='whisper'>({{whisperOrUnlistTopicText}})</span>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
|
@ -106,7 +106,7 @@
|
|||
<a href {{action "cancel"}} class='cancel' tabindex="6">{{i18n 'cancel'}}</a>
|
||||
|
||||
{{#if site.mobileView}}
|
||||
{{#if model.whisper}}
|
||||
{{#if whisperOrUnlistTopic}}
|
||||
<span class='whisper'><i class='fa fa-eye-slash'></i></span>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -554,10 +554,12 @@ class PostsController < ApplicationController
|
|||
:auto_track,
|
||||
:typing_duration_msecs,
|
||||
:composer_open_duration_msecs,
|
||||
:visible
|
||||
]
|
||||
|
||||
# param munging for WordPress
|
||||
params[:auto_track] = !(params[:auto_track].to_s == "false") if params[:auto_track]
|
||||
params[:visible] = (params[:unlist_topic].to_s == "false") if params[:unlist_topic]
|
||||
|
||||
if api_key_valid?
|
||||
# php seems to be sending this incorrectly, don't fight with it
|
||||
|
|
|
@ -1016,9 +1016,11 @@ en:
|
|||
more_emoji: "more..."
|
||||
options: "Options"
|
||||
whisper: "whisper"
|
||||
unlist: "unlisted"
|
||||
|
||||
add_warning: "This is an official warning."
|
||||
toggle_whisper: "Toggle Whisper"
|
||||
toggle_unlisted: "Toggle Unlisted"
|
||||
posting_not_on_topic: "Which topic do you want to reply to?"
|
||||
saving_draft_tip: "saving..."
|
||||
saved_draft_tip: "saved"
|
||||
|
|
|
@ -93,10 +93,13 @@ class TopicCreator
|
|||
end
|
||||
|
||||
def setup_topic_params
|
||||
@opts[:visible] = true if @opts[:visible].nil?
|
||||
|
||||
topic_params = {
|
||||
title: @opts[:title],
|
||||
user_id: @user.id,
|
||||
last_post_user_id: @user.id
|
||||
last_post_user_id: @user.id,
|
||||
visible: @opts[:visible]
|
||||
}
|
||||
|
||||
[:subtype, :archetype, :meta_data, :import_mode].each do |key|
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Composer", { loggedIn: true });
|
||||
acceptance("Composer", {
|
||||
loggedIn: true,
|
||||
settings: {
|
||||
enable_whispers: true
|
||||
}
|
||||
});
|
||||
|
||||
test("Tests the Composer controls", () => {
|
||||
visit("/");
|
||||
|
@ -254,6 +259,52 @@ test("Composer can toggle between edit and reply", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test("Composer can toggle between reply and createTopic", () => {
|
||||
visit("/t/this-is-a-test-topic/9");
|
||||
|
||||
click('.topic-post:eq(0) button.reply');
|
||||
click('button.options');
|
||||
click('.popup-menu .fa-eye-slash');
|
||||
andThen(() => {
|
||||
ok(
|
||||
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) > 0,
|
||||
'it sets the post type to whisper'
|
||||
);
|
||||
});
|
||||
|
||||
visit("/");
|
||||
andThen(() => {
|
||||
ok(exists('#create-topic'), 'the create topic button is visible');
|
||||
});
|
||||
|
||||
click('#create-topic');
|
||||
andThen(() => {
|
||||
ok(
|
||||
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) === -1,
|
||||
"it should reset the state of the composer's model"
|
||||
);
|
||||
});
|
||||
|
||||
click('button.options');
|
||||
click('.popup-menu .fa-eye-slash');
|
||||
andThen(() => {
|
||||
ok(
|
||||
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) > 0,
|
||||
'it sets the topic to unlisted'
|
||||
);
|
||||
});
|
||||
|
||||
visit("/t/this-is-a-test-topic/9");
|
||||
|
||||
click('.topic-post:eq(0) button.reply');
|
||||
andThen(() => {
|
||||
ok(
|
||||
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) === -1,
|
||||
"it should reset the state of the composer's model"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("Composer with dirty reply can toggle to edit", () => {
|
||||
visit("/t/this-is-a-test-topic/9");
|
||||
|
||||
|
|
Loading…
Reference in a new issue