This reverts commit 0b10e335ae
.
I realised that some of these actions are overridden in themes/plugins, so this is going to cause problems (especially because modifyClass doesn't currently work well with the `@action` decorator)
This commit is contained in:
parent
0b10e335ae
commit
0ddad8fc64
|
@ -21,12 +21,14 @@ import getURL from "discourse-common/lib/get-url";
|
|||
import I18n from "discourse-i18n";
|
||||
import NotActivatedModal from "../components/modal/not-activated";
|
||||
|
||||
function unlessStrictlyReadOnly(cb, message) {
|
||||
function unlessStrictlyReadOnly(method, message) {
|
||||
return function () {
|
||||
if (this.site.isReadOnly && !this.site.isStaffWritesOnly) {
|
||||
this.dialog.alert(message);
|
||||
} else {
|
||||
cb();
|
||||
this[method]();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ApplicationRoute = DiscourseRoute.extend({
|
||||
|
@ -72,25 +74,20 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
return true;
|
||||
},
|
||||
|
||||
@action
|
||||
actions: {
|
||||
toggleMobileView() {
|
||||
mobile.toggleMobileView();
|
||||
},
|
||||
|
||||
@action
|
||||
toggleSidebar() {
|
||||
this.controllerFor("application").send("toggleSidebar");
|
||||
},
|
||||
|
||||
@action
|
||||
logout() {
|
||||
unlessStrictlyReadOnly.apply(this, [
|
||||
() => this._handleLogout(),
|
||||
I18n.t("read_only_mode.logout_disabled"),
|
||||
]);
|
||||
},
|
||||
logout: unlessStrictlyReadOnly(
|
||||
"_handleLogout",
|
||||
I18n.t("read_only_mode.logout_disabled")
|
||||
),
|
||||
|
||||
@action
|
||||
_collectTitleTokens(tokens) {
|
||||
tokens.push(this.siteTitle);
|
||||
if (
|
||||
|
@ -103,7 +100,6 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
this.documentTitle.setTitle(tokens.join(" - "));
|
||||
},
|
||||
|
||||
@action
|
||||
composePrivateMessage(user, post) {
|
||||
const recipients = user ? user.get("username") : "";
|
||||
const reply = post
|
||||
|
@ -127,7 +123,6 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
});
|
||||
},
|
||||
|
||||
@action
|
||||
error(err, transition) {
|
||||
const xhrOrErr = err.jqXHR ? err.jqXHR : err;
|
||||
const exceptionController = this.controllerFor("exception");
|
||||
|
@ -171,15 +166,11 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
return shouldBubble;
|
||||
},
|
||||
|
||||
@action
|
||||
showLogin() {
|
||||
unlessStrictlyReadOnly.apply(this, [
|
||||
() => this.handleShowLogin(),
|
||||
I18n.t("read_only_mode.login_disabled"),
|
||||
]);
|
||||
},
|
||||
showLogin: unlessStrictlyReadOnly(
|
||||
"handleShowLogin",
|
||||
I18n.t("read_only_mode.login_disabled")
|
||||
),
|
||||
|
||||
@action
|
||||
showCreateAccount(createAccountProps = {}) {
|
||||
if (this.site.isReadOnly) {
|
||||
this.dialog.alert(I18n.t("read_only_mode.login_disabled"));
|
||||
|
@ -188,28 +179,23 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@action
|
||||
showForgotPassword() {
|
||||
this.modal.show(ForgotPassword);
|
||||
},
|
||||
|
||||
@action
|
||||
showNotActivated(props) {
|
||||
this.modal.show(NotActivatedModal, { model: props });
|
||||
},
|
||||
|
||||
@action
|
||||
showUploadSelector() {
|
||||
document.getElementById("file-uploader").click();
|
||||
},
|
||||
|
||||
@action
|
||||
showKeyboardShortcutsHelp() {
|
||||
this.modal.show(KeyboardShortcutsHelp);
|
||||
},
|
||||
|
||||
// Close the current modal, and destroy its state.
|
||||
@action
|
||||
closeModal(initiatedBy) {
|
||||
return this.modal.close(initiatedBy);
|
||||
},
|
||||
|
@ -219,27 +205,22 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
This is useful if you want to prompt for confirmation. hideModal, ask "Are you sure?",
|
||||
user clicks "No", reopenModal. If user clicks "Yes", be sure to call closeModal.
|
||||
**/
|
||||
@action
|
||||
hideModal() {
|
||||
return this.modal.hide();
|
||||
},
|
||||
|
||||
@action
|
||||
reopenModal() {
|
||||
return this.modal.reopen();
|
||||
},
|
||||
|
||||
@action
|
||||
editCategory(category) {
|
||||
DiscourseURL.routeTo(`/c/${Category.slugFor(category)}/edit`);
|
||||
},
|
||||
|
||||
@action
|
||||
checkEmail(user) {
|
||||
user.checkEmail();
|
||||
},
|
||||
|
||||
@action
|
||||
createNewTopicViaParams(title, body, categoryId, tags) {
|
||||
deprecated(
|
||||
"createNewTopicViaParam on the application route is deprecated. Use the composer service instead",
|
||||
|
@ -253,7 +234,6 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
});
|
||||
},
|
||||
|
||||
@action
|
||||
createNewMessageViaParams({
|
||||
recipients = "",
|
||||
topicTitle = "",
|
||||
|
@ -271,6 +251,7 @@ const ApplicationRoute = DiscourseRoute.extend({
|
|||
hasGroups,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
handleShowLogin() {
|
||||
if (this.siteSettings.enable_discourse_connect) {
|
||||
|
|
Loading…
Reference in New Issue