mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 00:23:43 +08:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
|
import Component from "@glimmer/component";
|
||
|
import { action } from "@ember/object";
|
||
|
import { inject as service } from "@ember/service";
|
||
|
import RouteTemplate from "ember-route-template";
|
||
|
import getUrl from "discourse-common/lib/get-url";
|
||
|
import WizardCanvas from "../components/wizard-canvas";
|
||
|
import WizardStep from "../components/wizard-step";
|
||
|
|
||
|
export default RouteTemplate(
|
||
|
class extends Component {
|
||
|
@service router;
|
||
|
|
||
|
<template>
|
||
|
{{#if this.showCanvas}}
|
||
|
<WizardCanvas />
|
||
|
{{/if}}
|
||
|
|
||
|
<WizardStep
|
||
|
@step={{@model.step}}
|
||
|
@wizard={{@model.wizard}}
|
||
|
@goNext={{this.goNext}}
|
||
|
@goBack={{this.goBack}}
|
||
|
/>
|
||
|
</template>
|
||
|
|
||
|
get step() {
|
||
|
return this.args.model.step;
|
||
|
}
|
||
|
|
||
|
get showCanvas() {
|
||
|
return this.step.id === "ready";
|
||
|
}
|
||
|
|
||
|
@action
|
||
|
goNext(response) {
|
||
|
const next = this.step.next;
|
||
|
|
||
|
if (response?.refresh_required) {
|
||
|
document.location = getUrl(`/wizard/steps/${next}`);
|
||
|
} else if (response?.success && next) {
|
||
|
this.router.transitionTo("wizard.step", next);
|
||
|
} else if (response?.success) {
|
||
|
this.router.transitionTo("discovery.latest");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@action
|
||
|
goBack() {
|
||
|
this.router.transitionTo("wizard.step", this.step.previous);
|
||
|
}
|
||
|
}
|
||
|
);
|