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);
|
||||
|
||||
if (count($checks) === 0) {
|
||||
throw new \UnexpectedValueException($this->l->t('At least one check needs to be provided'));
|
||||
}
|
||||
$instance->validateOperation($name, $checks, $operation);
|
||||
|
||||
foreach ($checks as $check) {
|
||||
if (!is_string($check['class'])) {
|
||||
throw new \UnexpectedValueException($this->l->t('Invalid check provided'));
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var ICheck $instance */
|
||||
$instance = $this->container->query($check['class']);
|
||||
|
|
|
@ -72,7 +72,7 @@ export default {
|
|||
currentOption: null,
|
||||
currentOperator: null,
|
||||
options: [],
|
||||
valid: true,
|
||||
valid: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -107,6 +107,11 @@ export default {
|
|||
this.options = Object.values(this.checks)
|
||||
this.currentOption = this.checks[this.check.class]
|
||||
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: {
|
||||
showDelete() {
|
||||
|
|
|
@ -56,7 +56,21 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
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)
|
||||
},
|
||||
},
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
@input="updateOperation" />
|
||||
</Operation>
|
||||
<div class="buttons">
|
||||
<button v-tooltip="ruleStatus.tooltip"
|
||||
class="status-button icon"
|
||||
<button class="status-button icon"
|
||||
:class="ruleStatus.class"
|
||||
@click="saveRule">
|
||||
{{ ruleStatus.title }}
|
||||
|
@ -43,6 +42,9 @@
|
|||
{{ t('workflowengine', 'Delete') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -84,7 +86,7 @@ export default {
|
|||
return this.$store.getters.getOperationForRule(this.rule)
|
||||
},
|
||||
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 {
|
||||
title: t('workflowengine', 'The configuration is invalid'),
|
||||
class: 'icon-close-white invalid',
|
||||
|
@ -174,12 +176,19 @@ export default {
|
|||
|
||||
.buttons {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
button {
|
||||
float: right;
|
||||
height: 34px;
|
||||
}
|
||||
}
|
||||
|
||||
.error-message {
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.status-button {
|
||||
transition: 0.5s ease all;
|
||||
display: block;
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
:operation="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="actions__item__description">
|
||||
<h3>{{ t('workflowengine', 'More flows') }}</h3>
|
||||
|
@ -49,6 +52,7 @@ import Rule from './Rule'
|
|||
import Operation from './Operation'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
||||
const ACTION_LIMIT = 3
|
||||
|
||||
|
@ -61,7 +65,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
showMoreOperations: false,
|
||||
appstoreUrl: '/index.php/settings/apps/workflow',
|
||||
appstoreUrl: generateUrl('settings/apps/workflow'),
|
||||
scope: loadState('workflowengine', 'scope'),
|
||||
}
|
||||
},
|
||||
|
@ -81,6 +85,9 @@ export default {
|
|||
}
|
||||
return Object.values(this.operations).slice(0, ACTION_LIMIT)
|
||||
},
|
||||
showAppStoreHint() {
|
||||
return this.scope === 0 && OC.isUserAdmin()
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('fetchRules')
|
||||
|
|
|
@ -98,7 +98,9 @@ const store = new Vuex.Store({
|
|||
entity: entity ? entity.id : rule.fixedEntity,
|
||||
events,
|
||||
name: '', // unused in the new ui, there for legacy reasons
|
||||
checks: [],
|
||||
checks: [
|
||||
{ class: null, operator: null, value: '' },
|
||||
],
|
||||
operation: rule.operation || '',
|
||||
})
|
||||
},
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
background-size: 50px 50px;
|
||||
background-position: center center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 10px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.actions__item__description {
|
||||
|
|
Loading…
Reference in New Issue