UX: don't show 'auto delete' option for TL4

This commit is contained in:
Régis Hanol 2018-05-17 00:42:48 +02:00
parent 01b0d9d235
commit 674318e127
2 changed files with 24 additions and 13 deletions

View File

@ -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) {

View File

@ -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');