1
0
Fork 0
Dieser Commit ist enthalten in:
angusmcleod 2021-09-07 20:13:01 +08:00
Ursprung 7c9a0ef862
Commit 0313c773e8
15 geänderte Dateien mit 111 neuen und 99 gelöschten Zeilen

Datei anzeigen

@ -8,8 +8,8 @@ const klasses = ["topic", "post", "group", "category"];
const types = ["string", "boolean", "integer", "json"]; const types = ["string", "boolean", "integer", "json"];
const proTypes = { const proTypes = {
klass: ["group", "category"], klass: ["group", "category"],
type: ["json"] type: ["json"],
} };
const generateContent = function (array, type, proSubscribed = false) { const generateContent = function (array, type, proSubscribed = false) {
return array.reduce((result, key) => { return array.reduce((result, key) => {
@ -19,7 +19,7 @@ const generateContent = function (array, type, proSubscribed = false) {
result.push({ result.push({
id: key, id: key,
name: I18n.t(`admin.wizard.custom_field.${type}.${key}`), name: I18n.t(`admin.wizard.custom_field.${type}.${key}`),
pro pro,
}); });
} }
return result; return result;

Datei anzeigen

@ -102,10 +102,10 @@ export default Component.extend(UndoChanges, {
result.push({ result.push({
id: type, id: type,
name: I18n.t(`admin.wizard.action.${type}.label`), name: I18n.t(`admin.wizard.action.${type}.label`),
pro pro,
}); });
} }
return result; return result;
}, []); }, []);
} },
}); });

Datei anzeigen

@ -2,7 +2,7 @@ import SingleSelectComponent from "select-kit/components/single-select";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
export default SingleSelectComponent.extend({ export default SingleSelectComponent.extend({
classNames: ["combo-box", 'wizard-pro-selector'], classNames: ["combo-box", "wizard-pro-selector"],
selectKitOptions: { selectKitOptions: {
autoFilterable: false, autoFilterable: false,
@ -10,10 +10,10 @@ export default SingleSelectComponent.extend({
showFullTitle: true, showFullTitle: true,
headerComponent: "wizard-pro-selector/wizard-pro-selector-header", headerComponent: "wizard-pro-selector/wizard-pro-selector-header",
caretUpIcon: "caret-up", caretUpIcon: "caret-up",
caretDownIcon: "caret-down" caretDownIcon: "caret-down",
}, },
modifyComponentForRow() { modifyComponentForRow() {
return "wizard-pro-selector/wizard-pro-selector-row"; return "wizard-pro-selector/wizard-pro-selector-row";
} },
}); });

Datei anzeigen

@ -4,44 +4,49 @@ import { notEmpty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({ export default Component.extend({
classNameBindings: [':custom-wizard-pro-subscription', 'subscription.active:active:inactive'], classNameBindings: [
subscribed: notEmpty('subscription'), ":custom-wizard-pro-subscription",
"subscription.active:active:inactive",
],
subscribed: notEmpty("subscription"),
@discourseComputed('subscription.type') @discourseComputed("subscription.type")
title(type) { title(type) {
return type ? return type
I18n.t(`admin.wizard.pro.subscription.title.${type}`) : ? I18n.t(`admin.wizard.pro.subscription.title.${type}`)
I18n.t("admin.wizard.pro.not_subscribed"); : I18n.t("admin.wizard.pro.not_subscribed");
}, },
@discourseComputed('subscription.active') @discourseComputed("subscription.active")
stateClass(active) { stateClass(active) {
return active ? 'active' : 'inactive'; return active ? "active" : "inactive";
}, },
@discourseComputed('stateClass') @discourseComputed("stateClass")
stateLabel(stateClass) { stateLabel(stateClass) {
return I18n.t(`admin.wizard.pro.subscription.status.${stateClass}`); return I18n.t(`admin.wizard.pro.subscription.status.${stateClass}`);
}, },
actions: { actions: {
update() { update() {
this.set('updating', true); this.set("updating", true);
CustomWizardPro.update_subscription().then(result => { CustomWizardPro.update_subscription()
.then((result) => {
if (result.success) { if (result.success) {
this.setProperties({ this.setProperties({
updateIcon: 'check', updateIcon: "check",
subscription: result.subscription subscription: result.subscription,
}); });
} else { } else {
this.set('updateIcon', 'times'); this.set("updateIcon", "times");
} }
}).finally(() => {
this.set('updating', false);
setTimeout(() => {
this.set('updateIcon', null);
}, 7000);
}) })
} .finally(() => {
} this.set("updating", false);
setTimeout(() => {
this.set("updateIcon", null);
}, 7000);
});
},
},
}); });

Datei anzeigen

@ -5,52 +5,58 @@ import { alias } from "@ember/object/computed";
export default Controller.extend({ export default Controller.extend({
messageUrl: "https://thepavilion.io/t/3652", messageUrl: "https://thepavilion.io/t/3652",
messageType: 'info', messageType: "info",
messageKey: null, messageKey: null,
showSubscription: alias('model.authentication.active'), showSubscription: alias("model.authentication.active"),
setup() { setup() {
const authentication = this.get('model.authentication'); const authentication = this.get("model.authentication");
const subscription = this.get('model.subscription'); const subscription = this.get("model.subscription");
const subscribed = subscription && subscription.active; const subscribed = subscription && subscription.active;
const authenticated = authentication && authentication.active; const authenticated = authentication && authentication.active;
if (!subscribed) { if (!subscribed) {
this.set('messageKey', authenticated ? 'not_subscribed' : 'authorize'); this.set("messageKey", authenticated ? "not_subscribed" : "authorize");
} else { } else {
this.set('messageKey', !authenticated ? this.set(
'subscription_expiring' : "messageKey",
subscribed ? 'subscription_active' : 'subscription_inactive' !authenticated
? "subscription_expiring"
: subscribed
? "subscription_active"
: "subscription_inactive"
); );
} }
}, },
@discourseComputed('model.server') @discourseComputed("model.server")
messageOpts(server) { messageOpts(server) {
return { server }; return { server };
}, },
actions: { actions: {
unauthorize() { unauthorize() {
this.set('unauthorizing', true); this.set("unauthorizing", true);
CustomWizardPro.unauthorize().then(result => { CustomWizardPro.unauthorize()
.then((result) => {
if (result.success) { if (result.success) {
this.setProperties({ this.setProperties({
messageKey: 'unauthorized', messageKey: "unauthorized",
messageType: 'warn', messageType: "warn",
"model.authentication": null, "model.authentication": null,
"model.subscription": null "model.subscription": null,
}); });
} else { } else {
this.setProperties({ this.setProperties({
messageKey: 'unauthorize_failed', messageKey: "unauthorize_failed",
messageType: 'error' messageType: "error",
}); });
} }
}).finally(() => {
this.set('unauthorizing', false);
}) })
} .finally(() => {
} this.set("unauthorizing", false);
});
},
},
}); });

Datei anzeigen

@ -80,7 +80,7 @@ export default Controller.extend({
if (result.wizard_id) { if (result.wizard_id) {
this.send("afterSave", result.wizard_id); this.send("afterSave", result.wizard_id);
} else if (result.errors) { } else if (result.errors) {
this.set('error', result.errors.join(', ')); this.set("error", result.errors.join(", "));
} }
}) })
.catch((result) => { .catch((result) => {

Datei anzeigen

@ -45,7 +45,7 @@ export default {
this.route("adminWizardsLogs", { this.route("adminWizardsLogs", {
path: "/logs", path: "/logs",
resetNamespace: true resetNamespace: true,
}); });
this.route("adminWizardsManager", { this.route("adminWizardsManager", {

Datei anzeigen

@ -196,11 +196,11 @@ const action = {
], ],
required: ["id", "type"], required: ["id", "type"],
proTypes: [ proTypes: [
'send_message', "send_message",
'add_to_group', "add_to_group",
'create_category', "create_category",
'create_group', "create_group",
'send_to_api' "send_to_api",
], ],
dependent: {}, dependent: {},
objectArrays: {}, objectArrays: {},

Datei anzeigen

@ -28,7 +28,7 @@ CustomWizardPro.reopenClass({
return ajax(`${basePath}/subscription`, { return ajax(`${basePath}/subscription`, {
type: "POST", type: "POST",
}).catch(popupAjaxError); }).catch(popupAjaxError);
} },
}); });
export default CustomWizardPro; export default CustomWizardPro;

Datei anzeigen

@ -221,7 +221,7 @@ CustomWizard.reopenClass({
const wizard = this._super.apply(this); const wizard = this._super.apply(this);
wizard.setProperties(buildProperties(wizardJson)); wizard.setProperties(buildProperties(wizardJson));
return wizard; return wizard;
} },
}); });
export default CustomWizard; export default CustomWizard;

Datei anzeigen

@ -13,7 +13,7 @@ export default DiscourseRoute.extend({
controller.setProperties({ controller.setProperties({
customFields, customFields,
proSubscribed proSubscribed,
}); });
}, },
}); });

