Move over checker plugins

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-09-06 16:23:45 +02:00
parent d6b3af9d77
commit 98666a9f4d
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
14 changed files with 547 additions and 193 deletions

View File

@ -16,9 +16,10 @@
</template>
<script>
import { Multiselect, Actions, ActionButton } from 'nextcloud-vue'
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
import { Actions } from 'nextcloud-vue/dist/Components/Actions'
import { ActionButton } from 'nextcloud-vue/dist/Components/ActionButton'
import ClickOutside from 'vue-click-outside'
import { mapState } from 'vuex'
export default {
name: 'Check',

View File

@ -1,9 +1,8 @@
<template>
<div>
<multiselect
:value="currentValue"
placeholder="Select a file type"
placeholder="Select a user agent"
label="label"
track-by="pattern"
:options="options" :multiple="false" :tagging="false" @input="setValue">
@ -21,7 +20,7 @@
</template>
<script>
import { Multiselect } from 'nextcloud-vue'
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
export default {
name: 'FileMimeType',

View File

@ -0,0 +1,68 @@
<!--
- @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
-
- @author Julius Härtl <jus@bitgrid.net>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<MultiselectTag v-model="newValue" :multiple="false" type="text" placeholder="1 MB"
@input="update"/>
</template>
<script>
import { MultiselectTag } from 'nextcloud-vue'
export default {
name: 'SizeValue',
components: {
MultiselectTag
},
props: {
value: {
type: String,
default: ''
}
},
data() {
return {
valid: false,
newValue: this.value
}
},
watch: {
value() {
this.newValue = this.value
}
},
methods: {
update() {
if (this.validate()) {
this.$emit('input', this.newValue)
this.valid = false
} else {
this.valid = false
}
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,94 @@
<template>
<div class="timeslot">
<multiselect v-model="newValue.timezone" :options="timezones"></multiselect>
<input type="text" class="timeslot--start" v-model="newValue.startTime" placeholder="08:00" @input="update"/>
<input type="text" v-model="newValue.endTime" placeholder="18:00" @input="update"/>
</div>
</template>
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
import moment from 'moment-timezone'
const zones = moment.tz.names()
export default {
name: 'RequestTime',
components: {
Multiselect
},
props: {
value: {
type: String,
default: '1 MB'
}
},
data() {
return {
valid: false,
newValue: {
startTime: null,
endTime: null,
timezone: moment.tz.guess()
},
}
},
computed: {
timezones() {
return zones
}
},
watch: {
'value': function(value) {
var data = JSON.parse(value)
var startTime = data[0].split(' ', 2)[0]
var endTime = data[1].split(' ', 2)[0]
var timezone = data[0].split(' ', 2)[1]
this.newValue = {
startTime: startTime,
endTime: endTime,
timezone: timezone
}
}
},
methods: {
validate() {
return this.newValue.startTime && this.newValue.startTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null &&
this.newValue.endTime && this.newValue.endTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null &&
moment.tz.zone(this.newValue.timezone) !== null
},
update() {
if (this.validate()) {
const output = `["${this.newValue.startTime} ${this.newValue.timezone}","${this.newValue.endTime} ${this.newValue.timezone}"]`
this.$emit('input', output)
this.valid = true
} else {
this.valid = false
}
}
}
}
</script>
<style scoped lang="scss">
.timeslot {
display: flex;
flex-grow: 1;
flex-wrap: wrap;
max-width: 200px;
.multiselect {
width: 100%;
margin-bottom: 5px;
}
input[type=text] {
width: 50%;
margin: 0;
margin-bottom: 5px;
&.timeslot--start {
margin-right: 5px;
width: calc(50% - 5px);
}
}
}
</style>

View File

@ -0,0 +1,122 @@
<!--
- @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
-
- @author Julius Härtl <jus@bitgrid.net>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div>
<multiselect
:value="currentValue"
placeholder="Select a file type"
label="label"
track-by="pattern"
group-values="children",
group-label="text",
:options="options" :multiple="false" :tagging="false" @input="setValue">
<template slot="singleLabel" slot-scope="props">
<span class="option__icon" :class="props.option.icon"></span>
<span class="option__title option__title_single">{{ props.option.label }}</span>
</template>
<template slot="option" slot-scope="props">
<span class="option__icon" :class="props.option.icon"></span>
<span class="option__title">{{ props.option.label }}</span>
</template>
</multiselect>
<input type="text" :value="currentValue.pattern" @input="updateCustom"/>
</div>
</template>
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
export default {
name: 'UserAgent',
components: {
Multiselect
},
data() {
return {
value: '',
predefinedTypes: [
{
text: t('workflowengine', 'Sync clients'),
children: [
{ id: 'android', text: t('workflowengine', 'Android client') },
{ id: 'ios', text: t('workflowengine', 'iOS client') },
{ id: 'desktop', text: t('workflowengine', 'Desktop client') },
{ id: 'mail', text: t('workflowengine', 'Thunderbird & Outlook addons') }
]
}
]
}
},
computed: {
options() {
return [...this.predefinedTypes, this.customValue]
},
customValue() {
const matchingPredefined = this.predefinedTypes.find((type) => this.value.pattern === type.pattern)
return {
icon: 'icon-settings-dark',
label: t('workflowengine', 'Custom pattern'),
pattern: '',
}
},
currentValue() {
const matchingPredefined = this.predefinedTypes.find((type) => this.value === type.pattern)
if (matchingPredefined) {
return matchingPredefined
}
return {
icon: 'icon-settings-dark',
label: t('workflowengine', 'Custom pattern'),
pattern: this.value,
}
}
},
methods: {
validateRegex(string) {
var regexRegex = /^\/(.*)\/([gui]{0,3})$/
var result = regexRegex.exec(string)
return result !== null
},
setValue (value) {
// TODO: check if value requires a regex and set the check operator according to that
if (value !== null) {
this.value = value.pattern
}
},
updateCustom (event) {
console.log(event)
this.value = event.target.value
}
}
}
</script>
<style scoped>
.multiselect::v-deep .multiselect__single {
display: flex;
}
input, .multiselect {
width: 100%;
}
</style>

View File

@ -0,0 +1,102 @@
/*
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import FileMimeType from './FileMimeType';
import { stringValidator, validateIPv4, validateIPv6} from './../../helpers/validators'
const FileChecks = [
{
class: 'OCA\\WorkflowEngine\\Check\\FileName',
name: t('workflowengine', 'File name'),
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') }
],
placeholder: (check) => {
if (check.operator === 'matches' || check.operator === '!matches') {
return '/^dummy-.+$/i'
}
return 'filename.txt'
},
validate: stringValidator
},
{
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
},
{
class: 'OCA\\WorkflowEngine\\Check\\FileSize',
name: t('workflowengine', 'File size (upload)'),
operators: [
{ operator: 'less', name: t('workflowengine', 'less') },
{ operator: '!greater', name: t('workflowengine', 'less or equals') },
{ operator: '!less', name: t('workflowengine', 'greater or equals') },
{ operator: 'greater', name: t('workflowengine', 'greater') }
],
placeholder: (check) => '5 MB',
validate: (check) => check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null
},
{
class: 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress',
name: t('workflowengine', 'Request remote address'),
operators: [
{ operator: 'matchesIPv4', name: t('workflowengine', 'matches IPv4') },
{ operator: '!matchesIPv4', name: t('workflowengine', 'does not match IPv4') },
{ operator: 'matchesIPv6', name: t('workflowengine', 'matches IPv6') },
{ operator: '!matchesIPv6', name: t('workflowengine', 'does not match IPv6') }
],
placeholder: (check) => {
if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
return '::1/128';
}
return '127.0.0.1/32'
},
validate: (check) => {
if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
return validateIPv6(check.value)
}
return validateIPv4(check.value)
}
},
{
class: 'OCA\\WorkflowEngine\\Check\\FileSystemTags',
name: t('workflowengine', 'File system tag'),
operators: [
{ operator: 'is', name: t('workflowengine', 'is tagged with') },
{ operator: '!is', name: t('workflowengine', 'is not tagged with') }
]
}
]
export default FileChecks

View File

@ -0,0 +1,26 @@
/*
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import FileChecks from './file'
import RequestChecks from './request'
export default [...FileChecks, ...RequestChecks]

View File

@ -0,0 +1,70 @@
/*
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import RequestUserAgent from './RequestUserAgent';
import RequestTime from './RequestTime';
const RequestChecks = [
{
class: 'OCA\\WorkflowEngine\\Check\\RequestURL',
name: t('workflowengine', 'Request URL'),
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') }
],
// TODO: implement component
},
{
class: 'OCA\\WorkflowEngine\\Check\\RequestTime',
name: t('workflowengine', 'Request time'),
operators: [
{ operator: 'in', name: t('workflowengine', 'between') },
{ operator: '!in', name: t('workflowengine', 'not between') }
],
// TODO: implement component
component: RequestTime
},
{
class: 'OCA\\WorkflowEngine\\Check\\RequestUserAgent',
name: t('workflowengine', 'Request user agent'),
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: RequestUserAgent
},
{
class: 'OCA\\WorkflowEngine\\Check\\UserGroupMembership',
name: t('workflowengine', 'User group membership'),
operators: [
{ operator: 'is', name: t('workflowengine', 'is member of') },
{ operator: '!is', name: t('workflowengine', 'is not member of') }
],
// TODO: implement component
}
]
export default RequestChecks

View File

@ -20,7 +20,7 @@
</template>
<script>
import { Multiselect } from 'nextcloud-vue'
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
export default {
name: 'Event',

View File

@ -41,7 +41,9 @@
</template>
<script>
import { Actions, ActionButton, Tooltip } from 'nextcloud-vue'
import { Tooltip } from 'nextcloud-vue/dist/Directives/Tooltip'
import { Actions } from 'nextcloud-vue/dist/Components/Actions'
import { ActionButton } from 'nextcloud-vue/dist/Components/ActionButton'
import Event from './Event'
import Check from './Check'
import Operation from './Operation'

View File

@ -1,44 +0,0 @@
<template>
<input v-model="newValue" type="text" placeholder="1 MB"
@input="update">
</template>
<script>
export default {
name: 'SizeValue',
props: {
value: {
type: String,
default: '1 MB'
}
},
data() {
return {
valid: false,
newValue: this.value
}
},
watch: {
value() {
this.newValue = this.value
}
},
methods: {
validate() {
return this.newValue.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null
},
update() {
if (this.validate()) {
this.$emit('input', this.newValue)
this.valid = false
} else {
this.valid = false
}
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,133 +0,0 @@
/*
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import './../../legacy/filesystemtagsplugin'
import './../../legacy/requesttimeplugin'
import './../../legacy/requesturlplugin'
import './../../legacy/requestuseragentplugin'
import './../../legacy/usergroupmembershipplugin'
import FileMimeType from './FileMimeType';
const FileChecks = Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => {
if (plugin.component) {
return { ...plugin.getCheck(), component: plugin.component() }
}
return plugin.getCheck()
})
// new way of registering checks
const validateRegex = function(string) {
var regexRegex = /^\/(.*)\/([gui]{0,3})$/
var result = regexRegex.exec(string)
return result !== null
}
const validateIPv4 = function(string) {
var regexRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/
var result = regexRegex.exec(string)
return result !== null
}
const validateIPv6 = function(string) {
var regexRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/
var result = regexRegex.exec(string)
return result !== null
}
const stringValidator = (check) => {
if (check.operator === 'matches' || check.operator === '!matches') {
return validateRegex(check.value)
}
return true
}
FileChecks.push({
class: 'OCA\\WorkflowEngine\\Check\\FileName',
name: t('workflowengine', 'File name'),
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') }
],
placeholder: (check) => {
if (check.operator === 'matches' || check.operator === '!matches') {
return '/^dummy-.+$/i'
}
return 'filename.txt'
},
validate: stringValidator
})
FileChecks.push({
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
})
FileChecks.push({
class: 'OCA\\WorkflowEngine\\Check\\FileSize',
name: t('workflowengine', 'File size (upload)'),
operators: [
{ operator: 'less', name: t('workflowengine', 'less') },
{ operator: '!greater', name: t('workflowengine', 'less or equals') },
{ operator: '!less', name: t('workflowengine', 'greater or equals') },
{ operator: 'greater', name: t('workflowengine', 'greater') }
],
placeholder: (check) => '5 MB',
validate: (check) => check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null
})
FileChecks.push({
class: 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress',
name: t('workflowengine', 'Request remote address'),
operators: [
{ operator: 'matchesIPv4', name: t('workflowengine', 'matches IPv4') },
{ operator: '!matchesIPv4', name: t('workflowengine', 'does not match IPv4') },
{ operator: 'matchesIPv6', name: t('workflowengine', 'matches IPv6') },
{ operator: '!matchesIPv6', name: t('workflowengine', 'does not match IPv6') }
],
placeholder: (check) => {
if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
return '::1/128';
}
return '127.0.0.1/32'
},
validate: (check) => {
if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') {
return validateIPv6(check.value)
}
return validateIPv4(check.value)
}
})
export default FileChecks

View File

@ -0,0 +1,49 @@
/*
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
const validateRegex = function(string) {
var regexRegex = /^\/(.*)\/([gui]{0,3})$/
var result = regexRegex.exec(string)
return result !== null
}
const validateIPv4 = function(string) {
var regexRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/
var result = regexRegex.exec(string)
return result !== null
}
const validateIPv6 = function(string) {
var regexRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/
var result = regexRegex.exec(string)
return result !== null
}
const stringValidator = (check) => {
if (check.operator === 'matches' || check.operator === '!matches') {
return validateRegex(check.value)
}
return true
}
export { validateRegex, stringValidator, validateIPv4, validateIPv6 }

View File

@ -1,9 +1,8 @@
import Vue from 'vue'
import Vuex from 'vuex'
import store from './store'
import Settings from './components/Workflow'
import FileValues from './components/Values/file'
import ShippedChecks from './components/Checks'
/**
* A plugin for displaying a custom value field for checks
@ -43,7 +42,6 @@ import FileValues from './components/Values/file'
*/
window.OCA.WorkflowEngine = Object.assign({}, OCA.WorkflowEngine, {
/**
*
* @param {CheckPlugin} Plugin
@ -60,8 +58,8 @@ window.OCA.WorkflowEngine = Object.assign({}, OCA.WorkflowEngine, {
}
})
// Register shipped checks for file entity
FileValues.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(checkPlugin))
// Register shipped checks
ShippedChecks.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(checkPlugin))
/**
* FIXME: remove before merge as this is for UI testing only
@ -69,16 +67,16 @@ FileValues.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(chec
const demo = [
{
id: 'OCA\\TestExample\\Operation1',
name: 'Rename file',
description: '🚧 For UI mocking only',
iconClass: 'icon-address-white',
name: 'Convert to PDF',
description: 'Convert a file to PDF using Libreoffice',
iconClass: 'icon-convert-pdf',
color: 'var(--color-success)',
operation: 'deny'
},
{
id: 'OCA\\TestExample\\Operation2',
name: 'Notify me',
description: '🚧 For UI mocking only',
description: 'Send a Nextcloud Notification',
iconClass: 'icon-comment-white',
color: 'var(--color-warning)',
operation: 'deny'