diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 39c84fa2..915e83aa 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -1,6 +1,7 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"; import wizardSchema, { actionsAvailableWithAdditionalSubscription, + actionsAvailableWithCurrentSubscription } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema"; import { empty, equal, or } from "@ember/object/computed"; import { notificationLevels, selectKitContent } from "../lib/wizard"; @@ -100,11 +101,16 @@ export default Component.extend(UndoChanges, { actionTypes(subscribed, subscription) { let unsubscribedActions = actionsAvailableWithAdditionalSubscription(subscription); + let subscribedActions = actionsAvailableWithCurrentSubscription(subscription); return Object.keys(wizardSchema.action.types).reduce((result, type) => { + let subscriptionLabel = (subscribedActions.includes(type) || unsubscribedActions.includes(type)); + let disabled = unsubscribedActions.includes(type); + console.log(subscriptionLabel, disabled); result.push({ id: type, name: I18n.t(`admin.wizard.action.${type}.label`), - subscribed: unsubscribedActions.includes(type), + subscription: subscriptionLabel, + disabled: disabled, }); return result; }, []); diff --git a/assets/javascripts/discourse/components/wizard-subscription-selector/wizard-subscription-selector-row.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-selector/wizard-subscription-selector-row.js.es6 index 23034ac1..11dd314a 100644 --- a/assets/javascripts/discourse/components/wizard-subscription-selector/wizard-subscription-selector-row.js.es6 +++ b/assets/javascripts/discourse/components/wizard-subscription-selector/wizard-subscription-selector-row.js.es6 @@ -1,3 +1,20 @@ import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row"; +import { default as discourseComputed } from "discourse-common/utils/decorators"; -export default SelectKitRowComponent.extend(); +export default SelectKitRowComponent.extend({ + classNameBindings: ["isDisabled:disabled"], + + @discourseComputed("item") + isDisabled() { + return this.item.disabled; + }, + + click(event) { + event.preventDefault(); + event.stopPropagation(); + if (!this.item.disabled) { + this.selectKit.select(this.rowValue, this.item); + } + return false; + } +}); diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index 34df21d2..3559c98d 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -201,8 +201,8 @@ const action = { "send_to_api", ], actionTypesWithSubscription: { - advanced: ["send_message", "add_to_group", "watch_categories"], - business: ["create_category", "create_group", "send_to_api"], + basic: ["send_message", "add_to_group", "watch_categories"], + advanced: ["create_category", "create_group", "send_to_api"], }, dependent: {}, objectArrays: {}, @@ -219,17 +219,31 @@ export function actionsAvailableWithAdditionalSubscription( currentSubscription ) { switch (currentSubscription) { - case "complete": - return []; case "advanced": - return action.actionTypesWithSubscription["business"]; - case "core": - return action.actionTypesWithSubscription["advanced"].concat( - action.actionTypesWithSubscription["business"] + return []; + case "basic": + return action.actionTypesWithSubscription["advanced"]; + case "none", "": + return action.actionTypesWithSubscription["basic"].concat( + action.actionTypesWithSubscription["advanced"] ); } } +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 buildFieldTypes(types) { wizardSchema.field.types = types; } diff --git a/assets/javascripts/discourse/templates/components/wizard-subscription-selector/wizard-subscription-selector-row.hbs b/assets/javascripts/discourse/templates/components/wizard-subscription-selector/wizard-subscription-selector-row.hbs index e2650408..92cb2750 100644 --- a/assets/javascripts/discourse/templates/components/wizard-subscription-selector/wizard-subscription-selector-row.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-subscription-selector/wizard-subscription-selector-row.hbs @@ -10,6 +10,12 @@