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 { 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 { empty, equal, or } from "@ember/object/computed";
|
||||||
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
|
@ -94,17 +96,16 @@ export default Component.extend(UndoChanges, {
|
||||||
return apis.find((a) => a.name === api).endpoints;
|
return apis.find((a) => a.name === api).endpoints;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
@discourseComputed("subscribed", "subscription")
|
||||||
actionTypes(subscribed) {
|
actionTypes(subscribed, subscription) {
|
||||||
|
let unsubscribedActions =
|
||||||
|
actionsAvailableWithAdditionalSubscription(subscription);
|
||||||
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
||||||
let subscription = wizardSchema.action.subscriptionTypes.includes(type);
|
|
||||||
if (subscribed || !subscription) {
|
|
||||||
result.push({
|
result.push({
|
||||||
id: type,
|
id: type,
|
||||||
name: I18n.t(`admin.wizard.action.${type}.label`),
|
name: I18n.t(`admin.wizard.action.${type}.label`),
|
||||||
subscription,
|
subscribed: unsubscribedActions.includes(type),
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
},
|
},
|
||||||
|
|
|
@ -200,14 +200,10 @@ const action = {
|
||||||
"create_group",
|
"create_group",
|
||||||
"send_to_api",
|
"send_to_api",
|
||||||
],
|
],
|
||||||
required: ["id", "type"],
|
actionTypesWithSubscription: {
|
||||||
proTypes: [
|
advanced: ["send_message", "add_to_group", "watch_categories"],
|
||||||
"send_message",
|
business: ["create_category", "create_group", "send_to_api"],
|
||||||
"add_to_group",
|
},
|
||||||
"create_category",
|
|
||||||
"create_group",
|
|
||||||
"send_to_api",
|
|
||||||
],
|
|
||||||
dependent: {},
|
dependent: {},
|
||||||
objectArrays: {},
|
objectArrays: {},
|
||||||
};
|
};
|
||||||
|
@ -219,6 +215,21 @@ const wizardSchema = {
|
||||||
action,
|
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) {
|
export function buildFieldTypes(types) {
|
||||||
wizardSchema.field.types = types;
|
wizardSchema.field.types = types;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ export default DiscourseRoute.extend({
|
||||||
currentAction: wizard.actions[0],
|
currentAction: wizard.actions[0],
|
||||||
creating: model.create,
|
creating: model.create,
|
||||||
subscribed: parentModel.subscribed,
|
subscribed: parentModel.subscribed,
|
||||||
|
subscription: parentModel.subscription,
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.setProperties(props);
|
controller.setProperties(props);
|
||||||
|
|
|
@ -178,7 +178,8 @@
|
||||||
apis=apis
|
apis=apis
|
||||||
removeAction="removeAction"
|
removeAction="removeAction"
|
||||||
wizardFields=wizardFields
|
wizardFields=wizardFields
|
||||||
subscribed=subscribed}}
|
subscribed=subscribed
|
||||||
|
subscription=subscription}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
<div class="admin-wizard-buttons">
|
<div class="admin-wizard-buttons">
|
||||||
|
|
|
@ -11,7 +11,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||||
field_types: CustomWizard::Field.types,
|
field_types: CustomWizard::Field.types,
|
||||||
realtime_validations: CustomWizard::RealtimeValidation.types,
|
realtime_validations: CustomWizard::RealtimeValidation.types,
|
||||||
custom_fields: custom_field_list,
|
custom_fields: custom_field_list,
|
||||||
subscribed: CustomWizard::Subscription.subscribed?
|
subscribed: CustomWizard::Subscription.subscribed?,
|
||||||
|
subscription: CustomWizard::Subscription.type
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren