0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 01:10:28 +01:00

Update action dropdown behaviour to show sub level

Dieser Commit ist enthalten in:
merefield 2021-10-22 19:56:00 +01:00
Ursprung 41e0f13b25
Commit fbab8d89a5
3 geänderte Dateien mit 23 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,7 @@
import { default as discourseComputed } from "discourse-common/utils/decorators";
import wizardSchema, {
actionsAvailableWithAdditionalSubscription,
actionsAvailableWithCurrentSubscription,
actionsRequiringAdditionalSubscription,
actionSubscriptionLevel,
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
import { empty, equal, or } from "@ember/object/computed";
import { notificationLevels, selectKitContent } from "../lib/wizard";
@ -99,20 +99,15 @@ export default Component.extend(UndoChanges, {
@discourseComputed("subscribed", "subscription")
actionTypes(subscribed, subscription) {
let unsubscribedActions = actionsAvailableWithAdditionalSubscription(
subscription
);
let subscribedActions = actionsAvailableWithCurrentSubscription(
let unsubscribedActions = actionsRequiringAdditionalSubscription(
subscription
);
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
let subscriptionLabel =
subscribedActions.includes(type) || unsubscribedActions.includes(type);
let disabled = unsubscribedActions.includes(type);
result.push({
id: type,
name: I18n.t(`admin.wizard.action.${type}.label`),
subscription: subscriptionLabel,
subscription: actionSubscriptionLevel(type),
disabled: disabled,
});
return result;

Datei anzeigen

@ -201,8 +201,8 @@ const action = {
"send_to_api",
],
actionTypesWithSubscription: {
basic: ["send_message", "add_to_group", "watch_categories"],
advanced: ["create_category", "create_group", "send_to_api"],
standard: ["send_message", "add_to_group", "watch_categories"],
business: ["create_category", "create_group", "send_to_api"],
},
dependent: {},
objectArrays: {},
@ -215,31 +215,30 @@ const wizardSchema = {
action,
};
export function actionsAvailableWithAdditionalSubscription(
export function actionsRequiringAdditionalSubscription(
currentSubscription
) {
switch (currentSubscription) {
case "advanced":
case "business":
return [];
case "basic":
return action.actionTypesWithSubscription["advanced"];
case "none":
return action.actionTypesWithSubscription["basic"].concat(
action.actionTypesWithSubscription["advanced"]
case "standard":
return action.actionTypesWithSubscription["business"];
default:
return action.actionTypesWithSubscription["standard"].concat(
action.actionTypesWithSubscription["business"]
);
}
}
export function actionsAvailableWithCurrentSubscription(currentSubscription) {
switch (currentSubscription) {
case "advanced":
return action.actionTypesWithSubscription["advanced"].concat(
action.actionTypesWithSubscription["basic"]
);
case "basic":
return action.actionTypesWithSubscription["basic"];
case "none":
return [];
export function actionSubscriptionLevel(type) {
if (action.actionTypesWithSubscription["business"].includes(type)) {
return "business"
} else {
if (action.actionTypesWithSubscription["standard"].includes(type)) {
return "standard"
} else {
return ""
}
}
}

Datei anzeigen

@ -11,11 +11,7 @@
<span class="name">{{html-safe label}}</span>
{{#if item.subscription}}
<span class="subscription-label">
{{#if item.disabled}}
{{i18n "admin.wizard.subscription.additional_label"}}
{{else}}
{{i18n "admin.wizard.subscription.label"}}
{{/if}}
{{item.subscription}}
</span>
{{/if}}
</div>