| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- import { disableDeleteAction } from '@/utils/common/tableActions'
- import { checkSecgroup } from '@DB/views/utils'
- import { HYPERVISORS_MAP } from '@/constants'
- import i18n from '@/locales'
- export default {
- created () {
- this.singleActions = [
- {
- label: i18n.t('db.text_69'),
- permission: 'redis_elasticcaches_perform_sync',
- action: (obj) => {
- this.onManager('performAction', {
- id: obj.id,
- steadyStatus: 'running',
- managerArgs: {
- action: 'Sync',
- },
- })
- },
- },
- {
- label: i18n.t('db.text_155'),
- actions: (obj) => {
- const { provider, status } = obj
- const isRunning = status.toLowerCase() === 'running'
- const notRunninTip = !isRunning ? i18n.t('db.text_156') : null
- const isAuthModeOn = obj.auth_mode === 'on'
- const setAuthMode = () => {
- if (!isAuthModeOn && obj.brand !== 'Huawei') {
- return {
- label: i18n.t('db.text_304'),
- permission: 'redis_elasticcaches_perform_reset_password',
- action: () => {
- this.createDialog('RedisUpdateAuthModeDialog', {
- title: i18n.t('db.text_304'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- let validate = true
- let tooltip = ''
- if (!isRunning) {
- validate = false
- tooltip = notRunninTip
- } else if (obj.brand === 'Qcloud' && obj.network_type !== 'vpc') {
- validate = false
- tooltip = i18n.t('db.text_354')
- } else if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && validate) {
- validate = false
- tooltip = i18n.t('db.text_384', [obj.brand])
- }
- return {
- validate,
- tooltip,
- }
- },
- }
- }
- return {
- label: i18n.t('db.text_305'),
- permission: 'redis_elasticcaches_perform_update_auth_mode',
- action: () => {
- this.createDialog('RedisUpdateAuthModeDialog', {
- title: i18n.t('db.text_305'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- let validate = true
- let tooltip = ''
- if (!isRunning) {
- validate = false
- tooltip = notRunninTip
- } else if (obj.brand === 'Huawei') {
- validate = false
- tooltip = i18n.t('db.text_306')
- } else if (obj.brand === 'Qcloud' && obj.network_type !== 'vpc') {
- validate = false
- tooltip = i18n.t('db.text_354')
- } else if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && validate) {
- validate = false
- tooltip = i18n.t('db.text_384', [obj.brand])
- }
- return {
- validate,
- tooltip,
- }
- },
- }
- }
- return [
- {
- label: i18n.t('db.text_70'),
- permission: 'redis_elasticcaches_perform_restart',
- action: () => {
- this.createDialog('RedisRestartdialog', {
- title: i18n.t('db.text_70'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- const ret = {
- validate: isRunning && obj.brand !== 'Qcloud',
- tooltip: notRunninTip || (obj.brand === 'Qcloud' ? i18n.t('db.text_358') : ''),
- }
- // aws 和 azure禁用
- if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
- ret.validate = false
- ret.tooltip = this.$t('db.text_384', [obj.brand])
- }
- return ret
- },
- },
- {
- label: i18n.t('db.text_159'),
- permission: 'redis_elasticcaches_perform_change_spec',
- action: () => {
- this.createDialog('RedisSetConfigDialog', {
- title: i18n.t('db.text_159'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- const isPrepaid = obj.billing_type === 'prepaid'
- // 腾讯云暂不支持调整配置
- const isQcloud = obj.brand.toLowerCase() === 'qcloud'
- const ret = {
- validate: isRunning && !isPrepaid && !isQcloud,
- tooltip: notRunninTip || (isPrepaid ? i18n.t('db.text_307') : '') || (isQcloud ? i18n.t('db.text_352') : ''),
- }
- // aws 和 azure, hcs禁用
- if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand || obj.brand === HYPERVISORS_MAP.hcs.brand) && ret.validate) {
- ret.validate = false
- ret.tooltip = this.$t('db.text_384', [obj.brand])
- }
- return ret
- },
- },
- {
- label: i18n.t('db.text_239'),
- permission: 'redis_elasticcaches_perform_flush_instance',
- action: () => {
- this.createDialog('RedisClearDataDialog', {
- title: i18n.t('db.text_239'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- const ret = {
- validate: isRunning,
- tooltip: notRunninTip,
- }
- // aws 和 azure禁用
- if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
- ret.validate = false
- ret.tooltip = this.$t('db.text_384', [obj.brand])
- }
- return ret
- },
- },
- {
- label: provider === 'Huawei' ? i18n.t('db.text_308') : i18n.t('db.text_201'),
- permission: 'redis_elasticcaches_perform_reset_password',
- action: () => {
- this.createDialog('RedisResetPassworddialog', {
- title: provider === 'Huawei' ? i18n.t('db.text_308') : i18n.t('db.text_201'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- const ret = {
- validate: isRunning,
- tooltip: notRunninTip,
- }
- // aws 和 azure禁用
- if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
- ret.validate = false
- ret.tooltip = this.$t('db.text_384', [obj.brand])
- }
- return ret
- },
- },
- {
- label: i18n.t('db.text_160', [i18n.t('dictionary.project')]),
- permission: 'redis_elasticcaches_perform_change_owner',
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- title: i18n.t('db.text_160', [i18n.t('dictionary.project')]),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- resource: 'elasticcaches',
- })
- },
- },
- {
- label: this.$t('compute.text_1116'),
- permission: 'server_perform_add_secgroup',
- action: () => {
- this.createDialog('SetSecgroupDialog', {
- vm: this,
- data: [obj],
- name: this.$t('dictionary.elasticcache'),
- resource: 'elasticcache_id',
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const ret = checkSecgroup(obj, 'redis', ['Qcloud'])
- // aws 和 azure禁用
- if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
- ret.validate = false
- ret.tooltip = this.$t('db.text_384', [obj.brand])
- }
- return ret
- },
- },
- setAuthMode(),
- {
- label: i18n.t('db.text_71'),
- permission: 'redis_elasticcaches_perform_postpaid_expire',
- action: () => {
- this.createDialog('SetDurationDialog', {
- data: [obj],
- columns: this.columns,
- alert: this.$t('db.text_393'),
- onManager: this.onManager,
- refresh: this.refresh,
- name: this.$t('dictionary.elasticcaches'),
- })
- },
- meta: () => {
- const ret = {
- validate: false,
- tooltip: null,
- }
- if (obj.billing_type === 'prepaid') {
- ret.tooltip = i18n.t('db.text_72')
- return ret
- }
- ret.validate = true
- return ret
- },
- },
- {
- label: i18n.t('db.text_157'),
- permission: 'redis_elasticcaches_perform_renew',
- action: () => {
- this.createDialog('RedisRenewDialog', {
- title: i18n.t('db.text_157'),
- name: this.$t('dictionary.elasticcaches'),
- data: [obj],
- alert: this.$t('network.text_765'),
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const isPrepaid = obj.billing_type === 'prepaid'
- const validate = (isRunning && isPrepaid)
- return {
- validate: validate,
- tooltip: notRunninTip || (!isPrepaid ? i18n.t('db.text_158') : null),
- }
- },
- },
- {
- label: i18n.t('db.text_351'),
- permission: 'redis_elasticcaches_perform_set_auto_renew',
- action: () => {
- this.createDialog('AutoRenewDialog', {
- name: i18n.t('dictionary.elasticcaches'),
- data: [obj],
- alert: this.$t('network.text_766'),
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const isPrepaid = obj.billing_type === 'prepaid'
- const validate = (isRunning && isPrepaid)
- return {
- validate: validate,
- tooltip: notRunninTip || (!isPrepaid ? i18n.t('db.text_158') : null),
- }
- },
- },
- disableDeleteAction(Object.assign(this, { permission: 'redis_elasticcaches_update' }), {
- name: this.$t('dictionary.elasticcaches'),
- }),
- {
- label: i18n.t('db.text_42'),
- permission: 'redis_elasticcaches_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- title: i18n.t('db.text_42'),
- name: this.$t('dictionary.elasticcaches'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => this.$getDeleteResult(obj),
- },
- ]
- },
- },
- ]
- },
- }
|