diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue
index b2e8e13c29b..5f8140f2222 100644
--- a/apps/workflowengine/src/components/Check.vue
+++ b/apps/workflowengine/src/components/Check.vue
@@ -3,12 +3,12 @@
-
-
-
+
+
@@ -16,9 +16,9 @@
diff --git a/apps/workflowengine/src/legacy/filemimetypeplugin.js b/apps/workflowengine/src/legacy/filemimetypeplugin.js
index 2b29c4fcbb8..e58bdec26d3 100644
--- a/apps/workflowengine/src/legacy/filemimetypeplugin.js
+++ b/apps/workflowengine/src/legacy/filemimetypeplugin.js
@@ -17,8 +17,6 @@
* along with this program. If not, see .
*
*/
-import FileMimeType from './../components/Values/FileMimeType'
-
(function() {
OCA.WorkflowEngine = OCA.WorkflowEngine || {}
@@ -66,12 +64,6 @@ import FileMimeType from './../components/Values/FileMimeType'
var regexRegex = /^\/(.*)\/([gui]{0,3})$/
var result = regexRegex.exec(string)
return result !== null
- },
-
- component: function() {
- return FileMimeType
}
}
})()
-
-OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileMimeTypePlugin)
diff --git a/apps/workflowengine/src/services/Operation.js b/apps/workflowengine/src/services/Operation.js
index 99dca212f4c..ed996593cb4 100644
--- a/apps/workflowengine/src/services/Operation.js
+++ b/apps/workflowengine/src/services/Operation.js
@@ -13,16 +13,6 @@ const ALL_CHECKS = [
'OCA\\WorkflowEngine\\Check\\UserGroupMembership'
]
-const Checks = Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => {
- if (plugin.component) {
- return { ...plugin.getCheck(), component: plugin.component }
- }
- return plugin.getCheck()
-}).reduce((obj, item) => {
- obj[item.class] = item
- return obj
-}, {})
-
const Operators = OCP.InitialState.loadState('workflowengine', 'operators')
/**
@@ -71,7 +61,6 @@ Operators['OCA\\FilesAutomatedTagging\\Operation'] = {
}
export {
- Checks,
Operators,
ALL_CHECKS
}
diff --git a/apps/workflowengine/src/store.js b/apps/workflowengine/src/store.js
index ec9d736dd08..34cee256757 100644
--- a/apps/workflowengine/src/store.js
+++ b/apps/workflowengine/src/store.js
@@ -35,6 +35,12 @@ const store = new Vuex.Store({
scope: OCP.InitialState.loadState('workflowengine', 'scope'),
// TODO: move to backend data
operations: Operators,
+
+ plugins: Vue.observable({
+ checks: {},
+ operators: {}
+ }),
+
entities: OCP.InitialState.loadState('workflowengine', 'entities').map(entity => {
return {
...entity,
@@ -63,6 +69,12 @@ const store = new Vuex.Store({
removeRule(state, rule) {
const index = state.rules.findIndex((item) => rule.id === item.id)
state.rules.splice(index, 1)
+ },
+ addPluginCheck(state, plugin) {
+ Vue.set(state.plugins.checks, plugin.class, plugin)
+ },
+ addPluginOperator(state, plugin) {
+ Vue.set(state.plugins.operators, plugin.class, plugin)
}
},
actions: {
diff --git a/apps/workflowengine/src/workflowengine.js b/apps/workflowengine/src/workflowengine.js
index 866f049b0bf..bdf30397883 100644
--- a/apps/workflowengine/src/workflowengine.js
+++ b/apps/workflowengine/src/workflowengine.js
@@ -14,11 +14,41 @@ import Vuex from 'vuex'
import store from './store'
import Settings from './components/Workflow'
+import FileMimeType from './components/Values/FileMimeType';
+
+window.OCA.WorkflowEngine = Object.assign({}, OCA.WorkflowEngine, {
+ registerCheck: function (Plugin) {
+ store.commit('addPluginCheck', Plugin)
+ },
+ registerOperator: function (Plugin) {
+ store.commit('addPluginOperator', Plugin)
+ }
+})
+
+// Load legacy plugins for now and register them in the new plugin system
+Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => {
+ if (plugin.component) {
+ return { ...plugin.getCheck(), component: plugin.component() }
+ }
+ return plugin.getCheck()
+}).forEach((legacyCheckPlugin) => window.OCA.WorkflowEngine.registerCheck(legacyCheckPlugin))
+
+// new way of registering checks
+window.OCA.WorkflowEngine.registerCheck({
+ class: 'OCA\\WorkflowEngine\\Check\\FileMimeType',
+ name: t('workflowengine', 'File MIME type'),
+ operators: [
+ { operator: 'is', name: t('workflowengine', 'is') },
+ { operator: '!is', name: t('workflowengine', 'is not') },
+ { operator: 'matches', name: t('workflowengine', 'matches') },
+ { operator: '!matches', name: t('workflowengine', 'does not match') }
+ ],
+ component: FileMimeType
+})
-window.OCA.WorkflowEngine = OCA.WorkflowEngine
Vue.use(Vuex)
-
Vue.prototype.t = t
+
const View = Vue.extend(Settings)
new View({
store