diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-05-30 14:29:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 14:29:21 +0200 |
commit | cc7e6e5e4c1204cdf92d5ae5a665f75d04d39abb (patch) | |
tree | 7989f1fd2c68d040b9f10ad18b0efb1d93116b51 /apps/workflowengine/src | |
parent | 1470a7294ba1778b2cbe6486f87d8658cd12d558 (diff) | |
parent | 31b0a44cf65b6625636ea0fa15fb1a1122b525e1 (diff) | |
download | nextcloud-server-cc7e6e5e4c1204cdf92d5ae5a665f75d04d39abb.tar.gz nextcloud-server-cc7e6e5e4c1204cdf92d5ae5a665f75d04d39abb.zip |
Merge branch 'master' into refactor/OC-Server-getCsrfTokenManager
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'apps/workflowengine/src')
-rw-r--r-- | apps/workflowengine/src/components/Checks/RequestUserGroup.vue | 21 | ||||
-rw-r--r-- | apps/workflowengine/src/components/Checks/request.js | 2 | ||||
-rw-r--r-- | apps/workflowengine/src/components/Workflow.vue | 64 | ||||
-rw-r--r-- | apps/workflowengine/src/store.js | 7 |
4 files changed, 63 insertions, 31 deletions
diff --git a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue index 2b248153aa6..ee774b7939f 100644 --- a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue +++ b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue @@ -22,21 +22,26 @@ <template> <div> - <NcSelect :value="currentValue" + <NcSelect :aria-label-combobox="t('workflowengine', 'Select groups')" + :aria-label-listbox="t('workflowengine', 'Groups')" + :clearable="false" :loading="status.isLoading && groups.length === 0" + :placeholder="t('workflowengine', 'Type to search for group …')" :options="groups" - :clearable="false" + :value="currentValue" label="displayname" - @search-change="searchAsync" + @search="searchAsync" @input="(value) => $emit('input', value.id)" /> </div> </template> <script> -import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' -import axios from '@nextcloud/axios' +import { translate as t } from '@nextcloud/l10n' import { generateOcsUrl } from '@nextcloud/router' +import axios from '@nextcloud/axios' +import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' + const groups = [] const status = { isLoading: false, @@ -69,14 +74,18 @@ export default { }, }, async mounted() { + // If empty, load first chunk of groups if (this.groups.length === 0) { await this.searchAsync('') } - if (this.currentValue === null) { + // If a current group is set but not in our list of groups then search for that group + if (this.currentValue === null && this.value) { await this.searchAsync(this.value) } }, methods: { + t, + searchAsync(searchQuery) { if (this.status.isLoading) { return diff --git a/apps/workflowengine/src/components/Checks/request.js b/apps/workflowengine/src/components/Checks/request.js index 9f33bac6676..e04ed1b9c93 100644 --- a/apps/workflowengine/src/components/Checks/request.js +++ b/apps/workflowengine/src/components/Checks/request.js @@ -59,7 +59,7 @@ const RequestChecks = [ }, { class: 'OCA\\WorkflowEngine\\Check\\UserGroupMembership', - name: t('workflowengine', 'User group membership'), + name: t('workflowengine', 'Group membership'), operators: [ { operator: 'is', name: t('workflowengine', 'is member of') }, { operator: '!is', name: t('workflowengine', 'is not member of') }, diff --git a/apps/workflowengine/src/components/Workflow.vue b/apps/workflowengine/src/components/Workflow.vue index 96d633ee60d..342e7113251 100644 --- a/apps/workflowengine/src/components/Workflow.vue +++ b/apps/workflowengine/src/components/Workflow.vue @@ -2,18 +2,27 @@ <div id="workflowengine"> <NcSettingsSection :name="t('workflowengine', 'Available flows')" :doc-url="workflowDocUrl"> - <p v-if="scope === 0" class="settings-hint"> + <p v-if="isAdminScope" class="settings-hint"> <a href="https://nextcloud.com/developer/">{{ t('workflowengine', 'For details on how to write your own flow, check out the development documentation.') }}</a> </p> - <transition-group name="slide" tag="div" class="actions"> - <Operation v-for="operation in getMainOperations" + <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" :key="operation.id" :operation="operation" @click.native="createNewRule(operation)" /> - <a v-if="showAppStoreHint" - :key="'add'" + key="add" :href="appstoreUrl" class="actions__item colored more"> <div class="icon icon-add" /> @@ -33,49 +42,58 @@ {{ showMoreOperations ? t('workflowengine', 'Show less') : t('workflowengine', 'Show more') }} </NcButton> </div> - - <h2 v-if="scope === 0" class="configured-flows"> - {{ t('workflowengine', 'Configured flows') }} - </h2> - <h2 v-else class="configured-flows"> - {{ t('workflowengine', 'Your flows') }} - </h2> </NcSettingsSection> - <transition-group v-if="rules.length > 0" name="slide"> - <Rule v-for="rule in rules" :key="rule.id" :rule="rule" /> - </transition-group> + <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> </div> </template> <script> import Rule from './Rule.vue' import Operation from './Operation.vue' -import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' +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' import { mapGetters, mapState } from 'vuex' import { generateUrl } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' import MenuUp from 'vue-material-design-icons/MenuUp.vue' import MenuDown from 'vue-material-design-icons/MenuDown.vue' +import WorkflowOffSvg from '../../img/workflow-off.svg?raw' const ACTION_LIMIT = 3 +const ADMIN_SCOPE = 0 +// const PERSONAL_SCOPE = 1 export default { name: 'Workflow', components: { - NcButton, MenuDown, MenuUp, + NcButton, + NcEmptyContent, + NcIconSvgWrapper, + NcSettingsSection, Operation, Rule, - NcSettingsSection, }, data() { return { showMoreOperations: false, appstoreUrl: generateUrl('settings/apps/workflow'), workflowDocUrl: loadState('workflowengine', 'doc-url'), + WorkflowOffSvg, } }, computed: { @@ -90,14 +108,20 @@ export default { hasMoreOperations() { return Object.keys(this.operations).length > ACTION_LIMIT }, - getMainOperations() { + mainOperations() { if (this.showMoreOperations) { return Object.values(this.operations) } return Object.values(this.operations).slice(0, ACTION_LIMIT) }, showAppStoreHint() { - return this.scope === 0 && this.appstoreEnabled && OC.isUserAdmin() + return this.appstoreEnabled && OC.isUserAdmin() + }, + isUserAdmin() { + return OC.isUserAdmin() + }, + isAdminScope() { + return this.scope === ADMIN_SCOPE }, }, mounted() { diff --git a/apps/workflowengine/src/store.js b/apps/workflowengine/src/store.js index 49c881e67b6..6f8905687cf 100644 --- a/apps/workflowengine/src/store.js +++ b/apps/workflowengine/src/store.js @@ -89,7 +89,8 @@ const store = new Store({ context.commit('addRule', rule) }) }, - createNewRule(context, rule) { + async createNewRule(context, rule) { + await confirmPassword() let entity = null let events = [] if (rule.isComplex === false && rule.fixedEntity === '') { @@ -120,9 +121,7 @@ const store = new Store({ context.commit('removeRule', rule) }, async pushUpdateRule(context, rule) { - if (context.state.scope === 0) { - await confirmPassword() - } + await confirmPassword() let result if (rule.id < 0) { result = await axios.post(getApiUrl(''), rule) |