Skip to content

Commit 64bfd4b

Browse files
authored
Merge pull request #17506 from nextcloud/bugfix/12790/workflow-frontend
Workflow frontend polishing
2 parents e517ca0 + 3f97025 commit 64bfd4b

File tree

25 files changed

+301
-277
lines changed

25 files changed

+301
-277
lines changed

apps/workflowengine/appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
],
2626
'ocs-resources' => [
2727
'global_workflows' => ['url' => '/api/v1/workflows/global'],
28+
'user_workflows' => ['url' => '/api/v1/workflows/user'],
2829
],
2930
];

apps/workflowengine/css/admin.scss

Lines changed: 0 additions & 86 deletions
This file was deleted.

apps/workflowengine/css/multiselect.css

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/workflowengine/js/workflowengine.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/workflowengine/js/workflowengine.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/workflowengine/lib/Controller/UserWorkflowsController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ public function show(string $id): DataResponse {
7979
* @throws OCSBadRequestException
8080
* @throws OCSForbiddenException
8181
*/
82-
public function create(string $class, string $name, array $checks, string $operation): DataResponse {
83-
return parent::create($class, $name, $checks, $operation);
82+
public function create(string $class, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
83+
return parent::create($class, $name, $checks, $operation, $entity, $events);
8484
}
8585

8686
/**
8787
* @NoAdminRequired
8888
* @throws OCSBadRequestException
8989
* @throws OCSForbiddenException
9090
*/
91-
public function update(int $id, string $name, array $checks, string $operation): DataResponse {
92-
return parent::update($id, $name, $checks, $operation);
91+
public function update(int $id, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
92+
return parent::update($id, $name, $checks, $operation, $entity, $events);
9393
}
9494

9595
/**

apps/workflowengine/lib/Manager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ public function formatOperation(array $operation): array {
561561

562562
$operation['checks'][] = $check;
563563
}
564+
$operation['events'] = json_decode($operation['events'], true);
565+
564566

565567
return $operation;
566568
}

apps/workflowengine/lib/Service/RuleMatcher.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424

2525
namespace OCA\WorkflowEngine\Service;
2626

27-
use OCA\WorkflowEngine\AppInfo\Application;
28-
use OCA\WorkflowEngine\Entity\File;
2927
use OCA\WorkflowEngine\Helper\ScopeContext;
3028
use OCA\WorkflowEngine\Manager;
3129
use OCP\AppFramework\QueryException;
32-
use OCP\Files\Node;
3330
use OCP\Files\Storage\IStorage;
3431
use OCP\IL10N;
3532
use OCP\IServerContainer;
@@ -128,7 +125,7 @@ public function check(array $check) {
128125
list($entity, $subject) = $entityInfo;
129126
$checkInstance->setEntitySubject($entity, $subject);
130127
}
131-
} else {
128+
} else if(!$checkInstance instanceof ICheck) {
132129
// Check is invalid
133130
throw new \UnexpectedValueException($this->l->t('Check %s is invalid or does not exist', $check['class']));
134131
}

apps/workflowengine/src/components/Check.vue

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Multiselect v-model="currentOperator"
1212
:disabled="!currentOption"
1313
:options="operators"
14+
class="comparator"
1415
label="name"
1516
track-by="operator"
1617
:allow-empty="false"
@@ -21,6 +22,7 @@
2122
v-model="check.value"
2223
:disabled="!currentOption"
2324
:check="check"
25+
class="option"
2426
@input="updateCheck"
2527
@valid="(valid=true) && validate()"
2628
@invalid="(valid=false) && validate()" />
@@ -30,9 +32,10 @@
3032
:class="{ invalid: !valid }"
3133
:disabled="!currentOption"
3234
:placeholder="valuePlaceholder"
35+
class="option"
3336
@input="updateCheck">
3437
<Actions v-if="deleteVisible || !currentOption">
35-
<ActionButton icon="icon-delete" @click="$emit('remove')" />
38+
<ActionButton icon="icon-close" @click="$emit('remove')" />
3639
</Actions>
3740
</div>
3841
</template>
@@ -73,17 +76,16 @@ export default {
7376
}
7477
},
7578
computed: {
76-
Checks() {
79+
checks() {
7780
return this.$store.getters.getChecksForEntity(this.rule.entity)
7881
},
7982
operators() {
8083
if (!this.currentOption) { return [] }
81-
return this.Checks[this.currentOption.class].operators
84+
return this.checks[this.currentOption.class].operators
8285
},
8386
currentComponent() {
8487
if (!this.currentOption) { return [] }
85-
const currentComponent = this.Checks[this.currentOption.class].component
86-
return currentComponent
88+
return this.checks[this.currentOption.class].component
8789
},
8890
valuePlaceholder() {
8991
if (this.currentOption && this.currentOption.placeholder) {
@@ -98,8 +100,8 @@ export default {
98100
}
99101
},
100102
mounted() {
101-
this.options = Object.values(this.Checks)
102-
this.currentOption = this.Checks[this.check.class]
103+
this.options = Object.values(this.checks)
104+
this.currentOption = this.checks[this.check.class]
103105
this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator)
104106
},
105107
methods: {
@@ -111,13 +113,8 @@ export default {
111113
},
112114
validate() {
113115
if (this.currentOption && this.currentOption.validate) {
114-
if (this.currentOption.validate(this.check)) {
115-
this.valid = true
116-
} else {
117-
this.valid = false
118-
}
116+
this.valid = !!this.currentOption.validate(this.check)
119117
}
120-
this.$store.dispatch('setValid', { rule: this.rule, valid: this.rule.valid && this.valid })
121118
return this.valid
122119
},
123120
updateCheck() {
@@ -128,7 +125,7 @@ export default {
128125
this.check.operator = this.currentOperator.operator
129126
130127
if (!this.validate()) {
131-
return
128+
this.check.invalid = !this.valid
132129
}
133130
this.$emit('update', this.check)
134131
}
@@ -142,29 +139,43 @@ export default {
142139
flex-wrap: wrap;
143140
width: 100%;
144141
padding-right: 20px;
145-
& > *:not(.icon-delete) {
142+
& > *:not(.close) {
146143
width: 180px;
147144
}
145+
& > .comparator {
146+
min-width: 130px;
147+
width: 130px;
148+
}
149+
& > .option {
150+
min-width: 230px;
151+
width: 230px;
152+
}
148153
& > .multiselect,
149154
& > input[type=text] {
150155
margin-right: 5px;
151156
margin-bottom: 5px;
152157
}
158+
159+
.multiselect::v-deep .multiselect__content-wrapper li>span,
160+
.multiselect::v-deep .multiselect__single {
161+
display: block;
162+
white-space: nowrap;
163+
overflow: hidden;
164+
text-overflow: ellipsis;
165+
}
153166
}
154167
input[type=text] {
155168
margin: 0;
156169
}
157170
::placeholder {
158171
font-size: 10px;
159172
}
160-
.icon-delete {
173+
button.action-item.action-item--single.icon-close {
174+
height: 44px;
175+
width: 44px;
161176
margin-top: -5px;
162177
margin-bottom: -5px;
163178
}
164-
button.action-item.action-item--single.icon-delete {
165-
height: 34px;
166-
width: 34px;
167-
}
168179
.invalid {
169180
border: 1px solid var(--color-error) !important;
170181
}

apps/workflowengine/src/components/Checks/FileMimeType.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@
3232
:tagging="false"
3333
@input="setValue">
3434
<template slot="singleLabel" slot-scope="props">
35-
<span class="option__icon" :class="props.option.icon" />
35+
<span v-if="props.option.icon" class="option__icon" :class="props.option.icon" />
36+
<img v-else :src="props.option.iconUrl">
3637
<span class="option__title option__title_single">{{ props.option.label }}</span>
3738
</template>
3839
<template slot="option" slot-scope="props">
39-
<span class="option__icon" :class="props.option.icon" />
40+
<span v-if="props.option.icon" class="option__icon" :class="props.option.icon" />
41+
<img v-else :src="props.option.iconUrl">
4042
<span class="option__title">{{ props.option.label }}</span>
4143
</template>
4244
</Multiselect>
4345
<input v-if="!isPredefined"
4446
type="text"
4547
:value="currentValue.pattern"
48+
:placeholder="t('workflowengine', 'e.g. httpd/unix-directory')"
4649
@input="updateCustom">
4750
</div>
4851
</template>
@@ -68,12 +71,12 @@ export default {
6871
pattern: '/image\\/.*/'
6972
},
7073
{
71-
icon: 'icon-category-office',
74+
iconUrl: OC.imagePath('core', 'filetypes/x-office-document'),
7275
label: t('workflowengine', 'Office documents'),
7376
pattern: '/(vnd\\.(ms-|openxmlformats-).*))$/'
7477
},
7578
{
76-
icon: 'icon-filetype-file',
79+
iconUrl: OC.imagePath('core', 'filetypes/application-pdf'),
7780
label: t('workflowengine', 'PDF documents'),
7881
pattern: 'application/pdf'
7982
}
@@ -130,3 +133,15 @@ export default {
130133
}
131134
}
132135
</script>
136+
<style scoped>
137+
.multiselect, input[type='text'] {
138+
width: 100%;
139+
}
140+
.multiselect >>> .multiselect__content-wrapper li>span,
141+
.multiselect >>> .multiselect__single {
142+
display: flex;
143+
white-space: nowrap;
144+
overflow: hidden;
145+
text-overflow: ellipsis;
146+
}
147+
</style>

0 commit comments

Comments
 (0)