From bfea842d324c9f62ac33da64e5ec356493cbd635 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 1 Mar 2016 17:36:30 +0800 Subject: [PATCH] UX: Better error message when logging out in read only mode. --- .../javascripts/discourse/routes/application.js.es6 | 12 +++++++----- config/locales/client.en.yml | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index b25208f6c..184646a9c 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -4,10 +4,10 @@ import showModal from 'discourse/lib/show-modal'; import OpenComposer from "discourse/mixins/open-composer"; import Category from 'discourse/models/category'; -function unlessReadOnly(method) { +function unlessReadOnly(method, message) { return function() { if (this.site.get("isReadOnly")) { - bootbox.alert(I18n.t("read_only_mode.login_disabled")); + bootbox.alert(message); } else { this[method](); } @@ -19,7 +19,9 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { actions: { - logout() { + logout: unlessReadOnly('_handleLogout', I18n.t("read_only_mode.logout_disabled")), + + _handleLogout() { if (this.currentUser) { this.currentUser.destroySession().then(() => logout(this.siteSettings, this.keyValueStore)); } @@ -83,9 +85,9 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { return true; }, - showLogin: unlessReadOnly('handleShowLogin'), + showLogin: unlessReadOnly('handleShowLogin', I18n.t("read_only_mode.login_disabled")), - showCreateAccount: unlessReadOnly('handleShowCreateAccount'), + showCreateAccount: unlessReadOnly('handleShowCreateAccount', I18n.t("read_only_mode.login_disabled")), showForgotPassword() { showModal('forgotPassword', { title: 'forgot_password.title' }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d4d17f0a1..d4d246a00 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -777,6 +777,7 @@ en: read_only_mode: enabled: "This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now." login_disabled: "Login is disabled while the site is in read only mode." + logout_disabled: "Logout is disabled while the site is in read only mode." too_few_topics_and_posts_notice: "Let's get this discussion started! There are currently %{currentTopics} / %{requiredTopics} topics and %{currentPosts} / %{requiredPosts} posts. New visitors need some conversations to read and respond to." too_few_topics_notice: "Let's get this discussion started! There are currently %{currentTopics} / %{requiredTopics} topics. New visitors need some conversations to read and respond to." too_few_posts_notice: "Let's get this discussion started! There are currently %{currentPosts} / %{requiredPosts} posts. New visitors need some conversations to read and respond to."