Datei anzeigen

@ -7,13 +7,13 @@ export default DiscourseRoute.extend({
}, },
setupController(controller, model) { setupController(controller, model) {
controller.set('model', model); controller.set("model", model);
controller.setup(); controller.setup();
}, },
actions: { actions: {
authorize() { authorize() {
CustomWizardPro.authorize(); CustomWizardPro.authorize();
} },
} },
}); });

Datei anzeigen

@ -39,7 +39,7 @@ export default DiscourseRoute.extend({
currentStep: wizard.steps[0], currentStep: wizard.steps[0],
currentAction: wizard.actions[0], currentAction: wizard.actions[0],
creating: model.create, creating: model.create,
proSubscribed: parentModel.pro_subscribed proSubscribed: parentModel.pro_subscribed,
}; };
controller.setProperties(props); controller.setProperties(props);

Datei anzeigen

@ -741,7 +741,7 @@
.validation-section { .validation-section {
min-width: 250px; min-width: 250px;
margin: .5em 0; margin: 0.5em 0;
} }
} }
@ -761,18 +761,19 @@
.pro-label { .pro-label {
color: var(--tertiary); color: var(--tertiary);
font-size: .75em; font-size: 0.75em;
} }
.admin-wizards-pro { .admin-wizards-pro {
.admin-wizard-controls { .admin-wizard-controls {
h3, label { h3,
label {
margin: 0; margin: 0;
} }
label { label {
padding: .4em .5em; padding: 0.4em 0.5em;
margin-left: .75em; margin-left: 0.75em;
background-color: var(--success); background-color: var(--success);
color: var(--secondary); color: var(--secondary);
} }
@ -792,14 +793,14 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: .5em; margin-bottom: 0.5em;
h3 { h3 {
margin: 0; margin: 0;
} }
.buttons > span { .buttons > span {
margin-right: .5em; margin-right: 0.5em;
} }
} }
@ -810,8 +811,8 @@
background-color: var(--primary-very-low); background-color: var(--primary-very-low);
.subscription-state { .subscription-state {
padding: .25em .5em; padding: 0.25em 0.5em;
margin-right: .75em; margin-right: 0.75em;
&.active { &.active {
background-color: var(--success); background-color: var(--success);
@ -829,7 +830,7 @@
} }
.pro-label { .pro-label {
margin-left: .75em; margin-left: 0.75em;
padding-top: .25em; padding-top: 0.25em;
} }
} }