Distinguish actions which require additional subscription
Dieser Commit ist enthalten in:
Ursprung
14e7e9c0db
Commit
67cfeb6ed9
5 geänderte Dateien mit 36 neuen und 21 gelöschten Zeilen
|
@ -1,5 +1,7 @@
|
|||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
import wizardSchema from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import wizardSchema, {
|
||||
actionsAvailableWithAdditionalSubscription,
|
||||
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import { empty, equal, or } from "@ember/object/computed";
|
||||
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
||||
import { computed } from "@ember/object";
|
||||
|
@ -94,17 +96,16 @@ export default Component.extend(UndoChanges, {
|
|||
return apis.find((a) => a.name === api).endpoints;
|
||||
},
|
||||
|
||||
@discourseComputed("subscribed")
|
||||
actionTypes(subscribed) {
|
||||
@discourseComputed("subscribed", "subscription")
|
||||
actionTypes(subscribed, subscription) {
|
||||
let unsubscribedActions =
|
||||
actionsAvailableWithAdditionalSubscription(subscription);
|
||||
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
||||
let subscription = wizardSchema.action.subscriptionTypes.includes(type);
|
||||
if (subscribed || !subscription) {
|
||||
result.push({
|
||||
id: type,
|
||||
name: I18n.t(`admin.wizard.action.${type}.label`),
|
||||
subscription,
|
||||
});
|
||||
}
|
||||
result.push({
|
||||
id: type,
|
||||
name: I18n.t(`admin.wizard.action.${type}.label`),
|
||||
subscribed: unsubscribedActions.includes(type),
|
||||
});
|
||||
return result;
|
||||
}, []);
|
||||
},
|
||||
|
|
|
@ -200,14 +200,10 @@ const action = {
|
|||
"create_group",
|
||||
"send_to_api",
|
||||
],
|
||||
required: ["id", "type"],
|
||||
proTypes: [
|
||||
"send_message",
|
||||
"add_to_group",
|
||||
"create_category",
|
||||
"create_group",
|
||||
"send_to_api",
|
||||
],
|
||||
actionTypesWithSubscription: {
|
||||
advanced: ["send_message", "add_to_group", "watch_categories"],
|
||||
business: ["create_category", "create_group", "send_to_api"],
|
||||
},
|
||||
dependent: {},
|
||||
objectArrays: {},
|
||||
};
|
||||
|
@ -219,6 +215,21 @@ const wizardSchema = {
|
|||
action,
|
||||
};
|
||||
|
||||
export function actionsAvailableWithAdditionalSubscription(
|
||||
currentSubscription
|
||||
) {
|
||||
switch (currentSubscription) {
|
||||
case "business":
|
||||
return [];
|
||||
case "advanced":
|
||||
return action.actionTypesWithSubscription["business"];
|
||||
case "community":
|
||||
return action.actionTypesWithSubscription["advanced"].concat(
|
||||
action.actionTypesWithSubscription["business"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function buildFieldTypes(types) {
|
||||
wizardSchema.field.types = types;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ export default DiscourseRoute.extend({
|
|||
currentAction: wizard.actions[0],
|
||||
creating: model.create,
|
||||
subscribed: parentModel.subscribed,
|
||||
subscription: parentModel.subscription,
|
||||
};
|
||||
|
||||
controller.setProperties(props);
|
||||
|
|
|
@ -178,7 +178,8 @@
|
|||
apis=apis
|
||||
removeAction="removeAction"
|
||||
wizardFields=wizardFields
|
||||
subscribed=subscribed}}
|
||||
subscribed=subscribed
|
||||
subscription=subscription}}
|
||||
{{/each}}
|
||||
|
||||
<div class="admin-wizard-buttons">
|
||||
|
|
|
@ -11,7 +11,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
|||
field_types: CustomWizard::Field.types,
|
||||
realtime_validations: CustomWizard::RealtimeValidation.types,
|
||||
custom_fields: custom_field_list,
|
||||
subscribed: CustomWizard::Subscription.subscribed?
|
||||
subscribed: CustomWizard::Subscription.subscribed?,
|
||||
subscription: CustomWizard::Subscription.type
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren