Apply linting
Dieser Commit ist enthalten in:
Ursprung
f607863510
Commit
92219ace2f
15 geänderte Dateien mit 62 neuen und 46 gelöschten Zeilen
|
@ -1,5 +1,4 @@
|
|||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import { subscriptionSelectKitContent } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription";
|
||||
import { empty, equal, or } from "@ember/object/computed";
|
||||
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
||||
|
|
|
@ -5,7 +5,7 @@ import DiscourseURL from "discourse/lib/url";
|
|||
import I18n from "I18n";
|
||||
|
||||
export default Component.extend(Subscription, {
|
||||
tagName: 'a',
|
||||
tagName: "a",
|
||||
classNameBindings: [":wizard-subscription-badge", "subscriptionType"],
|
||||
attributeBindings: ["title"],
|
||||
|
||||
|
@ -26,5 +26,5 @@ export default Component.extend(Subscription, {
|
|||
|
||||
click() {
|
||||
DiscourseURL.routeTo(this.subscriptionLink);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -22,5 +22,5 @@ export default Component.extend(Subscription, {
|
|||
return `admin.wizard.subscription_container.${
|
||||
subscribed ? "subscribed" : "not_subscribed"
|
||||
}.title`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,17 +3,18 @@ import Subscription from "../mixins/subscription";
|
|||
import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import {
|
||||
subscriptionTypeSufficient,
|
||||
subscriptionTypes
|
||||
subscriptionTypes,
|
||||
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-subscription";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import I18n from "I18n";
|
||||
|
||||
const nameKey = function(feature, attribute, value) {
|
||||
if (feature === 'action') {
|
||||
const nameKey = function (feature, attribute, value) {
|
||||
if (feature === "action") {
|
||||
return `admin.wizard.action.${value}.label`;
|
||||
} else {
|
||||
return `admin.wizard.${feature}.${attribute}.${value}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default SingleSelectComponent.extend(Subscription, {
|
||||
classNames: ["combo-box", "wizard-subscription-selector"],
|
||||
|
@ -30,10 +31,12 @@ export default SingleSelectComponent.extend(Subscription, {
|
|||
|
||||
requiredSubscriptionType(feature, attribute, value) {
|
||||
let attributes = this.subscriptionAttributes[feature];
|
||||
if (!attributes || !attributes[attribute]) return null;
|
||||
if (!attributes || !attributes[attribute]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let requiredType = null;
|
||||
Object.keys(attributes[attribute]).some(subscriptionType => {
|
||||
Object.keys(attributes[attribute]).some((subscriptionType) => {
|
||||
let values = attributes[attribute][subscriptionType];
|
||||
if (values[0] === "*" || values.includes(value)) {
|
||||
if (subscriptionTypes.includes(subscriptionType)) {
|
||||
|
@ -47,15 +50,22 @@ export default SingleSelectComponent.extend(Subscription, {
|
|||
return requiredType;
|
||||
},
|
||||
|
||||
@discourseComputed('feature', 'attribute')
|
||||
@discourseComputed("feature", "attribute")
|
||||
content(feature, attribute) {
|
||||
return wizardSchema[feature][attribute].map((value) => {
|
||||
let requiredSubscriptionType = this.requiredSubscriptionType(feature, attribute, value);
|
||||
let requiredSubscriptionType = this.requiredSubscriptionType(
|
||||
feature,
|
||||
attribute,
|
||||
value
|
||||
);
|
||||
return {
|
||||
id: value,
|
||||
name: I18n.t(nameKey(feature, attribute, value)),
|
||||
subscriptionType: requiredSubscriptionType,
|
||||
disabled: !subscriptionTypeSufficient(this.subscriptionType, requiredSubscriptionType)
|
||||
disabled: !subscriptionTypeSufficient(
|
||||
this.subscriptionType,
|
||||
requiredSubscriptionType
|
||||
),
|
||||
};
|
||||
});
|
||||
},
|
||||
|
|
|
@ -14,7 +14,6 @@ import I18n from "I18n";
|
|||
export default Controller.extend({
|
||||
hasName: notEmpty("wizard.name"),
|
||||
|
||||
|
||||
@observes("currentStep")
|
||||
resetCurrentObjects() {
|
||||
const currentStep = this.currentStep;
|
||||
|
|
|
@ -2,6 +2,6 @@ import Controller from "@ember/controller";
|
|||
import { equal } from "@ember/object/computed";
|
||||
|
||||
export default Controller.extend({
|
||||
businessSubscription: equal('subscriptionType', 'business'),
|
||||
standardSubscription: equal('subscriptionType', 'standard')
|
||||
businessSubscription: equal("subscriptionType", "business"),
|
||||
standardSubscription: equal("subscriptionType", "standard"),
|
||||
});
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import DiscourseURL from "discourse/lib/url";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { isPresent } from "@ember/utils";
|
||||
import { A } from "@ember/array";
|
||||
import getUrl from "discourse-common/lib/get-url";
|
||||
|
||||
export default {
|
||||
|
|
|
@ -211,7 +211,7 @@ const wizardSchema = {
|
|||
step,
|
||||
field,
|
||||
custom_field,
|
||||
action
|
||||
action,
|
||||
};
|
||||
|
||||
export function buildFieldTypes(types) {
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
const subscriptionTypes = [
|
||||
'standard',
|
||||
'business'
|
||||
]
|
||||
const subscriptionTypes = ["standard", "business"];
|
||||
|
||||
function subscriptionTypeSufficient(subscriptionType, requiredType) {
|
||||
if (requiredType && !subscriptionType) return false;
|
||||
if (requiredType === 'none' || requiredType === null) return true;
|
||||
if (requiredType === 'standard' && subscriptionTypes.includes(subscriptionType)) return true;
|
||||
if (requiredType === 'business' && subscriptionType === 'business') return true;
|
||||
if (requiredType && !subscriptionType) {
|
||||
return false;
|
||||
}
|
||||
if (requiredType === "none" || requiredType === null) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
requiredType === "standard" &&
|
||||
subscriptionTypes.includes(subscriptionType)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (requiredType === "business" && subscriptionType === "business") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export {
|
||||
subscriptionTypeSufficient,
|
||||
subscriptionTypes
|
||||
}
|
||||
export { subscriptionTypeSufficient, subscriptionTypes };
|
||||
|
|
|
@ -9,18 +9,22 @@ export default Mixin.create({
|
|||
|
||||
@discourseComputed
|
||||
adminWizards() {
|
||||
return getOwner(this).lookup('controller:admin-wizards');
|
||||
return getOwner(this).lookup("controller:admin-wizards");
|
||||
},
|
||||
|
||||
subscribed: readOnly('adminWizards.subscribed'),
|
||||
subscriptionType: readOnly('adminWizards.subscriptionType'),
|
||||
businessSubscription: readOnly('adminWizards.businessSubscription'),
|
||||
standardSubscription: readOnly('adminWizards.standardSubscription'),
|
||||
subscriptionAttributes: readOnly('adminWizards.subscriptionAttributes'),
|
||||
subscriptionClientInstalled: readOnly('adminWizards.subscriptionClientInstalled'),
|
||||
subscribed: readOnly("adminWizards.subscribed"),
|
||||
subscriptionType: readOnly("adminWizards.subscriptionType"),
|
||||
businessSubscription: readOnly("adminWizards.businessSubscription"),
|
||||
standardSubscription: readOnly("adminWizards.standardSubscription"),
|
||||
subscriptionAttributes: readOnly("adminWizards.subscriptionAttributes"),
|
||||
subscriptionClientInstalled: readOnly(
|
||||
"adminWizards.subscriptionClientInstalled"
|
||||
),
|
||||
|
||||
@discourseComputed("subscriptionClientInstalled")
|
||||
subscriptionLink(subscriptionClientInstalled) {
|
||||
return subscriptionClientInstalled ? this.subscriptionClientUrl : this.subscriptionLandingUrl;
|
||||
}
|
||||
return subscriptionClientInstalled
|
||||
? this.subscriptionClientUrl
|
||||
: this.subscriptionLandingUrl;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ export default DiscourseRoute.extend({
|
|||
const customFields = A(model.custom_fields || []);
|
||||
|
||||
controller.setProperties({
|
||||
customFields
|
||||
customFields,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ export default DiscourseRoute.extend({
|
|||
wizard,
|
||||
currentStep: wizard.steps[0],
|
||||
currentAction: wizard.actions[0],
|
||||
creating: model.create
|
||||
creating: model.create,
|
||||
};
|
||||
|
||||
controller.setProperties(props);
|
||||
|
|
|
@ -11,7 +11,7 @@ export default DiscourseRoute.extend({
|
|||
subscribed: model.subscribed,
|
||||
subscriptionType: model.subscription_type,
|
||||
subscriptionAttributes: model.subscription_attributes,
|
||||
subscriptionClientInstalled: model.subscription_client_installed
|
||||
subscriptionClientInstalled: model.subscription_client_installed,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -19,5 +19,5 @@ export default DiscourseRoute.extend({
|
|||
if (transition.targetName === "adminWizards.index") {
|
||||
this.transitionTo("adminWizardsWizard");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -847,7 +847,7 @@ $error: #ef1700;
|
|||
.subscription-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: .25em;
|
||||
margin-bottom: 0.25em;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
|
@ -871,7 +871,7 @@ $error: #ef1700;
|
|||
box-sizing: border-box;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
padding: .5em .65em;
|
||||
padding: 0.5em 0.65em;
|
||||
background-color: rgba($primary-medium, 0.05);
|
||||
border: 1.5px solid rgba($primary-medium, 0.5);
|
||||
color: $primary-medium;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Subscription
|
||||
STANDARD_PRODUCT_ID = 'prod_LNAGVAaIqDsHmB'
|
||||
BUSINESS_PRODUCT_ID = 'prod_LNABQ50maBQ1pY'
|
||||
|
|
Laden …
In neuem Issue referenzieren