Skip to content

Commit 5b18099

Browse files
committed
fix(workflowengine): Add an empty content when no flows are installed or configured
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 970ac3d commit 5b18099

File tree

4 files changed

+51
-23
lines changed

4 files changed

+51
-23
lines changed
Lines changed: 4 additions & 0 deletions
Loading

apps/workflowengine/src/components/Workflow.vue

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22
<div id="workflowengine">
33
<NcSettingsSection :name="t('workflowengine', 'Available flows')"
44
:doc-url="workflowDocUrl">
5-
<p v-if="scope === 0" class="settings-hint">
5+
<p v-if="isAdminScope" class="settings-hint">
66
<a href="https://nextcloud.com/developer/">{{ t('workflowengine', 'For details on how to write your own flow, check out the development documentation.') }}</a>
77
</p>
88

9-
<transition-group name="slide" tag="div" class="actions">
10-
<Operation v-for="operation in getMainOperations"
9+
<NcEmptyContent v-if="!isUserAdmin && mainOperations.length === 0"
10+
:name="t('workflowengine', 'No flows installed')"
11+
:description="!isUserAdmin ? t('workflowengine', 'Ask your administrator to install new flows.') : undefined">
12+
<template #icon>
13+
<NcIconSvgWrapper :svg="WorkflowOffSvg" :size="20" />
14+
</template>
15+
</NcEmptyContent>
16+
<transition-group v-else
17+
name="slide"
18+
tag="div"
19+
class="actions">
20+
<Operation v-for="operation in mainOperations"
1121
:key="operation.id"
1222
:operation="operation"
1323
@click.native="createNewRule(operation)" />
14-
1524
<a v-if="showAppStoreHint"
16-
:key="'add'"
25+
key="add"
1726
:href="appstoreUrl"
1827
class="actions__item colored more">
1928
<div class="icon icon-add" />
@@ -33,49 +42,58 @@
3342
{{ showMoreOperations ? t('workflowengine', 'Show less') : t('workflowengine', 'Show more') }}
3443
</NcButton>
3544
</div>
36-
37-
<h2 v-if="scope === 0" class="configured-flows">
38-
{{ t('workflowengine', 'Configured flows') }}
39-
</h2>
40-
<h2 v-else class="configured-flows">
41-
{{ t('workflowengine', 'Your flows') }}
42-
</h2>
4345
</NcSettingsSection>
4446

45-
<transition-group v-if="rules.length > 0" name="slide">
46-
<Rule v-for="rule in rules" :key="rule.id" :rule="rule" />
47-
</transition-group>
47+
<NcSettingsSection v-if="mainOperations.length > 0"
48+
:name="isAdminScope ? t('workflowengine', 'Configured flows') : t('workflowengine', 'Your flows')">
49+
<transition-group v-if="rules.length > 0" name="slide">
50+
<Rule v-for="rule in rules" :key="rule.id" :rule="rule" />
51+
</transition-group>
52+
<NcEmptyContent v-else :name="t('workflowengine', 'No flows configured')">
53+
<template #icon>
54+
<NcIconSvgWrapper :svg="WorkflowOffSvg" :size="20" />
55+
</template>
56+
</NcEmptyContent>
57+
</NcSettingsSection>
4858
</div>
4959
</template>
5060

5161
<script>
5262
import Rule from './Rule.vue'
5363
import Operation from './Operation.vue'
54-
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
5564
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
65+
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
66+
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
67+
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
5668
import { mapGetters, mapState } from 'vuex'
5769
import { generateUrl } from '@nextcloud/router'
5870
import { loadState } from '@nextcloud/initial-state'
5971
import MenuUp from 'vue-material-design-icons/MenuUp.vue'
6072
import MenuDown from 'vue-material-design-icons/MenuDown.vue'
73+
import WorkflowOffSvg from '../../img/workflow-off.svg?raw'
6174
6275
const ACTION_LIMIT = 3
76+
const ADMIN_SCOPE = 0
77+
// const PERSONAL_SCOPE = 1
6378
6479
export default {
6580
name: 'Workflow',
6681
components: {
67-
NcButton,
6882
MenuDown,
6983
MenuUp,
84+
NcButton,
85+
NcEmptyContent,
86+
NcIconSvgWrapper,
87+
NcSettingsSection,
7088
Operation,
7189
Rule,
72-
NcSettingsSection,
7390
},
7491
data() {
7592
return {
7693
showMoreOperations: false,
7794
appstoreUrl: generateUrl('settings/apps/workflow'),
7895
workflowDocUrl: loadState('workflowengine', 'doc-url'),
96+
WorkflowOffSvg,
7997
}
8098
},
8199
computed: {
@@ -90,14 +108,20 @@ export default {
90108
hasMoreOperations() {
91109
return Object.keys(this.operations).length > ACTION_LIMIT
92110
},
93-
getMainOperations() {
111+
mainOperations() {
94112
if (this.showMoreOperations) {
95113
return Object.values(this.operations)
96114
}
97115
return Object.values(this.operations).slice(0, ACTION_LIMIT)
98116
},
99117
showAppStoreHint() {
100-
return this.scope === 0 && this.appstoreEnabled && OC.isUserAdmin()
118+
return this.appstoreEnabled && OC.isUserAdmin()
119+
},
120+
isUserAdmin() {
121+
return OC.isUserAdmin()
122+
},
123+
isAdminScope() {
124+
return this.scope === ADMIN_SCOPE
101125
},
102126
},
103127
mounted() {

dist/workflowengine-workflowengine.js

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

dist/workflowengine-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.

0 commit comments

Comments
 (0)