aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workflowengine/src/components')
-rw-r--r--apps/workflowengine/src/components/Check.vue42
-rw-r--r--apps/workflowengine/src/components/Checks/FileMimeType.vue37
-rw-r--r--apps/workflowengine/src/components/Checks/FileSystemTag.vue15
-rw-r--r--apps/workflowengine/src/components/Checks/RequestTime.vue33
-rw-r--r--apps/workflowengine/src/components/Checks/RequestURL.vue26
-rw-r--r--apps/workflowengine/src/components/Checks/RequestUserAgent.vue46
-rw-r--r--apps/workflowengine/src/components/Checks/RequestUserGroup.vue70
-rw-r--r--apps/workflowengine/src/components/Checks/file.js5
-rw-r--r--apps/workflowengine/src/components/Checks/request.js9
-rw-r--r--apps/workflowengine/src/components/Event.vue2
-rw-r--r--apps/workflowengine/src/components/Operation.vue2
-rw-r--r--apps/workflowengine/src/components/Rule.vue49
-rw-r--r--apps/workflowengine/src/components/Workflow.vue8
13 files changed, 249 insertions, 95 deletions
diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue
index 6992c7ceee0..136f6d21280 100644
--- a/apps/workflowengine/src/components/Check.vue
+++ b/apps/workflowengine/src/components/Check.vue
@@ -19,8 +19,18 @@
:clearable="false"
:placeholder="t('workflowengine', 'Select a comparator')"
@input="updateCheck" />
+ <component :is="currentElement"
+ v-if="currentElement"
+ ref="checkComponent"
+ :disabled="!currentOption"
+ :operator="check.operator"
+ :model-value="check.value"
+ class="option"
+ @update:model-value="updateCheck"
+ @valid="(valid=true) && validate()"
+ @invalid="!(valid=false) && validate()" />
<component :is="currentOption.component"
- v-if="currentOperator && currentComponent"
+ v-else-if="currentOperator && currentComponent"
v-model="check.value"
:disabled="!currentOption"
:check="check"
@@ -47,12 +57,11 @@
</template>
<script>
-import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
-import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcActions from '@nextcloud/vue/components/NcActions'
+import NcActionButton from '@nextcloud/vue/components/NcActionButton'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import CloseIcon from 'vue-material-design-icons/Close.vue'
-
import ClickOutside from 'vue-click-outside'
export default {
@@ -99,6 +108,12 @@ export default {
}
return operators
},
+ currentElement() {
+ if (!this.check.class) {
+ return false
+ }
+ return this.checks[this.check.class].element
+ },
currentComponent() {
if (!this.currentOption) { return [] }
return this.checks[this.currentOption.class].component
@@ -120,6 +135,15 @@ export default {
this.currentOption = this.checks[this.check.class]
this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator)
+ if (this.currentElement) {
+ // If we do not set it, the check`s value would remain empty. Unsure why Vue behaves this way.
+ this.$refs.checkComponent.modelValue = undefined
+ } else if (this.currentOption?.component) {
+ // keeping this in an else for apps that try to be backwards compatible and may ship both
+ // to be removed in 03/2028
+ console.warn('Developer warning: `CheckPlugin.options` is deprecated. Use `CheckPlugin.element` instead.')
+ }
+
if (this.check.class === null) {
this.$nextTick(() => this.$refs.checkSelector.$el.focus())
}
@@ -141,11 +165,15 @@ export default {
this.check.invalid = !this.valid
this.$emit('validate', this.valid)
},
- updateCheck() {
- const matchingOperator = this.operators.findIndex((operator) => this.check.operator === operator.operator)
+ updateCheck(event) {
+ const selectedOperator = event?.operator || this.currentOperator?.operator || this.check.operator
+ const matchingOperator = this.operators.findIndex((operator) => selectedOperator === operator.operator)
if (this.check.class !== this.currentOption.class || matchingOperator === -1) {
this.currentOperator = this.operators[0]
}
+ if (event?.detail) {
+ this.check.value = event.detail[0]
+ }
// eslint-disable-next-line vue/no-mutating-props
this.check.class = this.currentOption.class
// eslint-disable-next-line vue/no-mutating-props
diff --git a/apps/workflowengine/src/components/Checks/FileMimeType.vue b/apps/workflowengine/src/components/Checks/FileMimeType.vue
index 0d1e6b3daa1..6817b128e27 100644
--- a/apps/workflowengine/src/components/Checks/FileMimeType.vue
+++ b/apps/workflowengine/src/components/Checks/FileMimeType.vue
@@ -4,7 +4,7 @@
-->
<template>
<div>
- <NcSelect :value="currentValue"
+ <NcSelect :model-value="currentValue"
:placeholder="t('workflowengine', 'Select a file type')"
label="label"
:options="options"
@@ -30,17 +30,16 @@
</template>
</NcSelect>
<input v-if="!isPredefined"
- type="text"
:value="currentValue.id"
+ type="text"
:placeholder="t('workflowengine', 'e.g. httpd/unix-directory')"
@input="updateCustom">
</div>
</template>
<script>
-import NcEllipsisedOption from '@nextcloud/vue/dist/Components/NcEllipsisedOption.js'
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
-import valueMixin from './../../mixins/valueMixin.js'
+import NcEllipsisedOption from '@nextcloud/vue/components/NcEllipsisedOption'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import { imagePath } from '@nextcloud/router'
export default {
@@ -49,9 +48,15 @@ export default {
NcEllipsisedOption,
NcSelect,
},
- mixins: [
- valueMixin,
- ],
+ props: {
+ modelValue: {
+ type: String,
+ default: '',
+ },
+ },
+
+ emits: ['update:model-value'],
+
data() {
return {
predefinedTypes: [
@@ -76,6 +81,7 @@ export default {
id: 'application/pdf',
},
],
+ newValue: '',
}
},
computed: {
@@ -108,21 +114,30 @@ export default {
}
},
},
+ watch: {
+ modelValue() {
+ this.updateInternalValue()
+ },
+ },
+
methods: {
validateRegex(string) {
const regexRegex = /^\/(.*)\/([gui]{0,3})$/
const result = regexRegex.exec(string)
return result !== null
},
+ updateInternalValue() {
+ this.newValue = this.modelValue
+ },
setValue(value) {
if (value !== null) {
this.newValue = value.id
- this.$emit('input', this.newValue)
+ this.$emit('update:model-value', this.newValue)
}
},
updateCustom(event) {
- this.newValue = event.target.value
- this.$emit('input', this.newValue)
+ this.newValue = event.target.value || event.detail[0]
+ this.$emit('update:model-value', this.newValue)
},
},
}
diff --git a/apps/workflowengine/src/components/Checks/FileSystemTag.vue b/apps/workflowengine/src/components/Checks/FileSystemTag.vue
index 69d2db0b85b..e71b0cd259a 100644
--- a/apps/workflowengine/src/components/Checks/FileSystemTag.vue
+++ b/apps/workflowengine/src/components/Checks/FileSystemTag.vue
@@ -9,7 +9,7 @@
</template>
<script>
-import NcSelectTags from '@nextcloud/vue/dist/Components/NcSelectTags.js'
+import NcSelectTags from '@nextcloud/vue/components/NcSelectTags'
export default {
name: 'FileSystemTag',
@@ -17,18 +17,21 @@ export default {
NcSelectTags,
},
props: {
- value: {
+ modelValue: {
type: String,
default: '',
},
},
+
+ emits: ['update:model-value'],
+
data() {
return {
newValue: [],
}
},
watch: {
- value() {
+ modelValue() {
this.updateValue()
},
},
@@ -37,14 +40,14 @@ export default {
},
methods: {
updateValue() {
- if (this.value !== '') {
- this.newValue = parseInt(this.value)
+ if (this.modelValue !== '') {
+ this.newValue = parseInt(this.modelValue)
} else {
this.newValue = null
}
},
update() {
- this.$emit('input', this.newValue || '')
+ this.$emit('update:model-value', this.newValue || '')
},
},
}
diff --git a/apps/workflowengine/src/components/Checks/RequestTime.vue b/apps/workflowengine/src/components/Checks/RequestTime.vue
index f48ec8cd270..5b1a4ef1cfa 100644
--- a/apps/workflowengine/src/components/Checks/RequestTime.vue
+++ b/apps/workflowengine/src/components/Checks/RequestTime.vue
@@ -25,9 +25,8 @@
</template>
<script>
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import moment from 'moment-timezone'
-import valueMixin from '../../mixins/valueMixin.js'
const zones = moment.tz.names()
export default {
@@ -35,15 +34,13 @@ export default {
components: {
NcSelect,
},
- mixins: [
- valueMixin,
- ],
props: {
- value: {
+ modelValue: {
type: String,
- default: '',
+ default: '[]',
},
},
+ emits: ['update:model-value'],
data() {
return {
timezones: zones,
@@ -53,21 +50,31 @@ export default {
endTime: null,
timezone: moment.tz.guess(),
},
+ stringifiedValue: '[]',
}
},
- mounted() {
- this.validate()
+ watch: {
+ modelValue() {
+ this.updateInternalValue()
+ },
+ },
+ beforeMount() {
+ // this is necessary to keep so the value is re-applied when a different
+ // check is being removed.
+ this.updateInternalValue()
},
methods: {
- updateInternalValue(value) {
+ updateInternalValue() {
try {
- const data = JSON.parse(value)
+ const data = JSON.parse(this.modelValue)
if (data.length === 2) {
this.newValue = {
startTime: data[0].split(' ', 2)[0],
endTime: data[1].split(' ', 2)[0],
timezone: data[0].split(' ', 2)[1],
}
+ this.stringifiedValue = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
+ this.validate()
}
} catch (e) {
// ignore invalid values
@@ -89,8 +96,8 @@ export default {
this.newValue.timezone = moment.tz.guess()
}
if (this.validate()) {
- const output = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
- this.$emit('input', output)
+ this.stringifiedValue = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
+ this.$emit('update:model-value', this.stringifiedValue)
}
},
},
diff --git a/apps/workflowengine/src/components/Checks/RequestURL.vue b/apps/workflowengine/src/components/Checks/RequestURL.vue
index b6a0bbd80e6..21b3a9cacbe 100644
--- a/apps/workflowengine/src/components/Checks/RequestURL.vue
+++ b/apps/workflowengine/src/components/Checks/RequestURL.vue
@@ -4,7 +4,8 @@
-->
<template>
<div>
- <NcSelect :value="currentValue"
+ <NcSelect v-model="newValue"
+ :value="currentValue"
:placeholder="t('workflowengine', 'Select a request URL')"
label="label"
:clearable="false"
@@ -32,8 +33,8 @@
</template>
<script>
-import NcEllipsisedOption from '@nextcloud/vue/dist/Components/NcEllipsisedOption.js'
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcEllipsisedOption from '@nextcloud/vue/components/NcEllipsisedOption'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import valueMixin from '../../mixins/valueMixin.js'
export default {
@@ -45,6 +46,19 @@ export default {
mixins: [
valueMixin,
],
+ props: {
+ modelValue: {
+ type: String,
+ default: '',
+ },
+ operator: {
+ type: String,
+ default: '',
+ },
+ },
+
+ emits: ['update:model-value'],
+
data() {
return {
newValue: '',
@@ -62,7 +76,7 @@ export default {
return [...this.predefinedTypes, this.customValue]
},
placeholder() {
- if (this.check.operator === 'matches' || this.check.operator === '!matches') {
+ if (this.operator === 'matches' || this.operator === '!matches') {
return '/^https\\:\\/\\/localhost\\/index\\.php$/i'
}
return 'https://localhost/index.php'
@@ -102,12 +116,12 @@ export default {
// TODO: check if value requires a regex and set the check operator according to that
if (value !== null) {
this.newValue = value.id
- this.$emit('input', this.newValue)
+ this.$emit('update:model-value', this.newValue)
}
},
updateCustom(event) {
this.newValue = event.target.value
- this.$emit('input', this.newValue)
+ this.$emit('update:model-value', this.newValue)
},
},
}
diff --git a/apps/workflowengine/src/components/Checks/RequestUserAgent.vue b/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
index be4075a1370..825a112f6fc 100644
--- a/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
+++ b/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
@@ -4,7 +4,7 @@
-->
<template>
<div>
- <NcSelect :value="currentValue"
+ <NcSelect v-model="currentValue"
:placeholder="t('workflowengine', 'Select a user agent')"
label="label"
:options="options"
@@ -24,15 +24,15 @@
</template>
</NcSelect>
<input v-if="!isPredefined"
+ v-model="newValue"
type="text"
- :value="currentValue.id"
@input="updateCustom">
</div>
</template>
<script>
-import NcEllipsisedOption from '@nextcloud/vue/dist/Components/NcEllipsisedOption.js'
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcEllipsisedOption from '@nextcloud/vue/components/NcEllipsisedOption'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import valueMixin from '../../mixins/valueMixin.js'
export default {
@@ -44,6 +44,13 @@ export default {
mixins: [
valueMixin,
],
+ props: {
+ modelValue: {
+ type: String,
+ default: '',
+ },
+ },
+ emits: ['update:model-value'],
data() {
return {
newValue: '',
@@ -73,15 +80,20 @@ export default {
id: '',
}
},
- currentValue() {
- if (this.matchingPredefined) {
- return this.matchingPredefined
- }
- return {
- icon: 'icon-settings-dark',
- label: t('workflowengine', 'Custom user agent'),
- id: this.newValue,
- }
+ currentValue: {
+ get() {
+ if (this.matchingPredefined) {
+ return this.matchingPredefined
+ }
+ return {
+ icon: 'icon-settings-dark',
+ label: t('workflowengine', 'Custom user agent'),
+ id: this.newValue,
+ }
+ },
+ set(value) {
+ this.newValue = value
+ },
},
},
methods: {
@@ -94,12 +106,12 @@ export default {
// TODO: check if value requires a regex and set the check operator according to that
if (value !== null) {
this.newValue = value.id
- this.$emit('input', this.newValue)
+ this.$emit('update:model-value', this.newValue)
}
},
- updateCustom(event) {
- this.newValue = event.target.value
- this.$emit('input', this.newValue)
+ updateCustom() {
+ this.newValue = this.currentValue.id
+ this.$emit('update:model-value', this.newValue)
},
},
}
diff --git a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
index c639f20e5bd..f9606b7ca26 100644
--- a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
+++ b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
@@ -10,10 +10,10 @@
:loading="status.isLoading && groups.length === 0"
:placeholder="t('workflowengine', 'Type to search for group …')"
:options="groups"
- :value="currentValue"
+ :model-value="currentValue"
label="displayname"
@search="searchAsync"
- @input="(value) => $emit('input', value.id)" />
+ @input="update" />
</div>
</template>
@@ -22,9 +22,10 @@ import { translate as t } from '@nextcloud/l10n'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
const groups = []
+const wantedGroups = []
const status = {
isLoading: false,
}
@@ -35,7 +36,7 @@ export default {
NcSelect,
},
props: {
- value: {
+ modelValue: {
type: String,
default: '',
},
@@ -44,15 +45,28 @@ export default {
default: () => { return {} },
},
},
+ emits: ['update:model-value'],
data() {
return {
groups,
status,
+ wantedGroups,
+ newValue: '',
}
},
computed: {
- currentValue() {
- return this.groups.find(group => group.id === this.value) || null
+ currentValue: {
+ get() {
+ return this.groups.find(group => group.id === this.newValue) || null
+ },
+ set(value) {
+ this.newValue = value
+ },
+ },
+ },
+ watch: {
+ modelValue() {
+ this.updateInternalValue()
},
},
async mounted() {
@@ -61,8 +75,8 @@ export default {
await this.searchAsync('')
}
// If a current group is set but not in our list of groups then search for that group
- if (this.currentValue === null && this.value) {
- await this.searchAsync(this.value)
+ if (this.currentValue === null && this.newValue) {
+ await this.searchAsync(this.newValue)
}
},
methods: {
@@ -70,6 +84,13 @@ export default {
searchAsync(searchQuery) {
if (this.status.isLoading) {
+ if (searchQuery) {
+ // The first 20 groups are loaded up front (indicated by an
+ // empty searchQuery parameter), afterwards we may load
+ // groups that have not been fetched yet, but are used
+ // in existing rules.
+ this.enqueueWantedGroup(searchQuery)
+ }
return
}
@@ -82,16 +103,49 @@ export default {
})
})
this.status.isLoading = false
+ this.findGroupByQueue()
}, (error) => {
console.error('Error while loading group list', error.response)
})
},
+ async updateInternalValue() {
+ if (!this.newValue) {
+ await this.searchAsync(this.modelValue)
+ }
+ this.newValue = this.modelValue
+ },
addGroup(group) {
const index = this.groups.findIndex((item) => item.id === group.id)
if (index === -1) {
this.groups.push(group)
}
},
+ hasGroup(group) {
+ const index = this.groups.findIndex((item) => item.id === group)
+ return index > -1
+ },
+ update(value) {
+ this.newValue = value.id
+ this.$emit('update:model-value', this.newValue)
+ },
+ enqueueWantedGroup(expectedGroupId) {
+ const index = this.wantedGroups.findIndex((groupId) => groupId === expectedGroupId)
+ if (index === -1) {
+ this.wantedGroups.push(expectedGroupId)
+ }
+ },
+ async findGroupByQueue() {
+ let nextQuery
+ do {
+ nextQuery = this.wantedGroups.shift()
+ if (this.hasGroup(nextQuery)) {
+ nextQuery = undefined
+ }
+ } while (!nextQuery && this.wantedGroups.length > 0)
+ if (nextQuery) {
+ await this.searchAsync(nextQuery)
+ }
+ },
},
}
</script>
diff --git a/apps/workflowengine/src/components/Checks/file.js b/apps/workflowengine/src/components/Checks/file.js
index 246f46ff55b..568efc81cd3 100644
--- a/apps/workflowengine/src/components/Checks/file.js
+++ b/apps/workflowengine/src/components/Checks/file.js
@@ -4,6 +4,7 @@
*/
import { stringValidator, validateIPv4, validateIPv6 } from '../../helpers/validators.js'
+import { registerCustomElement } from '../../helpers/window.js'
import FileMimeType from './FileMimeType.vue'
import FileSystemTag from './FileSystemTag.vue'
@@ -34,7 +35,7 @@ const FileChecks = [
class: 'OCA\\WorkflowEngine\\Check\\FileMimeType',
name: t('workflowengine', 'File MIME type'),
operators: stringOrRegexOperators,
- component: FileMimeType,
+ element: registerCustomElement(FileMimeType, 'oca-workflowengine-checks-file_mime_type'),
},
{
@@ -80,7 +81,7 @@ const FileChecks = [
{ operator: 'is', name: t('workflowengine', 'is tagged with') },
{ operator: '!is', name: t('workflowengine', 'is not tagged with') },
],
- component: FileSystemTag,
+ element: registerCustomElement(FileSystemTag, 'oca-workflowengine-file_system_tag'),
},
]
diff --git a/apps/workflowengine/src/components/Checks/request.js b/apps/workflowengine/src/components/Checks/request.js
index 3bbf464adb5..b91f00baef0 100644
--- a/apps/workflowengine/src/components/Checks/request.js
+++ b/apps/workflowengine/src/components/Checks/request.js
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { registerCustomElement } from '../../helpers/window.js'
import RequestUserAgent from './RequestUserAgent.vue'
import RequestTime from './RequestTime.vue'
import RequestURL from './RequestURL.vue'
@@ -18,7 +19,7 @@ const RequestChecks = [
{ operator: 'matches', name: t('workflowengine', 'matches') },
{ operator: '!matches', name: t('workflowengine', 'does not match') },
],
- component: RequestURL,
+ element: registerCustomElement(RequestURL, 'oca-workflowengine-checks-request_url'),
},
{
class: 'OCA\\WorkflowEngine\\Check\\RequestTime',
@@ -27,7 +28,7 @@ const RequestChecks = [
{ operator: 'in', name: t('workflowengine', 'between') },
{ operator: '!in', name: t('workflowengine', 'not between') },
],
- component: RequestTime,
+ element: registerCustomElement(RequestTime, 'oca-workflowengine-checks-request_time'),
},
{
class: 'OCA\\WorkflowEngine\\Check\\RequestUserAgent',
@@ -38,7 +39,7 @@ const RequestChecks = [
{ operator: 'matches', name: t('workflowengine', 'matches') },
{ operator: '!matches', name: t('workflowengine', 'does not match') },
],
- component: RequestUserAgent,
+ element: registerCustomElement(RequestUserAgent, 'oca-workflowengine-checks-request_user_agent'),
},
{
class: 'OCA\\WorkflowEngine\\Check\\UserGroupMembership',
@@ -47,7 +48,7 @@ const RequestChecks = [
{ operator: 'is', name: t('workflowengine', 'is member of') },
{ operator: '!is', name: t('workflowengine', 'is not member of') },
],
- component: RequestUserGroup,
+ element: registerCustomElement(RequestUserGroup, 'oca-workflowengine-checks-request_user_group'),
},
]
diff --git a/apps/workflowengine/src/components/Event.vue b/apps/workflowengine/src/components/Event.vue
index 52a14bd08ec..f170101b4e9 100644
--- a/apps/workflowengine/src/components/Event.vue
+++ b/apps/workflowengine/src/components/Event.vue
@@ -30,7 +30,7 @@
</template>
<script>
-import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
+import NcSelect from '@nextcloud/vue/components/NcSelect'
import { showWarning } from '@nextcloud/dialogs'
export default {
diff --git a/apps/workflowengine/src/components/Operation.vue b/apps/workflowengine/src/components/Operation.vue
index c24471c8fd9..df0b78dad89 100644
--- a/apps/workflowengine/src/components/Operation.vue
+++ b/apps/workflowengine/src/components/Operation.vue
@@ -19,7 +19,7 @@
</template>
<script>
-import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
+import NcButton from '@nextcloud/vue/components/NcButton'
export default {
name: 'Operation',
diff --git a/apps/workflowengine/src/components/Rule.vue b/apps/workflowengine/src/components/Rule.vue
index 80745643084..1c321fd014c 100644
--- a/apps/workflowengine/src/components/Rule.vue
+++ b/apps/workflowengine/src/components/Rule.vue
@@ -29,8 +29,12 @@
<div class="flow-icon icon-confirm" />
<div class="action">
<Operation :operation="operation" :colored="false">
+ <component :is="operation.element"
+ v-if="operation.element"
+ :model-value="inputValue"
+ @update:model-value="updateOperationByEvent" />
<component :is="operation.options"
- v-if="operation.options"
+ v-else-if="operation.options"
v-model="rule.operation"
@input="updateOperation" />
</Operation>
@@ -57,13 +61,13 @@
</template>
<script>
-import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
-import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
-import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
-import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
-import ArrowRight from 'vue-material-design-icons/ArrowRight.vue'
-import CheckMark from 'vue-material-design-icons/Check.vue'
-import Close from 'vue-material-design-icons/Close.vue'
+import NcActions from '@nextcloud/vue/components/NcActions'
+import NcActionButton from '@nextcloud/vue/components/NcActionButton'
+import NcButton from '@nextcloud/vue/components/NcButton'
+import Tooltip from '@nextcloud/vue/directives/Tooltip'
+import IconArrowRight from 'vue-material-design-icons/ArrowRight.vue'
+import IconCheckMark from 'vue-material-design-icons/Check.vue'
+import IconClose from 'vue-material-design-icons/Close.vue'
import Event from './Event.vue'
import Check from './Check.vue'
@@ -72,10 +76,7 @@ import Operation from './Operation.vue'
export default {
name: 'Rule',
components: {
- ArrowRight,
Check,
- CheckMark,
- Close,
Event,
NcActionButton,
NcActions,
@@ -98,9 +99,14 @@ export default {
error: null,
dirty: this.rule.id < 0,
originalRule: null,
+ element: null,
+ inputValue: '',
}
},
computed: {
+ /**
+ * @return {OperatorPlugin}
+ */
operation() {
return this.$store.getters.getOperationForRule(this.rule)
},
@@ -108,15 +114,15 @@ export default {
if (this.error || !this.rule.valid || this.rule.checks.length === 0 || this.rule.checks.some((check) => check.invalid === true)) {
return {
title: t('workflowengine', 'The configuration is invalid'),
- icon: 'Close',
+ icon: IconClose,
type: 'warning',
tooltip: { placement: 'bottom', show: true, content: this.error },
}
}
if (!this.dirty) {
- return { title: t('workflowengine', 'Active'), icon: 'CheckMark', type: 'success' }
+ return { title: t('workflowengine', 'Active'), icon: IconCheckMark, type: 'success' }
}
- return { title: t('workflowengine', 'Save'), icon: 'ArrowRight', type: 'primary' }
+ return { title: t('workflowengine', 'Save'), icon: IconArrowRight, type: 'primary' }
},
lastCheckComplete() {
@@ -126,11 +132,23 @@ export default {
},
mounted() {
this.originalRule = JSON.parse(JSON.stringify(this.rule))
+ if (this.operation?.element) {
+ this.inputValue = this.rule.operation
+ } else if (this.operation?.options) {
+ // keeping this in an else for apps that try to be backwards compatible and may ship both
+ // to be removed in 03/2028
+ console.warn('Developer warning: `OperatorPlugin.options` is deprecated. Use `OperatorPlugin.element` instead.')
+ }
},
methods: {
async updateOperation(operation) {
this.$set(this.rule, 'operation', operation)
- await this.updateRule()
+ this.updateRule()
+ },
+ async updateOperationByEvent(event) {
+ this.inputValue = event.detail[0]
+ this.$set(this.rule, 'operation', event.detail[0])
+ this.updateRule()
},
validate(/* state */) {
this.error = null
@@ -167,6 +185,7 @@ export default {
if (this.rule.id < 0) {
this.$store.dispatch('removeRule', this.rule)
} else {
+ this.inputValue = this.originalRule.operation
this.$store.dispatch('updateRule', this.originalRule)
this.originalRule = JSON.parse(JSON.stringify(this.rule))
this.dirty = false
diff --git a/apps/workflowengine/src/components/Workflow.vue b/apps/workflowengine/src/components/Workflow.vue
index 632be97c509..03ec2a79324 100644
--- a/apps/workflowengine/src/components/Workflow.vue
+++ b/apps/workflowengine/src/components/Workflow.vue
@@ -65,10 +65,10 @@
<script>
import Rule from './Rule.vue'
import Operation from './Operation.vue'
-import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
-import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
-import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
-import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
+import NcButton from '@nextcloud/vue/components/NcButton'
+import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
+import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
+import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
import { mapGetters, mapState } from 'vuex'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'