| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { mapGetters } from 'vuex'
- import { getEnabledSwitchActions, getSetPublicAction } from '@/utils/common/tableActions'
- export default {
- created () {
- this.singleActions = [
- {
- label: this.$t('table.action.modify'),
- permission: 'robots_update',
- action: (row) => {
- this.createDialog('CreateRobotDialog', {
- data: row,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: (row) => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- },
- {
- label: this.$t('system.text_153'),
- actions: (row) => {
- return [
- getSetPublicAction(this, {
- name: this.$t('system.robot'),
- scope: 'project',
- resource: 'robots',
- apiVersion: 'v1',
- }, {
- permission: 'robots_perform_public',
- meta: (row) => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- // if (row.public_scope !== 'none') {
- // ret.validate = false
- // ret.tooltip = this.$t('system.robot.shared')
- // return ret
- // }
- return ret
- },
- }),
- {
- label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
- permission: 'robots_perform_change_owner',
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- data: [row],
- columns: this.columns,
- onManager: this.onManager,
- name: this.$t('system.robot'),
- resource: 'robots',
- apiVersion: 'v1',
- })
- },
- meta: () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- },
- ...getEnabledSwitchActions(this, row, ['robots_perform_enable', 'robots_perform_disable'], {
- resourceName: this.$t('system.robot'),
- metas: [
- () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return ret
- },
- ],
- }),
- {
- label: this.$t('system.text_129'),
- permission: 'robots_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: [row],
- columns: this.columns,
- title: this.$t('system.text_129'),
- name: this.$t('system.robot'),
- onManager: this.onManager,
- })
- },
- meta: () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isPower(row)) {
- ret.validate = false
- ret.tooltip = this.$t('system.robot.shared')
- return ret
- }
- return this.$getDeleteResult(row)
- },
- },
- ]
- },
- },
- ]
- },
- computed: {
- ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
- },
- methods: {
- isPower (obj) {
- if (this.isAdminMode) return true
- if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
- return obj.tenant_id === this.userInfo.projectId
- },
- },
- }
|