mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:52:45 +08:00
topic-status-info
component wasn't updated when topic is closed/opened.
This commit is contained in:
parent
2fd1c49b88
commit
0bbad5040a
|
@ -4,13 +4,14 @@ export default Ember.Component.extend(bufferedRender({
|
|||
elementId: 'topic-status-info',
|
||||
delayedRerender: null,
|
||||
|
||||
rerenderTriggers: ['topic.closed',
|
||||
'topic.topic_status_update.execute_at',
|
||||
'topic.topic_status_update.based_on_last_post',
|
||||
'topic.topic_status_update.duration'],
|
||||
rerenderTriggers: [
|
||||
'topic.topic_status_update',
|
||||
'topic.topic_status_update.execute_at',
|
||||
'topic.topic_status_update.based_on_last_post',
|
||||
'topic.topic_status_update.duration'
|
||||
],
|
||||
|
||||
buildBuffer(buffer) {
|
||||
if (Ember.isEmpty(this.get('topic.topic_status_update.execute_at'))) return;
|
||||
if (!this.get('topic.topic_status_update')) return;
|
||||
|
||||
let statusUpdateAt = moment(this.get('topic.topic_status_update.execute_at'));
|
||||
|
|
|
@ -588,7 +588,11 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
},
|
||||
|
||||
toggleClosed() {
|
||||
this.get('content').toggleStatus('closed');
|
||||
const topic = this.get('content');
|
||||
|
||||
this.get('content').toggleStatus('closed').then(result => {
|
||||
topic.set('topic_status_update', result.topic_status_update);
|
||||
});
|
||||
},
|
||||
|
||||
recoverTopic() {
|
||||
|
|
|
@ -223,7 +223,7 @@ const Topic = RestModel.extend({
|
|||
|
||||
toggleStatus(property) {
|
||||
this.toggleProperty(property);
|
||||
this.saveStatus(property, !!this.get(property));
|
||||
return this.saveStatus(property, !!this.get(property));
|
||||
},
|
||||
|
||||
saveStatus(property, value, until) {
|
||||
|
|
|
@ -273,7 +273,12 @@ class TopicsController < ApplicationController
|
|||
@topic = Topic.find_by(id: topic_id)
|
||||
guardian.ensure_can_moderate!(@topic)
|
||||
@topic.update_status(status, enabled, current_user, until: params[:until])
|
||||
render nothing: true
|
||||
|
||||
render json: success_json.merge!(
|
||||
topic_status_update: TopicStatusUpdateSerializer.new(
|
||||
TopicStatusUpdate.find_by(topic: @topic), root: false
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def mute
|
||||
|
|
|
@ -412,14 +412,19 @@ describe TopicsController do
|
|||
expect { xhr :put, :status, topic_id: @topic.id, status: 'title', enabled: 'true' }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it 'calls update_status on the forum topic with false' do
|
||||
Topic.any_instance.expects(:update_status).with('closed', false, @user, until: nil)
|
||||
xhr :put, :status, topic_id: @topic.id, status: 'closed', enabled: 'false'
|
||||
end
|
||||
it 'should update the status of the topic correctly' do
|
||||
@topic = Fabricate(:topic, user: @user, closed: true, topic_status_updates: [
|
||||
Fabricate(:topic_status_update, status_type: TopicStatusUpdate.types[:open])
|
||||
])
|
||||
|
||||
it 'calls update_status on the forum topic with true' do
|
||||
Topic.any_instance.expects(:update_status).with('closed', true, @user, until: nil)
|
||||
xhr :put, :status, topic_id: @topic.id, status: 'closed', enabled: 'true'
|
||||
xhr :put, :status, topic_id: @topic.id, status: 'closed', enabled: 'false'
|
||||
|
||||
expect(response).to be_success
|
||||
expect(@topic.reload.closed).to eq(false)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
|
||||
expect(body['topic_status_update']).to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user