Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-09-06 14:47:11 +0300
committerJulius Härtl <jus@bitgrid.net>2019-09-10 10:01:25 +0300
commitd6b3af9d776c224015f9e9d8a4d858acae6f8560 (patch)
tree967ff1a894f2d1739a30945c1ee1b57acfd3ce8d /apps/workflowengine/src
parentc665d5475affc844e583a8a546466ae27c045bb5 (diff)
Load checks from the backend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src')
-rw-r--r--apps/workflowengine/src/components/Check.vue6
-rw-r--r--apps/workflowengine/src/components/Rule.vue2
-rw-r--r--apps/workflowengine/src/services/Operation.js38
-rw-r--r--apps/workflowengine/src/store.js26
-rw-r--r--apps/workflowengine/src/workflowengine.js25
5 files changed, 44 insertions, 53 deletions
diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue
index bd3c471fc3c..e521dffbb29 100644
--- a/apps/workflowengine/src/components/Check.vue
+++ b/apps/workflowengine/src/components/Check.vue
@@ -50,9 +50,9 @@ export default {
}
},
computed: {
- ...mapState({
- Checks: (state) => state.plugins.checks
- }),
+ Checks() {
+ return this.$store.getters.getChecksForEntity(this.rule.entity)
+ },
operators() {
if (!this.currentOption) { return [] }
return this.Checks[this.currentOption.class].operators
diff --git a/apps/workflowengine/src/components/Rule.vue b/apps/workflowengine/src/components/Rule.vue
index fab79109516..36616e9910a 100644
--- a/apps/workflowengine/src/components/Rule.vue
+++ b/apps/workflowengine/src/components/Rule.vue
@@ -1,5 +1,5 @@
<template>
- <div class="section rule" :style="{ borderLeftColor: operation.color }">
+ <div class="section rule" :style="{ borderLeftColor: operation.color || '' }">
<!-- TODO: icon-confirm -->
<div class="trigger">
<p>
diff --git a/apps/workflowengine/src/services/Operation.js b/apps/workflowengine/src/services/Operation.js
deleted file mode 100644
index 58c20d6db14..00000000000
--- a/apps/workflowengine/src/services/Operation.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const ALL_CHECKS = [
- 'OCA\\WorkflowEngine\\Check\\FileMimeType',
- 'OCA\\WorkflowEngine\\Check\\FileName',
- 'OCA\\WorkflowEngine\\Check\\FileSize',
- 'OCA\\WorkflowEngine\\Check\\FileSystemTags',
- 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress',
- 'OCA\\WorkflowEngine\\Check\\RequestTime',
- 'OCA\\WorkflowEngine\\Check\\RequestURL',
- 'OCA\\WorkflowEngine\\Check\\RequestUserAgent',
- 'OCA\\WorkflowEngine\\Check\\UserGroupMembership'
-]
-
-const Operators = {}
-/**
- * Extend operators for testing
- */
-
-Operators['OCA\\TestExample\\Operation1'] = {
- id: 'OCA\\TestExample\\Operation1',
- name: 'Rename file',
- description: '🚧 For UI mocking only',
- iconClass: 'icon-address-white',
- color: 'var(--color-success)',
- operation: 'deny'
-}
-Operators['OCA\\TestExample\\Operation2'] = {
- id: 'OCA\\TestExample\\Operation2',
- name: 'Notify me',
- description: '🚧 For UI mocking only',
- iconClass: 'icon-comment-white',
- color: 'var(--color-warning)',
- operation: 'deny'
-}
-
-export {
- Operators,
- ALL_CHECKS
-}
diff --git a/apps/workflowengine/src/store.js b/apps/workflowengine/src/store.js
index a6af51b65d8..75e53149ea2 100644
--- a/apps/workflowengine/src/store.js
+++ b/apps/workflowengine/src/store.js
@@ -24,7 +24,6 @@ import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'nextcloud-axios'
import { getApiUrl } from './helpers/api'
-import { ALL_CHECKS } from './services/Operation'
import confirmPassword from 'nextcloud-password-confirmation'
Vue.use(Vuex)
@@ -40,13 +39,7 @@ const store = new Vuex.Store({
operators: {}
}),
- entities: OCP.InitialState.loadState('workflowengine', 'entities').map(entity => {
- return {
- ...entity,
- // TODO: move to backend data once checks are provided
- checks: [...ALL_CHECKS]
- }
- }),
+ entities: OCP.InitialState.loadState('workflowengine', 'entities'),
events: OCP.InitialState.loadState('workflowengine', 'entities')
.map((entity) => entity.events.map(event => {
return {
@@ -54,7 +47,8 @@ const store = new Vuex.Store({
entity,
...event
}
- })).flat()
+ })).flat(),
+ checks: OCP.InitialState.loadState('workflowengine', 'checks')
},
mutations: {
addRule(state, rule) {
@@ -149,6 +143,20 @@ const store = new Vuex.Store({
},
getEventsForOperation(state) {
return (operation) => state.events
+ },
+ /**
+ * Return all available checker plugins for a given entity class
+ */
+ getChecksForEntity(state) {
+ return (entity) => {
+ return state.checks
+ .filter((check) => check.supportedEntities.indexOf(entity) > -1 || check.supportedEntities.length === 0)
+ .map((check) => state.plugins.checks[check.id])
+ .reduce((obj, item) => {
+ obj[item.class] = item
+ return obj
+ }, {})
+ }
}
}
})
diff --git a/apps/workflowengine/src/workflowengine.js b/apps/workflowengine/src/workflowengine.js
index 6f96f454262..e05ac0a5053 100644
--- a/apps/workflowengine/src/workflowengine.js
+++ b/apps/workflowengine/src/workflowengine.js
@@ -4,7 +4,6 @@ import store from './store'
import Settings from './components/Workflow'
import FileValues from './components/Values/file'
-import {Operators} from './services/Operation';
/**
* A plugin for displaying a custom value field for checks
@@ -63,7 +62,29 @@ window.OCA.WorkflowEngine = Object.assign({}, OCA.WorkflowEngine, {
// Register shipped checks for file entity
FileValues.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(checkPlugin))
-Object.values(Operators).forEach((operatorPlugin) => window.OCA.WorkflowEngine.registerOperator(operatorPlugin))
+
+/**
+ * FIXME: remove before merge as this is for UI testing only
+ */
+const demo = [
+ {
+ id: 'OCA\\TestExample\\Operation1',
+ name: 'Rename file',
+ description: '🚧 For UI mocking only',
+ iconClass: 'icon-address-white',
+ color: 'var(--color-success)',
+ operation: 'deny'
+ },
+ {
+ id: 'OCA\\TestExample\\Operation2',
+ name: 'Notify me',
+ description: '🚧 For UI mocking only',
+ iconClass: 'icon-comment-white',
+ color: 'var(--color-warning)',
+ operation: 'deny'
+ }
+]
+demo.forEach((operatorPlugin) => window.OCA.WorkflowEngine.registerOperator(operatorPlugin))
Vue.use(Vuex)
Vue.prototype.t = t