0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 01:10:28 +01:00

Add login button when no_access reason is requiresLogin

Dieser Commit ist enthalten in:
Angus McLeod 2024-07-09 11:24:40 +02:00
Ursprung cff8f9f427
Commit 54a9e9470e
4 geänderte Dateien mit 30 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,8 @@ import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import { dasherize } from "@ember/string"; import { dasherize } from "@ember/string";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import cookie from "discourse/lib/cookie";
import { getOwner } from "@ember/application";
export default Component.extend({ export default Component.extend({
classNameBindings: [":wizard-no-access", "reasonClass"], classNameBindings: [":wizard-no-access", "reasonClass"],
@ -17,6 +19,11 @@ export default Component.extend({
return this.siteSettings.title || ""; return this.siteSettings.title || "";
}, },
@discourseComputed("reason")
showLoginButton(reason) {
return reason === "requiresLogin";
},
actions: { actions: {
skip() { skip() {
if (this.currentUser) { if (this.currentUser) {
@ -25,5 +32,10 @@ export default Component.extend({
window.location = getURL("/"); window.location = getURL("/");
} }
}, },
showLogin() {
cookie("destination_url", getURL(`/w/${this.get("wizardId")}`));
getOwner(this).lookup("route:application").send("showLogin");
}
}, },
}); });

Datei anzeigen

@ -1,11 +1,17 @@
<div>{{text}}</div> <div>{{text}}</div>
<div class="no-access-gutter"> <div class="no-access-gutter">
<button <a
class="wizard-btn primary return-to-site" class="return-to-site"
{{action "skip"}} {{action "skip"}}
type="button"
> >
{{i18n "wizard.return_to_site" siteName=siteName}} {{i18n "wizard.return_to_site" siteName=siteName}}
{{d-icon "sign-out-alt"}} </a>
</button> {{#if showLoginButton}}
<DButton
class="btn-primary btn-small login-button"
@action={{action "showLogin"}}
@label="log_in"
@icon="user"
/>
{{/if}}
</div> </div>

Datei anzeigen

@ -158,7 +158,12 @@ body.custom-wizard {
.no-access-gutter { .no-access-gutter {
margin-top: 10px; margin-top: 10px;
display: flex; display: flex;
justify-content: flex-end; justify-content: space-between;
.return-to-site {
display: flex;
align-items: center;
}
} }
.powered-by-discourse { .powered-by-discourse {

Datei anzeigen

@ -5,7 +5,7 @@ en:
completed: "You have completed this wizard." completed: "You have completed this wizard."
not_permitted: "You are not permitted to access this wizard." not_permitted: "You are not permitted to access this wizard."
none: "There is no wizard here." none: "There is no wizard here."
return_to_site: "Return to {{siteName}}" return_to_site: "Return to {{siteName}}."
requires_login: "You need to be logged in to access this wizard." requires_login: "You need to be logged in to access this wizard."
reset: "Reset this wizard." reset: "Reset this wizard."
step_not_permitted: "You're not permitted to view this step." step_not_permitted: "You're not permitted to view this step."