UX: Better error message when logging out in read only mode.

This commit is contained in:
Guo Xiang Tan 2016-03-01 17:36:30 +08:00
parent d70e4ac5b6
commit bfea842d32
2 changed files with 8 additions and 5 deletions

View file

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

View file

@ -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 <a href='http://blog.discourse.org/2014/08/building-a-discourse-community/'>get this discussion started!</a> There are currently <strong>%{currentTopics} / %{requiredTopics}</strong> topics and <strong>%{currentPosts} / %{requiredPosts}</strong> posts. New visitors need some conversations to read and respond to."
too_few_topics_notice: "Let's <a href='http://blog.discourse.org/2014/08/building-a-discourse-community/'>get this discussion started!</a> There are currently <strong>%{currentTopics} / %{requiredTopics}</strong> topics. New visitors need some conversations to read and respond to."
too_few_posts_notice: "Let's <a href='http://blog.discourse.org/2014/08/building-a-discourse-community/'>get this discussion started!</a> There are currently <strong>%{currentPosts} / %{requiredPosts}</strong> posts. New visitors need some conversations to read and respond to."