Merge pull request #18547 from nextcloud/bugfix/flow
Various flow related fixes
This commit is contained in:
commit
f3232fc192
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -467,9 +467,16 @@ class Manager implements IManager {
|
||||||
|
|
||||||
$this->validateEvents($entity, $events, $instance);
|
$this->validateEvents($entity, $events, $instance);
|
||||||
|
|
||||||
|
if (count($checks) === 0) {
|
||||||
|
throw new \UnexpectedValueException($this->l->t('At least one check needs to be provided'));
|
||||||
|
}
|
||||||
$instance->validateOperation($name, $checks, $operation);
|
$instance->validateOperation($name, $checks, $operation);
|
||||||
|
|
||||||
foreach ($checks as $check) {
|
foreach ($checks as $check) {
|
||||||
|
if (!is_string($check['class'])) {
|
||||||
|
throw new \UnexpectedValueException($this->l->t('Invalid check provided'));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var ICheck $instance */
|
/** @var ICheck $instance */
|
||||||
$instance = $this->container->query($check['class']);
|
$instance = $this->container->query($check['class']);
|
||||||
|
|
|
@ -72,7 +72,7 @@ export default {
|
||||||
currentOption: null,
|
currentOption: null,
|
||||||
currentOperator: null,
|
currentOperator: null,
|
||||||
options: [],
|
options: [],
|
||||||
valid: true,
|
valid: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -107,6 +107,11 @@ export default {
|
||||||
this.options = Object.values(this.checks)
|
this.options = Object.values(this.checks)
|
||||||
this.currentOption = this.checks[this.check.class]
|
this.currentOption = this.checks[this.check.class]
|
||||||
this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator)
|
this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator)
|
||||||
|
|
||||||
|
if (this.check.class === null) {
|
||||||
|
this.$nextTick(() => this.$refs.checkSelector.$el.focus())
|
||||||
|
}
|
||||||
|
this.check.invalid = !this.validate()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showDelete() {
|
showDelete() {
|
||||||
|
|
|
@ -56,7 +56,21 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateEvent(events) {
|
updateEvent(events) {
|
||||||
this.$set(this.rule, 'events', events.map(event => event.eventName))
|
if (events.length === 0) {
|
||||||
|
window.OCP.Toast.warning(t('workflowengine', 'At least one event must be selected'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const existingEntity = this.rule.entity
|
||||||
|
const newEntities = events.map(event => event.entity.id).filter((value, index, self) => self.indexOf(value) === index)
|
||||||
|
let newEntity = null
|
||||||
|
if (newEntities.length > 1) {
|
||||||
|
newEntity = newEntities.filter(entity => entity !== existingEntity)[0]
|
||||||
|
} else {
|
||||||
|
newEntity = newEntities[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$set(this.rule, 'entity', newEntity)
|
||||||
|
this.$set(this.rule, 'events', events.filter(event => event.entity.id === newEntity).map(event => event.eventName))
|
||||||
this.$emit('update', this.rule)
|
this.$emit('update', this.rule)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
@input="updateOperation" />
|
@input="updateOperation" />
|
||||||
</Operation>
|
</Operation>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button v-tooltip="ruleStatus.tooltip"
|
<button class="status-button icon"
|
||||||
class="status-button icon"
|
|
||||||
:class="ruleStatus.class"
|
:class="ruleStatus.class"
|
||||||
@click="saveRule">
|
@click="saveRule">
|
||||||
{{ ruleStatus.title }}
|
{{ ruleStatus.title }}
|
||||||
|
@ -43,6 +42,9 @@
|
||||||
{{ t('workflowengine', 'Delete') }}
|
{{ t('workflowengine', 'Delete') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<p v-if="error" class="error-message">
|
||||||
|
{{ error }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -84,7 +86,7 @@ export default {
|
||||||
return this.$store.getters.getOperationForRule(this.rule)
|
return this.$store.getters.getOperationForRule(this.rule)
|
||||||
},
|
},
|
||||||
ruleStatus() {
|
ruleStatus() {
|
||||||
if (this.error || !this.rule.valid || this.rule.checks.some((check) => check.invalid === true)) {
|
if (this.error || !this.rule.valid || this.rule.checks.length === 0 || this.rule.checks.some((check) => check.invalid === true)) {
|
||||||
return {
|
return {
|
||||||
title: t('workflowengine', 'The configuration is invalid'),
|
title: t('workflowengine', 'The configuration is invalid'),
|
||||||
class: 'icon-close-white invalid',
|
class: 'icon-close-white invalid',
|
||||||
|
@ -174,12 +176,19 @@ export default {
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
display: block;
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
float: right;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.status-button {
|
.status-button {
|
||||||
transition: 0.5s ease all;
|
transition: 0.5s ease all;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
:operation="operation"
|
:operation="operation"
|
||||||
@click.native="createNewRule(operation)" />
|
@click.native="createNewRule(operation)" />
|
||||||
|
|
||||||
<a :key="'add'" :href="appstoreUrl" class="actions__item colored more">
|
<a v-if="showAppStoreHint"
|
||||||
|
:key="'add'"
|
||||||
|
:href="appstoreUrl"
|
||||||
|
class="actions__item colored more">
|
||||||
<div class="icon icon-add" />
|
<div class="icon icon-add" />
|
||||||
<div class="actions__item__description">
|
<div class="actions__item__description">
|
||||||
<h3>{{ t('workflowengine', 'More flows') }}</h3>
|
<h3>{{ t('workflowengine', 'More flows') }}</h3>
|
||||||
|
@ -49,6 +52,7 @@ import Rule from './Rule'
|
||||||
import Operation from './Operation'
|
import Operation from './Operation'
|
||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
import { loadState } from '@nextcloud/initial-state'
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
|
import { generateUrl } from '@nextcloud/router'
|
||||||
|
|
||||||
const ACTION_LIMIT = 3
|
const ACTION_LIMIT = 3
|
||||||
|
|
||||||
|
@ -61,7 +65,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showMoreOperations: false,
|
showMoreOperations: false,
|
||||||
appstoreUrl: '/index.php/settings/apps/workflow',
|
appstoreUrl: generateUrl('settings/apps/workflow'),
|
||||||
scope: loadState('workflowengine', 'scope'),
|
scope: loadState('workflowengine', 'scope'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -81,6 +85,9 @@ export default {
|
||||||
}
|
}
|
||||||
return Object.values(this.operations).slice(0, ACTION_LIMIT)
|
return Object.values(this.operations).slice(0, ACTION_LIMIT)
|
||||||
},
|
},
|
||||||
|
showAppStoreHint() {
|
||||||
|
return this.scope === 0 && OC.isUserAdmin()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.dispatch('fetchRules')
|
this.$store.dispatch('fetchRules')
|
||||||
|
|
|
@ -98,7 +98,9 @@ const store = new Vuex.Store({
|
||||||
entity: entity ? entity.id : rule.fixedEntity,
|
entity: entity ? entity.id : rule.fixedEntity,
|
||||||
events,
|
events,
|
||||||
name: '', // unused in the new ui, there for legacy reasons
|
name: '', // unused in the new ui, there for legacy reasons
|
||||||
checks: [],
|
checks: [
|
||||||
|
{ class: null, operator: null, value: '' },
|
||||||
|
],
|
||||||
operation: rule.operation || '',
|
operation: rule.operation || '',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
background-size: 50px 50px;
|
background-size: 50px 50px;
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 10px;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
.actions__item__description {
|
.actions__item__description {
|
||||||
|
|
Loading…
Reference in New Issue