Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def get_workspace_role(self):
Operate.TRIGGER_CREATE.value: _('Create Trigger'),
Operate.TRIGGER_EDIT.value: _('Edit Trigger'),
Operate.TRIGGER_DELETE.value: _('Delete Trigger'),
Operate.RECORD.value: _('Execute record'),

Group.APPLICATION_OVERVIEW.value: _('Overview'),
Group.APPLICATION_ACCESS.value: _('Application Access'),
Expand Down
1 change: 1 addition & 0 deletions ui/src/utils/permission/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const PermissionConst = {
TRIGGER_CREATE: new Permission('TRIGGER:READ+CREATE'),
TRIGGER_EDIT: new Permission('TRIGGER:READ+EDIT'),
TRIGGER_DELETE: new Permission('TRIGGER:READ+DELETE'),
TRIGGER_RECORD: new Permission('TRIGGER:READ+RECORD'),

KNOWLEDGE_READ: new Permission('KNOWLEDGE:READ'),
KNOWLEDGE_CREATE: new Permission('KNOWLEDGE:READ+CREATE'),
Expand Down
27 changes: 26 additions & 1 deletion ui/src/views/trigger/component/TriggerDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
<ToolDialog @refresh="toolRefresh" ref="toolDialogRef"></ToolDialog>
<template #footer>
<el-button @click="close">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submit">{{
<el-button v-if="submitPermission" type="primary" @click="submit">{{
is_edit ? $t('common.save') : $t('common.create')
}}</el-button>
</template>
Expand All @@ -480,6 +480,8 @@ import { resetUrl } from '@/utils/common.ts'
import { t } from '@/locales'
import { type FormInstance } from 'element-plus'
import Result from '@/request/Result'
import { hasPermission } from '@/utils/permission'
import { PermissionConst, RoleConst } from '@/utils/permission/data'

const emit = defineEmits(['refresh'])
const props = withDefaults(
Expand All @@ -501,6 +503,29 @@ const collapseData = reactive({
})
const showTast = ref<string>('')

const submitPermission = computed(() => {
return is_edit.value ? triggerPermissionMap.edit() : triggerPermissionMap.create()
})

const triggerPermissionMap = {
edit: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_EDIT.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
create: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_CREATE.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
}

const triggerFormRef = ref<FormInstance>()
const copy = () => {
copyClick(event_url.value)
Expand Down
73 changes: 66 additions & 7 deletions ui/src/views/trigger/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@
<div class="p-24">
<div class="flex-between">
<div>
<el-button type="primary" @click="openCreateTriggerDrawer"
<el-button
v-if="triggerPermissionMap.create()"
type="primary"
@click="openCreateTriggerDrawer"
>{{ $t('common.create') }}
</el-button>
<el-button @click="batchChangeState(true)" :disabled="multipleSelection.length === 0"
<el-button
v-if="triggerPermissionMap.edit()"
@click="batchChangeState(true)"
:disabled="multipleSelection.length === 0"
>{{ $t('common.status.enable') }}
</el-button>
<el-button @click="batchChangeState(false)" :disabled="multipleSelection.length === 0"
<el-button
v-if="triggerPermissionMap.edit()"
@click="batchChangeState(false)"
:disabled="multipleSelection.length === 0"
>{{ $t('common.status.disable') }}
</el-button>
<el-button @click="batchDelete" :disabled="multipleSelection.length === 0"
<el-button
v-if="triggerPermissionMap.delete()"
@click="batchDelete"
:disabled="multipleSelection.length === 0"
>{{ $t('common.delete') }}
</el-button>
</div>
Expand Down Expand Up @@ -243,7 +255,7 @@
</el-table-column>
<el-table-column align="left" width="160" fixed="right" :label="$t('common.operation')">
<template #default="{ row }">
<span @click.stop>
<span v-if="triggerPermissionMap.edit()" @click.stop>
<el-switch
:before-change="() => changeState(row)"
:loading="loading"
Expand All @@ -259,15 +271,25 @@
</el-button>
</span>
</el-tooltip>
<el-tooltip effect="dark" :content="$t('workflow.ExecutionRecord')" placement="top">
<el-tooltip
v-if="triggerPermissionMap.record()"
effect="dark"
:content="$t('workflow.ExecutionRecord')"
placement="top"
>
<span class="mr-4">
<el-button type="primary" text @click="openExecutionRecordDrawer(row)">
<AppIcon iconName="app-schedule-report"></AppIcon>
</el-button>
</span>
</el-tooltip>

<el-tooltip effect="dark" :content="$t('common.delete')" placement="top">
<el-tooltip
v-if="triggerPermissionMap.delete()"
effect="dark"
:content="$t('common.delete')"
placement="top"
>
<span class="mr-4">
<el-button type="primary" text @click="deleteTrigger(row)">
<AppIcon iconName="app-delete"></AppIcon>
Expand Down Expand Up @@ -301,6 +323,8 @@ import { resetUrl } from '@/utils/common'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import type { TriggerData } from '@/api/type/trigger'
import TriggerDrawer from '@/views/trigger/component/TriggerDrawer.vue'
import { hasPermission } from '@/utils/permission'
import { PermissionConst, RoleConst } from '@/utils/permission/data'

const { user } = useStore()

Expand Down Expand Up @@ -407,6 +431,41 @@ function batchDelete() {
})
}

const triggerPermissionMap = {
edit: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_EDIT.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
create: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_CREATE.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
delete: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_DELETE.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
record: () =>
hasPermission(
[
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.TRIGGER_RECORD.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
}

async function changeState(row: any) {
const obj = {
is_active: !row.is_active,
Expand Down