2024-05-30 14:13:41 -04:00
<!--
- SPDX - FileCopyrightText : 2019 Nextcloud GmbH and Nextcloud contributors
- SPDX - License - Identifier : AGPL - 3.0 - or - later
-- >
2019-08-06 11:40:30 -04:00
< template >
2019-08-28 12:27:37 -04:00
< div id = "workflowengine" >
2023-07-22 20:03:13 -04:00
< NcSettingsSection : name = "t('workflowengine', 'Available flows')"
2022-05-19 12:35:32 -04:00
: doc - url = "workflowDocUrl" >
2023-10-24 09:29:47 -04:00
< p v-if = "isAdminScope" class="settings-hint" >
2019-11-26 09:24:04 -05:00
< a href = "https://nextcloud.com/developer/" > { { t ( 'workflowengine' , 'For details on how to write your own flow, check out the development documentation.' ) } } < / a >
2019-11-19 03:31:46 -05:00
< / p >
2023-10-24 09:29:47 -04:00
< NcEmptyContent v-if = "!isUserAdmin && mainOperations.length === 0"
: name = "t('workflowengine', 'No flows installed')"
: description = "!isUserAdmin ? t('workflowengine', 'Ask your administrator to install new flows.') : undefined" >
< template # icon >
< NcIconSvgWrapper :svg = "WorkflowOffSvg" :size = "20" / >
< / template >
< / NcEmptyContent >
< transition-group v -else
name = "slide"
tag = "div"
class = "actions" >
< Operation v-for = "operation in mainOperations"
2019-09-25 12:19:42 -04:00
: key = "operation.id"
: operation = "operation"
2019-08-29 10:50:33 -04:00
@ click . native = "createNewRule(operation)" / >
2019-12-23 04:31:28 -05:00
< a v-if = "showAppStoreHint"
2023-10-24 09:29:47 -04:00
key = "add"
2019-12-23 04:31:28 -05:00
: href = "appstoreUrl"
class = "actions__item colored more" >
2019-11-14 16:50:33 -05:00
< div class = "icon icon-add" / >
< div class = "actions__item__description" >
2019-11-26 09:24:04 -05:00
< h3 > { { t ( 'workflowengine' , 'More flows' ) } } < / h3 >
2021-05-21 09:45:54 -04:00
< small > { { t ( 'workflowengine' , 'Browse the App Store' ) } } < / small >
2019-11-14 16:50:33 -05:00
< / div >
< / a >
2019-08-28 12:27:37 -04:00
< / transition-group >
2019-08-29 10:50:33 -04:00
< div v-if = "hasMoreOperations" class="actions__more" >
2022-08-22 08:29:58 -04:00
< NcButton @ click = "showMoreOperations = !showMoreOperations" >
2022-06-28 20:29:21 -04:00
< template # icon >
< MenuUp v-if = "showMoreOperations" :size="20" / >
< MenuDown v -else :size = "20" / >
< / template >
2019-08-06 11:40:30 -04:00
{ { showMoreOperations ? t ( 'workflowengine' , 'Show less' ) : t ( 'workflowengine' , 'Show more' ) } }
2022-08-22 08:29:58 -04:00
< / NcButton >
2019-08-06 11:40:30 -04:00
< / div >
2022-08-22 08:29:58 -04:00
< / NcSettingsSection >
2019-08-06 11:40:30 -04:00
2023-10-24 09:29:47 -04:00
< NcSettingsSection v-if = "mainOperations.length > 0"
: name = "isAdminScope ? t('workflowengine', 'Configured flows') : t('workflowengine', 'Your flows')" >
< transition-group v-if = "rules.length > 0" name="slide" >
< Rule v-for = "rule in rules" :key="rule.id" :rule="rule" / >
< / transition-group >
< NcEmptyContent v -else : name = "t('workflowengine', 'No flows configured')" >
< template # icon >
< NcIconSvgWrapper :svg = "WorkflowOffSvg" :size = "20" / >
< / template >
< / NcEmptyContent >
< / NcSettingsSection >
2019-08-06 11:40:30 -04:00
< / div >
< / template >
< script >
2023-03-23 02:38:34 -04:00
import Rule from './Rule.vue'
import Operation from './Operation.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
2023-10-24 09:29:47 -04:00
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
2019-08-29 10:50:33 -04:00
import { mapGetters , mapState } from 'vuex'
2019-12-23 04:31:28 -05:00
import { generateUrl } from '@nextcloud/router'
2022-05-19 12:35:32 -04:00
import { loadState } from '@nextcloud/initial-state'
2023-03-23 02:38:34 -04:00
import MenuUp from 'vue-material-design-icons/MenuUp.vue'
import MenuDown from 'vue-material-design-icons/MenuDown.vue'
2023-10-24 09:29:47 -04:00
import WorkflowOffSvg from '../../img/workflow-off.svg?raw'
2019-08-29 10:50:33 -04:00
const ACTION _LIMIT = 3
2023-10-24 09:29:47 -04:00
const ADMIN _SCOPE = 0
// const PERSONAL_SCOPE = 1
2019-08-29 10:50:33 -04:00
export default {
name : 'Workflow' ,
components : {
2022-06-28 20:29:21 -04:00
MenuDown ,
MenuUp ,
2023-10-24 09:29:47 -04:00
NcButton ,
NcEmptyContent ,
NcIconSvgWrapper ,
NcSettingsSection ,
2019-08-29 10:50:33 -04:00
Operation ,
2019-11-13 07:05:10 -05:00
Rule ,
2019-08-29 10:50:33 -04:00
} ,
data ( ) {
return {
2019-11-14 16:50:33 -05:00
showMoreOperations : false ,
2019-12-23 04:31:28 -05:00
appstoreUrl : generateUrl ( 'settings/apps/workflow' ) ,
2022-05-19 12:35:32 -04:00
workflowDocUrl : loadState ( 'workflowengine' , 'doc-url' ) ,
2023-10-24 09:29:47 -04:00
WorkflowOffSvg ,
2019-08-29 10:50:33 -04:00
}
} ,
computed : {
... mapGetters ( {
2019-11-13 07:05:10 -05:00
rules : 'getRules' ,
2019-08-29 10:50:33 -04:00
} ) ,
... mapState ( {
2020-03-15 12:32:50 -04:00
appstoreEnabled : 'appstoreEnabled' ,
scope : 'scope' ,
2019-11-13 07:05:10 -05:00
operations : 'operations' ,
2019-08-29 10:50:33 -04:00
} ) ,
hasMoreOperations ( ) {
return Object . keys ( this . operations ) . length > ACTION _LIMIT
2019-08-06 11:40:30 -04:00
} ,
2023-10-24 09:29:47 -04:00
mainOperations ( ) {
2019-08-29 10:50:33 -04:00
if ( this . showMoreOperations ) {
return Object . values ( this . operations )
2019-08-06 11:40:30 -04:00
}
2019-08-29 10:50:33 -04:00
return Object . values ( this . operations ) . slice ( 0 , ACTION _LIMIT )
2019-11-13 07:05:10 -05:00
} ,
2019-12-23 04:31:28 -05:00
showAppStoreHint ( ) {
2023-10-24 09:29:47 -04:00
return this . appstoreEnabled && OC . isUserAdmin ( )
} ,
isUserAdmin ( ) {
return OC . isUserAdmin ( )
} ,
isAdminScope ( ) {
return this . scope === ADMIN _SCOPE
2019-12-23 04:31:28 -05:00
} ,
2019-08-29 10:50:33 -04:00
} ,
mounted ( ) {
this . $store . dispatch ( 'fetchRules' )
} ,
methods : {
createNewRule ( operation ) {
this . $store . dispatch ( 'createNewRule' , operation )
2019-11-13 07:05:10 -05:00
} ,
} ,
2019-08-29 10:50:33 -04:00
}
2019-08-06 11:40:30 -04:00
< / script >
< style scoped lang = "scss" >
2019-08-28 12:27:37 -04:00
# workflowengine {
border - bottom : 1 px solid var ( -- color - border ) ;
}
2019-08-19 11:13:33 -04:00
. section {
max - width : 100 vw ;
2019-11-14 16:50:33 -05:00
h2 . configured - flows {
2019-11-26 09:24:04 -05:00
margin - top : 50 px ;
2019-11-14 16:50:33 -05:00
margin - bottom : 0 ;
}
2019-08-19 11:13:33 -04:00
}
2019-08-06 11:40:30 -04:00
. actions {
display : flex ;
2019-08-19 11:13:33 -04:00
flex - wrap : wrap ;
2019-12-19 07:11:01 -05:00
max - width : 1200 px ;
2019-08-19 11:13:33 -04:00
. actions _ _item {
2019-09-09 07:53:03 -04:00
max - width : 280 px ;
2019-08-28 12:27:37 -04:00
flex - basis : 250 px ;
2019-08-06 11:40:30 -04:00
}
}
2022-06-28 20:29:21 -04:00
. actions _ _more {
margin - bottom : 10 px ;
2019-08-06 11:40:30 -04:00
}
. slide - enter - active {
- moz - transition - duration : 0.3 s ;
- webkit - transition - duration : 0.3 s ;
- o - transition - duration : 0.3 s ;
transition - duration : 0.3 s ;
- moz - transition - timing - function : ease - in ;
- webkit - transition - timing - function : ease - in ;
- o - transition - timing - function : ease - in ;
transition - timing - function : ease - in ;
}
. slide - leave - active {
- moz - transition - duration : 0.3 s ;
- webkit - transition - duration : 0.3 s ;
- o - transition - duration : 0.3 s ;
transition - duration : 0.3 s ;
- moz - transition - timing - function : cubic - bezier ( 0 , 1 , 0.5 , 1 ) ;
- webkit - transition - timing - function : cubic - bezier ( 0 , 1 , 0.5 , 1 ) ;
- o - transition - timing - function : cubic - bezier ( 0 , 1 , 0.5 , 1 ) ;
transition - timing - function : cubic - bezier ( 0 , 1 , 0.5 , 1 ) ;
}
. slide - enter - to , . slide - leave {
max - height : 500 px ;
overflow : hidden ;
}
. slide - enter , . slide - leave - to {
overflow : hidden ;
max - height : 0 ;
2019-08-28 12:27:37 -04:00
padding - top : 0 ;
padding - bottom : 0 ;
2019-08-06 11:40:30 -04:00
}
2019-11-14 16:50:33 -05:00
@ import "./../styles/operation" ;
. actions _ _item . more {
background - color : var ( -- color - background - dark ) ;
}
2019-08-19 11:13:33 -04:00
< / style >