0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2025-02-02 11:27:01 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-custom-action.js.es6

57 Zeilen
1,8 KiB
Text

2020-04-08 17:59:54 +10:00
import { default as discourseComputed, observes, on } from 'discourse-common/utils/decorators';
2020-04-15 11:23:41 +10:00
import { equal, empty, or } from "@ember/object/computed";
2020-04-10 17:57:49 +10:00
import { generateName, selectKitContent, schema } from '../lib/wizard';
2020-04-05 11:37:09 +10:00
import Component from "@ember/component";
2017-10-13 21:02:34 +08:00
2020-04-05 11:37:09 +10:00
export default Component.extend({
2017-10-06 10:59:02 +08:00
classNames: 'wizard-custom-action',
2020-04-10 17:57:49 +10:00
actionTypes: Object.keys(schema.action.types).map(t => ({ id: t, name: generateName(t) })),
2020-04-01 21:58:30 +11:00
createTopic: equal('action.type', 'create_topic'),
updateProfile: equal('action.type', 'update_profile'),
sendMessage: equal('action.type', 'send_message'),
2020-04-08 12:52:07 +10:00
openComposer: equal('action.type', 'open_composer'),
2020-04-01 21:58:30 +11:00
sendToApi: equal('action.type', 'send_to_api'),
addToGroup: equal('action.type', 'add_to_group'),
routeTo: equal('action.type', 'route_to'),
2020-04-08 12:52:07 +10:00
apiEmpty: empty('action.api'),
2020-04-02 19:21:03 +11:00
groupPropertyTypes: selectKitContent(['id', 'name']),
2020-04-07 23:33:11 +10:00
hasAdvanced: or('hasCustomFields', 'routeTo'),
hasCustomFields: or('basicTopicFields', 'updateProfile'),
2020-04-08 12:52:07 +10:00
basicTopicFields: or('createTopic', 'sendMessage', 'openComposer'),
publicTopicFields: or('createTopic', 'openComposer'),
showSkipRedirect: or('createTopic', 'sendMessage'),
2020-04-02 16:21:57 +11:00
2020-04-08 12:52:07 +10:00
@discourseComputed('wizard.steps')
runAfterContent(steps) {
2020-04-08 17:59:54 +10:00
let content = steps.map(function(step) {
return {
id: step.id,
name: step.title || step.id
};
});
2020-04-08 12:52:07 +10:00
content.unshift({
id: 'wizard_completion',
name: I18n.t('admin.wizard.action.run_after.wizard_completion')
});
2020-04-08 17:59:54 +10:00
2020-04-08 12:52:07 +10:00
return content;
2019-06-03 17:09:24 +10:00
},
2020-04-01 21:58:30 +11:00
@discourseComputed('wizard.apis')
2019-06-03 17:09:24 +10:00
availableApis(apis) {
return apis.map(a => {
return {
id: a.name,
name: a.title
};
});
},
2020-04-01 21:58:30 +11:00
@discourseComputed('wizard.apis', 'action.api')
2019-06-03 17:09:24 +10:00
availableEndpoints(apis, api) {
if (!api) return [];
return apis.find(a => a.name === api).endpoints;
2017-10-13 21:02:34 +08:00
}
2017-09-23 10:34:07 +08:00
});