Update action dropdown behaviour to show sub level
Dieser Commit ist enthalten in:
Ursprung
41e0f13b25
Commit
fbab8d89a5
3 geänderte Dateien mit 23 neuen und 33 gelöschten Zeilen
|
@ -1,7 +1,7 @@
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
import wizardSchema, {
|
import wizardSchema, {
|
||||||
actionsAvailableWithAdditionalSubscription,
|
actionsRequiringAdditionalSubscription,
|
||||||
actionsAvailableWithCurrentSubscription,
|
actionSubscriptionLevel,
|
||||||
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
} 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";
|
||||||
|
@ -99,20 +99,15 @@ export default Component.extend(UndoChanges, {
|
||||||
|
|
||||||
@discourseComputed("subscribed", "subscription")
|
@discourseComputed("subscribed", "subscription")
|
||||||
actionTypes(subscribed, subscription) {
|
actionTypes(subscribed, subscription) {
|
||||||
let unsubscribedActions = actionsAvailableWithAdditionalSubscription(
|
let unsubscribedActions = actionsRequiringAdditionalSubscription(
|
||||||
subscription
|
|
||||||
);
|
|
||||||
let subscribedActions = actionsAvailableWithCurrentSubscription(
|
|
||||||
subscription
|
subscription
|
||||||
);
|
);
|
||||||
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
return Object.keys(wizardSchema.action.types).reduce((result, type) => {
|
||||||
let subscriptionLabel =
|
|
||||||
subscribedActions.includes(type) || unsubscribedActions.includes(type);
|
|
||||||
let disabled = unsubscribedActions.includes(type);
|
let disabled = unsubscribedActions.includes(type);
|
||||||
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: subscriptionLabel,
|
subscription: actionSubscriptionLevel(type),
|
||||||
disabled: disabled,
|
disabled: disabled,
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -201,8 +201,8 @@ const action = {
|
||||||
"send_to_api",
|
"send_to_api",
|
||||||
],
|
],
|
||||||
actionTypesWithSubscription: {
|
actionTypesWithSubscription: {
|
||||||
basic: ["send_message", "add_to_group", "watch_categories"],
|
standard: ["send_message", "add_to_group", "watch_categories"],
|
||||||
advanced: ["create_category", "create_group", "send_to_api"],
|
business: ["create_category", "create_group", "send_to_api"],
|
||||||
},
|
},
|
||||||
dependent: {},
|
dependent: {},
|
||||||
objectArrays: {},
|
objectArrays: {},
|
||||||
|
@ -215,31 +215,30 @@ const wizardSchema = {
|
||||||
action,
|
action,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function actionsAvailableWithAdditionalSubscription(
|
export function actionsRequiringAdditionalSubscription(
|
||||||
currentSubscription
|
currentSubscription
|
||||||
) {
|
) {
|
||||||
switch (currentSubscription) {
|
switch (currentSubscription) {
|
||||||
case "advanced":
|
case "business":
|
||||||
return [];
|
return [];
|
||||||
case "basic":
|
case "standard":
|
||||||
return action.actionTypesWithSubscription["advanced"];
|
return action.actionTypesWithSubscription["business"];
|
||||||
case "none":
|
default:
|
||||||
return action.actionTypesWithSubscription["basic"].concat(
|
return action.actionTypesWithSubscription["standard"].concat(
|
||||||
action.actionTypesWithSubscription["advanced"]
|
action.actionTypesWithSubscription["business"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function actionsAvailableWithCurrentSubscription(currentSubscription) {
|
export function actionSubscriptionLevel(type) {
|
||||||
switch (currentSubscription) {
|
if (action.actionTypesWithSubscription["business"].includes(type)) {
|
||||||
case "advanced":
|
return "business"
|
||||||
return action.actionTypesWithSubscription["advanced"].concat(
|
} else {
|
||||||
action.actionTypesWithSubscription["basic"]
|
if (action.actionTypesWithSubscription["standard"].includes(type)) {
|
||||||
);
|
return "standard"
|
||||||
case "basic":
|
} else {
|
||||||
return action.actionTypesWithSubscription["basic"];
|
return ""
|
||||||
case "none":
|
}
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,7 @@
|
||||||
<span class="name">{{html-safe label}}</span>
|
<span class="name">{{html-safe label}}</span>
|
||||||
{{#if item.subscription}}
|
{{#if item.subscription}}
|
||||||
<span class="subscription-label">
|
<span class="subscription-label">
|
||||||
{{#if item.disabled}}
|
{{item.subscription}}
|
||||||
{{i18n "admin.wizard.subscription.additional_label"}}
|
|
||||||
{{else}}
|
|
||||||
{{i18n "admin.wizard.subscription.label"}}
|
|
||||||
{{/if}}
|
|
||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Laden …
In neuem Issue referenzieren