| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import { mapGetters } from 'vuex'
- import { getSetPublicAction } from '@/utils/common/tableActions'
- import i18n from '@/locales'
- export default {
- computed: {
- ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
- },
- created () {
- const validateAction = function (obj) {
- if (obj.is_guest_image === true || obj.is_guest_image === 'true') {
- return false
- }
- return true
- }
- const validateActionTooltip = function (obj) {
- if (obj.is_guest_image === true || obj.is_guest_image === 'true') {
- return i18n.t('compute.text_622')
- }
- return ''
- }
- const ownerDomain = obj => this.$store.getters.isAdminMode || obj.domain_id === this.$store.getters.userInfo.projectDomainId
- const isOwnerProject = project => project === this.$store.getters.userInfo.projectId || project === this.$store.getters.userInfo.projectName
- this.singleActions = [
- {
- label: i18n.t('compute.text_247'),
- permission: 'guestimages_update',
- action: obj => {
- this.createDialog('ImageEditAttributesDialog', {
- data: [obj],
- columns: this.columns,
- refresh: this.refresh,
- })
- },
- meta: obj => {
- if (!validateAction(obj)) {
- return {
- validate: false,
- tooltip: validateActionTooltip(obj),
- }
- }
- if (this.isAdminMode) {
- return {
- validate: true,
- }
- } else if (this.isDomainMode) {
- return {
- validate: ownerDomain(obj),
- tooltip: i18n.t('compute.text_623', [i18n.t('dictionary.domain')]),
- }
- }
- return {
- validate: isOwnerProject(obj.tenant_id),
- tooltip: !isOwnerProject(obj.tenant_id) ? i18n.t('compute.text_623', [i18n.t('dictionary.domain')]) : '',
- }
- },
- },
- {
- label: i18n.t('compute.text_352'),
- actions: obj => {
- return [
- getSetPublicAction(this, {
- name: this.$t('dictionary.guestimage'),
- scope: 'project',
- resource: 'guestimages',
- apiVersion: 'v1',
- }, {
- permission: 'images_perform_public,guestimages_perform_private',
- meta: () => {
- function validate (val, tooltip = validateActionTooltip(obj)) {
- return {
- validate: val,
- tooltip,
- }
- }
- if (obj.is_standard) validate(false, i18n.t('compute.text_612'))
- if (!validateAction(obj)) validate(false)
- // 1、管理后台视图可以对所有镜像进行操作;
- // 2、域管理后台视图只能对该域下的镜像进行操作,不能对其他域共享的镜像进行操作;
- // 3、项目视图只能对该项目下的镜像进行操作,不能对其他域、其他项目共享的镜像进行操作。
- if (this.isAdminMode) validate(true)
- if (!this.isAdminMode && !this.isDomainAdmin) validate(this.userInfo.projectId === obj.tenant_id)
- if (this.isDomainMode) validate(this.userInfo.projectDomainId === obj.domain_id)
- return {
- validate: true,
- }
- },
- }),
- // {
- // label: '设置共享',
- // permission: 'images_perform_public',
- // action: () => {
- // this.createDialog('SetPublicDialog', {
- // data: [obj],
- // columns: this.columns,
- // onManager: this.onManager,
- // refresh: this.refresh,
- // })
- // },
- // meta: () => {
- // function validate (val, tooltip = validateActionTooltip(obj)) {
- // return {
- // validate: val,
- // tooltip,
- // }
- // }
- // if (obj.is_standard) validate(false, '公共镜像不支持设置')
- // if (!validateAction(obj)) validate(false)
- // // 1、管理后台视图可以对所有镜像进行操作;
- // // 2、域管理后台视图只能对该域下的镜像进行操作,不能对其他域共享的镜像进行操作;
- // // 3、项目视图只能对该项目下的镜像进行操作,不能对其他域、其他项目共享的镜像进行操作。
- // if (this.isAdminMode) validate(true)
- // if (!this.isAdminMode && !this.isDomainAdmin) validate(this.userInfo.projectId === obj.tenant_id)
- // if (this.isDomainMode) validate(this.userInfo.projectDomainId === obj.domain_id)
- // return {
- // validate: true,
- // }
- // },
- // },
- {
- label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
- permission: 'guestimages_perform_change_owner',
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- name: this.$t('dictionary.guestimage'),
- resource: 'guestimages',
- apiVersion: 'v1',
- })
- },
- meta: () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- if (!this.isAdminMode && !this.isDomainMode) {
- ret.validate = false
- ret.tooltip = i18n.t('compute.text_613')
- return ret
- }
- if (obj.is_public) {
- ret.validate = false
- ret.tooltip = i18n.t('compute.text_614')
- return ret
- }
- return ret
- },
- },
- {
- label: i18n.t('common_277'),
- permission: 'guestimages_update',
- action: (row) => {
- this.createDialog('ChangeDisableDelete', {
- name: this.$t('dictionary.guestimage'),
- columns: this.columns,
- onManager: this.onManager,
- data: [row],
- })
- },
- },
- {
- label: i18n.t('compute.perform_delete'),
- permission: 'guestimages_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: [obj],
- columns: this.columns,
- title: i18n.t('compute.perform_delete'),
- name: this.$t('dictionary.guestimage'),
- onManager: this.onManager,
- alert: this.$t('compute.text_1393'),
- requestData: {
- override_pending_delete: true,
- },
- })
- },
- meta: () => {
- if (this.isDomainAdmin && obj.domain_id !== this.userInfo.projectDomainId) {
- return {
- validate: false,
- tooltip: i18n.t('compute.text_625', [i18n.t('dictionary.domain')]),
- }
- }
- if (!validateAction(obj)) return { validate: false, tooltip: validateActionTooltip(obj) }
- return this.$getDeleteResult(obj)
- },
- },
- ]
- },
- },
- ]
- },
- }
|