| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- import { mapGetters } from 'vuex'
- import { getSetPublicAction } from '@/utils/common/tableActions'
- import i18n from '@/locales'
- // import { exportDataOptions } from '../utils'
- export default {
- computed: {
- ...mapGetters(['isAdminMode', 'isDomainMode', 'isProjectMode', 'userInfo']),
- },
- created () {
- this.singleActions = [
- // {
- // label: `关联${this.$t('dictionary.server')}`,
- // permission: 'server_perform_assign_secgroup',
- // action: (obj) => {
- // this.createDialog('SetServerDialog', {
- // data: [obj],
- // columns: this.columns,
- // title: `关联${this.$t('dictionary.server')}`,
- // onManager: this.onManager,
- // refresh: this.refresh,
- // })
- // },
- // },
- {
- label: i18n.t('compute.text_1027'),
- permission: 'secgrouprules_list',
- action: (obj) => {
- this.sidePageTriggerHandle(this, 'SecGroupSidePage', {
- id: obj.id,
- resource: 'secgroups',
- }, { tab: 'in-direction' })
- },
- },
- {
- label: i18n.t('compute.text_352'),
- actions: obj => {
- return [
- // {
- // label: '设置为私有',
- // permission: 'secgroups_create',
- // action: () => {
- // this.onManager('performAction', {
- // id: obj.id,
- // managerArgs: {
- // action: 'private',
- // },
- // })
- // },
- // meta: () => {
- // if (this.$store.getters.isAdminMode || this.$store.getters.isDomainMode) {
- // if (this.isPower(obj)) {
- // return {
- // validate: obj.is_public,
- // }
- // }
- // }
- // return {
- // validate: false,
- // }
- // },
- // },
- // {
- // label: '设置为共享',
- // permission: 'secgroups_create',
- // action: () => {
- // this.createDialog('SetPublicDialog', {
- // data: [obj],
- // title: '设置为共享',
- // columns: this.columns,
- // onManager: this.onManager,
- // refresh: this.refresh,
- // })
- // },
- // meta: () => {
- // if (this.$store.getters.isAdminMode || this.$store.getters.isDomainMode) {
- // if (this.isPower(obj)) {
- // return {
- // validate: !obj.is_public,
- // }
- // }
- // }
- // return {
- // validate: false,
- // }
- // },
- // },
- {
- label: i18n.t('compute.perform_sync_status'),
- permission: 'secgroups_perform_sync_status',
- action: () => {
- this.onManager('performAction', {
- steadyStatus: ['ready', 'delete_failed'],
- id: obj.id,
- managerArgs: {
- action: 'syncstatus',
- },
- })
- },
- },
- {
- label: i18n.t('compute.text_1028_1'),
- permission: 'servers_list',
- action: (obj) => {
- this.sidePageTriggerHandle(this, 'SecGroupSidePage', {
- id: obj.id,
- resource: 'secgroups',
- }, { tab: 'associated-instances' })
- },
- hidden: () => this.hiddenActions.includes('openSecgroupSidepageTab'),
- },
- // {
- // label: i18n.t('compute.text_983'),
- // permission: 'secgroups_perform_clone',
- // action: () => {
- // this.createDialog('CloneSecgroupDialog', {
- // data: [obj],
- // columns: this.columns,
- // title: i18n.t('compute.text_983'),
- // onManager: this.onManager,
- // refresh: this.refresh,
- // })
- // },
- // meta: () => {
- // const isPrivate = !obj.is_public
- // return {
- // validate: this.isPower(obj),
- // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
- // }
- // },
- // },
- // {
- // label: i18n.t('compute.import_secgroup_rule', []),
- // permission: 'secgroups_perform_import_rules',
- // action: () => {
- // this.createDialog('ImportSecgroupRuleDialog', {
- // data: [obj],
- // exportDataOptions,
- // onManager: this.onManager,
- // refresh: this.refresh,
- // a: 1,
- // })
- // },
- // meta: () => {
- // const isPrivate = !obj.is_public
- // return {
- // validate: this.isPower(obj),
- // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
- // }
- // },
- // },
- // {
- // label: i18n.t('compute.text_1012'),
- // permission: 'secgroups_perform_merge',
- // action: () => {
- // this.createDialog('ConcatSecgroupDialog', {
- // data: [obj],
- // columns: this.columns,
- // title: i18n.t('compute.text_1012'),
- // onManager: this.onManager,
- // refresh: this.refresh,
- // })
- // },
- // meta: () => {
- // const isPrivate = !obj.is_public
- // return {
- // validate: this.isPower(obj),
- // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
- // }
- // },
- // },
- {
- label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
- permission: 'secgroups_create',
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.secgroup'),
- resource: 'secgroups',
- })
- },
- meta: () => {
- if (!this.isProjectMode) {
- const isPower = this.isPower(obj)
- const isPrivate = !obj.is_public
- return {
- validate: isPower && isPrivate,
- tooltip: isPower && !isPrivate ? i18n.t('compute.secgroup.shared') : '',
- }
- }
- return {
- tooltip: i18n.t('compute.text_1336'),
- validate: false,
- }
- },
- },
- getSetPublicAction(this, {
- name: this.$t('dictionary.secgroup'),
- scope: 'project',
- resource: 'secgroups',
- }, {
- permission: 'secgroups_perform_public',
- }),
- {
- label: i18n.t('compute.perform_delete'),
- permission: 'secgroups_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: [obj],
- alert: this.$t('compute.text_1395'),
- columns: this.columns,
- title: i18n.t('compute.perform_delete'),
- name: this.$t('dictionary.secgroup'),
- onManager: this.onManager,
- })
- },
- meta: () => this.$getDeleteResult(obj),
- },
- ]
- },
- },
- ]
- },
- methods: {
- isPower (obj) {
- if (!obj.domain_id && obj.data.domain_id) {
- obj = obj.data
- }
- if (this.isAdminMode) return true
- if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
- return obj.tenant_id === this.userInfo.projectId
- },
- },
- }
|