Skip to content

Commit

Permalink
fix(ui): missing check permission to display flow CREATE and EXECUTE …
Browse files Browse the repository at this point in the history
…button

When a user didn't have FLOW CREATE permission, the 'Create' buton will disapear from the Dashboard and the Flows pages.
When a user didn't have EXECUTION CREATE permission, the 'Execute' button will disapear from the Flow detail and Execution detail pages.
  • Loading branch information
loicmathieu authored and Skraye committed Mar 4, 2024
1 parent 2e18c87 commit 87f7cde
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/flows/FlowEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</li>

<li>
<router-link v-if="flow" :to="{name: 'flows/create', query: {copy: true}}">
<router-link v-if="flow && canCreate" :to="{name: 'flows/create', query: {copy: true}}">
<el-button :icon="icon.ContentCopy" size="large">
{{ $t('copy') }}
</el-button>
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/flows/Flows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</router-link>
</li>
<li>
<router-link :to="{name: 'flows/create'}">
<router-link :to="{name: 'flows/create'}" v-if="canCreate">
<el-button :icon="Plus" type="primary">
{{ $t('create') }}
</el-button>
Expand Down Expand Up @@ -290,6 +290,9 @@
canCheck() {
return this.canRead || this.canDelete || this.canUpdate;
},
canCreate() {
return this.user && this.user.isAllowed(permission.FLOW, action.CREATE, this.$route.query.namespace);
},
canRead() {
return this.user && this.user.isAllowed(permission.FLOW, action.READ, this.$route.query.namespace);
},
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/home/Home.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<top-nav-bar v-if="!embed" :title="routeInfo.title">
<template #additional-right>
<template #additional-right v-if="canCreate">
<ul>
<li>
<router-link :to="{name: 'flows/create'}">
Expand Down Expand Up @@ -333,6 +333,9 @@
title: this.$t("homeDashboard.title"),
};
},
canCreate() {
return this.user.isAllowedGlobal(permission.FLOW, action.CREATE)
},
defaultFilters() {
return {
startDate: this.$moment(this.startDate).toISOString(true),
Expand Down
3 changes: 3 additions & 0 deletions ui/src/mixins/flowTemplateEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default {
canSave() {
return canSaveFlowTemplate(true, this.user, this.item, this.dataType);
},
canCreate() {
return this.dataType === "flow" && this.user.isAllowed(permission.FLOW, action.CREATE, this.item.namespace)
},
canExecute() {
return this.dataType === "flow" && this.user.isAllowed(permission.EXECUTION, action.CREATE, this.item.namespace)
},
Expand Down

0 comments on commit 87f7cde

Please sign in to comment.