Skip to content

Commit

Permalink
Merge pull request #267 from paviliondev/resolve_deprecations
Browse files Browse the repository at this point in the history
COMPATIBILITY:  resolve deprecations expected in Ember upgrade for Discourse 3.2
  • Loading branch information
angusmcleod authored Sep 15, 2023
2 parents bce0acb + 2460685 commit 5f99dc2
Show file tree
Hide file tree
Showing 28 changed files with 243 additions and 200 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<DModal @closeModal={{@closeModal}} @title={{this.title}}>
{{#if loading}}
<LoadingSpinner size="large" />
{{else}}
<div class="edit-directory-columns-container">
{{#each @model.columns as |column|}}
<div class="edit-directory-column">
<div class="left-content">
<label class="column-name">
<Input @type="checkbox" @checked={{column.enabled}} />
{{directory-table-header-title
field=column.label
translated=true
}}
</label>
</div>
</div>
{{/each}}
</div>
{{/if}}
<div class="modal-footer">
<DButton
class="btn-primary"
@label="directory.edit_columns.save"
@action={{action "save"}}
/>

<DButton
class="btn-secondary reset-to-default"
@label="directory.edit_columns.reset_to_default"
@action={{action "resetToDefault"}}
/>
</div>
</DModal>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import I18n from "I18n";

export default class AdminWizardsColumnComponent extends Component {
title = I18n.t("admin.wizard.edit_columns");

@action save() {
this.args.closeModal();
}

@action resetToDefault() {
this.args.model.reset();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<DModal
@closeModal={{@closeModal}}
class="next-session-time-modal"
@title={{this.title}}
>
<DateTimeInput
@date={{this.bufferedDateTime}}
@onChange={{action "dateTimeChanged"}}
@showTime="true"
@clearable="true"
/>
<div class="modal-footer">
<DButton
@action={{action "submit"}}
class="btn-primary"
@label="admin.wizard.after_time_modal.done"
@disabled={{this.submitDisabled}}
/>
</div>
</DModal>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import I18n from "I18n";

export default class NextSessionScheduledComponent extends Component {
@tracked bufferedDateTime;
title = I18n.t("admin.wizard.after_time_modal.title");

constructor() {
super(...arguments);
this.bufferedDateTime = this.args.model.dateTime
? moment(this.args.model.dateTime)
: moment(Date.now());
}

get submitDisabled() {
return moment().isAfter(this.bufferedDateTime);
}

@action submit() {
const dateTime = this.bufferedDateTime;
this.args.model.update(moment(dateTime).utc().toISOString());
this.args.closeModal();
}

@action dateTimeChanged(dateTime) {
this.bufferedDateTime = dateTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { selectKitContent } from "../lib/wizard";
import { underscore } from "@ember/string";
import Controller from "@ember/controller";
import I18n from "I18n";
import { inject as service } from "@ember/service";

export default Controller.extend({
router: service(),

queryParams: ["refresh_list"],
loadingSubscriptions: false,
notAuthorized: not("api.authorized"),
Expand Down Expand Up @@ -248,7 +251,7 @@ export default Controller.extend({
.catch(popupAjaxError)
.then((result) => {
if (result.success) {
this.transitionToRoute("adminWizardsApis").then(() => {
this.router.transitionTo("adminWizardsApis").then(() => {
this.send("refreshModel");
});
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import Controller from "@ember/controller";
import { empty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { fmt } from "discourse/lib/computed";
import showModal from "discourse/lib/show-modal";
import { inject as service } from "@ember/service";
import AdminWizardsColumnsModal from "../components/modal/admin-wizards-columns";
import CustomWizardAdmin from "../models/custom-wizard-admin";
import { formatModel } from "../lib/wizard-submission";

export default Controller.extend({
modal: service(),
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
noResults: empty("submissions"),
page: 0,
Expand Down Expand Up @@ -57,7 +59,7 @@ export default Controller.extend({
},

showEditColumnsModal() {
return showModal("admin-wizards-columns", {
return this.modal.show(AdminWizardsColumnsModal, {
model: {
columns: this.get("fields"),
reset: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
observes,
} from "discourse-common/utils/decorators";
import { notEmpty } from "@ember/object/computed";
import showModal from "discourse/lib/show-modal";
import { inject as service } from "@ember/service";
import NextSessionScheduledModal from "../components/modal/next-session-scheduled";
import { generateId, wizardFieldList } from "../lib/wizard";
import { dasherize } from "@ember/string";
import { later, scheduleOnce } from "@ember/runloop";
Expand All @@ -13,6 +14,7 @@ import I18n from "I18n";
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";

export default Controller.extend({
modal: service(),
hasName: notEmpty("wizard.name"),

@observes("currentStep")
Expand Down Expand Up @@ -126,15 +128,13 @@ export default Controller.extend({
},

setNextSessionScheduled() {
let controller = showModal("next-session-scheduled", {
this.modal.show(NextSessionScheduledModal, {
model: {
dateTime: this.wizard.after_time_scheduled,
update: (dateTime) =>
this.set("wizard.after_time_scheduled", dateTime),
},
});

controller.setup();
},

copyUrl() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Controller from "@ember/controller";
import getUrl from "discourse-common/lib/get-url";
import { inject as service } from "@ember/service";

export default Controller.extend({
router: service(),
wizard: null,
step: null,

Expand All @@ -15,12 +17,12 @@ export default Controller.extend({
const wizardId = this.get("wizard.id");
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
} else {
this.transitionToRoute("customWizardStep", nextStepId);
this.router.transitionTo("customWizardStep", nextStepId);
}
},

goBack() {
this.transitionToRoute("customWizardStep", this.get("step.previous"));
this.router.transitionTo("customWizardStep", this.get("step.previous"));
},

showMessage(message) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import CustomWizardApi from "../models/custom-wizard-api";
import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model(params) {
if (params.name === "create") {
return CustomWizardApi.create({ isNew: true });
Expand All @@ -12,7 +15,7 @@ export default DiscourseRoute.extend({

afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsApi");
return this.router.transitionTo("adminWizardsApi");
}
},

Expand Down
9 changes: 6 additions & 3 deletions assets/javascripts/discourse/routes/admin-wizards-api.js.es6
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse";
import CustomWizardApi from "../models/custom-wizard-api";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model() {
return CustomWizardApi.list();
},
Expand All @@ -25,11 +28,11 @@ export default DiscourseRoute.extend({
actions: {
changeApi(apiName) {
this.controllerFor("adminWizardsApi").set("apiName", apiName);
this.transitionTo("adminWizardsApiShow", apiName);
this.router.transitionTo("adminWizardsApiShow", apiName);
},

afterDestroy() {
this.transitionTo("adminWizardsApi").then(() => this.refresh());
this.router.transitionTo("adminWizardsApi").then(() => this.refresh());
},

afterSave(apiName) {
Expand All @@ -38,7 +41,7 @@ export default DiscourseRoute.extend({

createApi() {
this.controllerFor("adminWizardsApi").set("apiName", "create");
this.transitionTo("adminWizardsApiShow", "create");
this.router.transitionTo("adminWizardsApiShow", "create");
},
},
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import CustomWizardLogs from "../models/custom-wizard-logs";
import DiscourseRoute from "discourse/routes/discourse";
import { A } from "@ember/array";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model(params) {
return CustomWizardLogs.list(params.wizardId);
},

afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsLogs");
return this.router.transitionTo("adminWizardsLogs");
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model() {
return ajax(`/admin/wizards/wizard`);
},
Expand All @@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: {
changeWizard(wizardId) {
this.controllerFor("adminWizardsLogs").set("wizardId", wizardId);
this.transitionTo("adminWizardsLogsShow", wizardId);
this.router.transitionTo("adminWizardsLogsShow", wizardId);
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import { A } from "@ember/array";
import CustomWizardAdmin from "../models/custom-wizard-admin";
import DiscourseRoute from "discourse/routes/discourse";
import { formatModel } from "../lib/wizard-submission";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model(params) {
return CustomWizardAdmin.submissions(params.wizardId);
},

afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsSubmissions");
return this.router.transitionTo("adminWizardsSubmissions");
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax";
import { inject as service } from "@ember/service";

export default DiscourseRoute.extend({
router: service(),

model() {
return ajax(`/admin/wizards/wizard`);
},
Expand All @@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: {
changeWizard(wizardId) {
this.controllerFor("adminWizardsSubmissions").set("wizardId", wizardId);
this.transitionTo("adminWizardsSubmissionsShow", wizardId);
this.router.transitionTo("adminWizardsSubmissionsShow", wizardId);
},
},
});
Loading

0 comments on commit 5f99dc2

Please sign in to comment.