diff --git a/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 b/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 index e1a122a37a7..c12ae43a591 100644 --- a/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 @@ -15,12 +15,15 @@ export default Ember.Controller.extend(ModalFunctionality, { @computed("model.closed") publicTimerTypes(closed) { - return [ + let types = [ { id: CLOSE_STATUS_TYPE, name: I18n.t(closed ? 'topic.temp_open.title' : 'topic.auto_close.title'), }, { id: OPEN_STATUS_TYPE, name: I18n.t(closed ? 'topic.auto_reopen.title' : 'topic.temp_close.title') }, { id: PUBLISH_TO_CATEGORY_STATUS_TYPE, name: I18n.t('topic.publish_to_category.title') }, - { id: DELETE_STATUS_TYPE, name: I18n.t('topic.auto_delete.title') } ]; + if (this.currentUser.get("staff")) { + types.push({ id: DELETE_STATUS_TYPE, name: I18n.t('topic.auto_delete.title') }); + } + return types; }, @computed() @@ -32,20 +35,12 @@ export default Ember.Controller.extend(ModalFunctionality, { @computed("isPublic", 'publicTimerTypes', 'privateTimerTypes') selections(isPublic, publicTimerTypes, privateTimerTypes) { - if (isPublic === 'true') { - return publicTimerTypes; - } else { - return privateTimerTypes; - } + return "true" === isPublic ? publicTimerTypes : privateTimerTypes; }, @computed('isPublic', 'model.topic_timer', 'model.private_topic_timer') topicTimer(isPublic, publicTopicTimer, privateTopicTimer) { - if (isPublic === 'true') { - return publicTopicTimer; - } else { - return privateTopicTimer; - } + return "true" === isPublic ? publicTopicTimer : privateTopicTimer; }, _setTimer(time, statusType) { diff --git a/test/javascripts/acceptance/topic-edit-timer-test.js.es6 b/test/javascripts/acceptance/topic-edit-timer-test.js.es6 index 569639d810a..b3ed4df7440 100644 --- a/test/javascripts/acceptance/topic-edit-timer-test.js.es6 +++ b/test/javascripts/acceptance/topic-edit-timer-test.js.es6 @@ -1,4 +1,4 @@ -import { acceptance } from 'helpers/qunit-helpers'; +import { acceptance, replaceCurrentUser } from 'helpers/qunit-helpers'; acceptance('Topic - Edit timer', { loggedIn: true }); QUnit.test('default', assert => { @@ -162,6 +162,22 @@ QUnit.test('schedule', assert => { }); }); +QUnit.test("TL4 can't auto-delete", assert => { + replaceCurrentUser({ staff: false, trust_level: 4 }); + + visit('/t/internationalization-localization'); + click('.toggle-admin-menu'); + click('.topic-admin-status-update button'); + + const timerType = selectKit('.select-kit.timer-type'); + + timerType.expand(); + + andThen(() => { + assert.ok(!timerType.rowByValue("delete").exists()); + }); +}); + QUnit.test('auto delete', assert => { const timerType = selectKit('.select-kit.timer-type'); const futureDateInputSelector = selectKit('.future-date-input-selector');