Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions apps/workflowengine/js/workflowengine.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/workflowengine/js/workflowengine.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions apps/workflowengine/lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,16 @@ public function validateOperation($class, $name, array $checks, $operation, stri

$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']);
Expand Down
7 changes: 6 additions & 1 deletion apps/workflowengine/src/components/Check.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
currentOption: null,
currentOperator: null,
options: [],
valid: true,
valid: false,
}
},
computed: {
Expand Down Expand Up @@ -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() {
Expand Down
16 changes: 15 additions & 1 deletion apps/workflowengine/src/components/Event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down
15 changes: 12 additions & 3 deletions apps/workflowengine/src/components/Rule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -43,6 +42,9 @@
{{ t('workflowengine', 'Delete') }}
</button>
</div>
<p v-if="error" class="error-message">
{{ error }}
</p>
</div>
</div>
</template>
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions apps/workflowengine/src/components/Workflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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

Expand All @@ -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'),
}
},
Expand All @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion apps/workflowengine/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '',
})
},
Expand Down
2 changes: 1 addition & 1 deletion apps/workflowengine/src/styles/operation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down