| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- import { mapGetters } from 'vuex'
- import i18n from '@/locales'
- import {
- getSetPublicAction,
- } from '@/utils/common/tableActions'
- export default {
- computed: mapGetters(['isAdminMode', 'l3PermissionEnable']),
- created () {
- this.singleActions = [
- {
- label: i18n.t('system.text_152'),
- permission: 'policies_update',
- action: obj => {
- this.$router.push({
- path: '/policy/update',
- query: {
- policyName: obj.type,
- id: obj.id,
- },
- })
- },
- meta: (obj) => {
- const ret = {
- validate: true,
- }
- const ownerDomain = this.$store.getters.isAdminMode || obj.domain_id === this.$store.getters.userInfo.projectDomainId
- if (!ownerDomain) {
- ret.validate = false
- return ret
- }
- if (obj.is_system) {
- ret.validate = false
- ret.tooltip = this.$t('policy.tooltip.system_policy')
- return ret
- }
- return ret
- },
- },
- {
- label: i18n.t('system.text_153'),
- actions: obj => {
- return [
- {
- label: i18n.t('system.text_225'),
- permission: 'policies_update',
- action: () => {
- this.createDialog('DisableDialog', {
- title: i18n.t('system.text_342', [i18n.t('dictionary.policy')]),
- name: this.$t('dictionary.policy'),
- columns: this.columns,
- data: [obj],
- ok: async () => {
- try {
- const response = await this.onManager('performAction', {
- id: obj.id,
- managerArgs: {
- action: 'enable',
- },
- })
- return response
- } catch (error) {
- throw error
- }
- },
- })
- },
- meta: () => {
- return {
- validate: !obj.enabled && this.isOwnerPublic(obj),
- }
- },
- },
- {
- label: i18n.t('system.text_226'),
- permission: 'policies_update',
- action: () => {
- this.createDialog('DisableDialog', {
- alert: i18n.t('system.text_434'),
- title: i18n.t('system.text_341', [i18n.t('dictionary.policy')]),
- name: this.$t('dictionary.policy'),
- columns: this.columns,
- data: [obj],
- ok: async () => {
- try {
- const response = await this.onManager('performAction', {
- id: obj.id,
- managerArgs: {
- action: 'disable',
- },
- })
- return response
- } catch (error) {
- throw error
- }
- },
- })
- },
- meta: () => {
- return {
- validate: obj.enabled && this.isOwnerPublic(obj),
- }
- },
- },
- {
- label: this.$t('table.action.clone'),
- permission: 'policies_create',
- action: () => {
- this.createDialog('PolicyCloneDialog', {
- data: [obj],
- columns: this.columns,
- success: () => {
- this.refresh()
- },
- })
- },
- },
- // {
- // label: i18n.t('system.text_435'),
- // action: () => {
- // this.onManager('performAction', {
- // id: obj.id,
- // managerArgs: {
- // action: 'public',
- // },
- // })
- // },
- // meta: () => {
- // const ret = {
- // validate: false,
- // }
- // if (!this.isAdminMode || !this.l3PermissionEnable) {
- // return ret
- // }
- // if (obj.is_system) {
- // ret.tooltip = this.$t('policy.tooltip.system_policy')
- // return ret
- // }
- // ret.validate = !obj.is_public && this.isOwnerPublic(obj)
- // return ret
- // },
- // },
- // {
- // label: i18n.t('system.text_436'),
- // action: () => {
- // this.onManager('performAction', {
- // id: obj.id,
- // managerArgs: {
- // action: 'private',
- // },
- // })
- // },
- // meta: () => {
- // const ret = {
- // validate: false,
- // }
- // if (!this.isAdminMode || !this.l3PermissionEnable) {
- // return ret
- // }
- // if (obj.is_system) {
- // ret.tooltip = this.$t('policy.tooltip.system_policy')
- // return ret
- // }
- // ret.validate = obj.is_public && this.isOwnerPublic(obj)
- // return ret
- // },
- // },
- getSetPublicAction(this, {
- name: this.$t('res.policy'),
- scope: 'domain',
- resource: 'policies',
- apiVersion: 'v1',
- noCandidateDomains: true,
- }, {
- meta: row => {
- const ret = {
- validate: false,
- }
- if (obj.is_system) {
- ret.tooltip = this.$t('policy.tooltip.system_policy')
- return ret
- }
- },
- }),
- {
- label: i18n.t('system.text_129'),
- permission: 'policies_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: [obj],
- columns: this.columns,
- title: i18n.t('system.text_129'),
- onManager: this.onManager,
- name: this.$t('dictionary.policy'),
- })
- },
- meta: () => this.$getDeleteResult(obj),
- },
- ]
- },
- },
- ]
- },
- }
|