fix: 修复root组织可以创建的问题

fix: 修复全局组织可以clone的问题
This commit is contained in:
ibuler
2021-03-15 11:40:56 +08:00
committed by Orange
parent 0afc160b56
commit 4b152bf9bf
6 changed files with 49 additions and 60 deletions

View File

@@ -82,7 +82,7 @@ export default {
title: this.$t('common.Create'), title: this.$t('common.Create'),
type: 'primary', type: 'primary',
has: true, has: true,
can: true, can: this.canCreate,
dropdown: [], dropdown: [],
callback: this.handleCreate callback: this.handleCreate
} }

View File

@@ -84,7 +84,9 @@ export default {
canUpdate: true, // can set function(row, value) canUpdate: true, // can set function(row, value)
hasDelete: true, // can set function(row, value) hasDelete: true, // can set function(row, value)
canDelete: true, canDelete: true,
hasClone: true, hasClone: () => {
return !this.$store.getters.currentOrgIsRoot
},
canClone: true, canClone: true,
updateRoute: this.$route.name.replace('List', 'Update'), updateRoute: this.$route.name.replace('List', 'Update'),
cloneRoute: this.$route.name.replace('List', 'Create'), cloneRoute: this.$route.name.replace('List', 'Create'),

View File

@@ -4,7 +4,7 @@
<TreeTable <TreeTable
ref="TreeTable" ref="TreeTable"
:table-config="tableConfig" :table-config="tableConfig"
:header-actions="headerActions" :header-actions="iHeaderActions"
:tree-setting="treeSetting" :tree-setting="treeSetting"
v-on="$listeners" v-on="$listeners"
> >
@@ -39,6 +39,7 @@ export default {
iHeaderActions() { iHeaderActions() {
const attrs = _.cloneDeep(this.headerActions) const attrs = _.cloneDeep(this.headerActions)
const canCreate = _.get(attrs, 'canCreate', null) const canCreate = _.get(attrs, 'canCreate', null)
// this.$log.debug('Current org: ', this.currentOrg)
if (canCreate === null && this.currentOrg && this.currentOrg.is_root) { if (canCreate === null && this.currentOrg && this.currentOrg.is_root) {
_.set(attrs, 'canCreate', false) _.set(attrs, 'canCreate', false)
} }

View File

@@ -16,7 +16,7 @@
import QuickActions from '@/components/QuickActions/index' import QuickActions from '@/components/QuickActions/index'
import ListTable from '@/components/ListTable' import ListTable from '@/components/ListTable'
import RelationCard from '@/components/RelationCard' import RelationCard from '@/components/RelationCard'
import { BooleanFormatter } from '@/components/ListTable/formatters' import { ChoicesFormatter } from '@/components/ListTable/formatters'
export default { export default {
name: 'AssetList', name: 'AssetList',
@@ -44,7 +44,7 @@ export default {
}, },
connectivity: { connectivity: {
label: this.$t('assets.Reachable'), label: this.$t('assets.Reachable'),
formatter: BooleanFormatter, formatter: ChoicesFormatter,
formatterArgs: { formatterArgs: {
iconChoices: { iconChoices: {
0: 'fa-times text-danger', 0: 'fa-times text-danger',

View File

@@ -67,7 +67,7 @@
<script> <script>
import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index' import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index'
import { DetailFormatter, ActionsFormatter, BooleanFormatter } from '@/components/ListTable/formatters' import { DetailFormatter, ActionsFormatter, ChoicesFormatter } from '@/components/ListTable/formatters'
import $ from '@/utils/jquery-vendor' import $ from '@/utils/jquery-vendor'
import Dialog from '@/components/Dialog' import Dialog from '@/components/Dialog'
import TreeTable from '@/components/TreeTable' import TreeTable from '@/components/TreeTable'
@@ -138,7 +138,7 @@ export default {
}, },
connectivity: { connectivity: {
label: this.$t('assets.Reachable'), label: this.$t('assets.Reachable'),
formatter: BooleanFormatter, formatter: ChoicesFormatter,
formatterArgs: { formatterArgs: {
iconChoices: { iconChoices: {
0: 'fa-times text-danger', 0: 'fa-times text-danger',

View File

@@ -67,60 +67,46 @@ export default {
headerActions: { headerActions: {
hasBulkDelete: false, hasBulkDelete: false,
hasImport: false, hasImport: false,
hasCreate: false, hasMoreActions: false,
moreActionsTitle: this.$t('common.Create'), moreCreates: {
moreActionsType: 'primary', callback: (option) => {
extraMoreActions: [ vm.$router.push({ name: 'AccountCreate', query: { provider: option.name }})
{
name: aliyun,
title: ACCOUNT_PROVIDER_ATTRS_MAP[aliyun].title,
type: 'primary',
can: true,
callback: this.createAccount(aliyun).bind(this)
}, },
{ dropdown: [
name: qcloud, {
title: ACCOUNT_PROVIDER_ATTRS_MAP[qcloud].title, name: aliyun,
type: 'primary', title: ACCOUNT_PROVIDER_ATTRS_MAP[aliyun].title,
can: true, type: 'primary',
callback: this.createAccount(qcloud).bind(this) can: true
}, },
{ {
name: aws_china, name: qcloud,
title: ACCOUNT_PROVIDER_ATTRS_MAP[aws_china].title, title: ACCOUNT_PROVIDER_ATTRS_MAP[qcloud].title,
type: 'primary', type: 'primary',
can: true, can: true
callback: this.createAccount(aws_china).bind(this) },
}, {
{ name: aws_china,
name: aws_international, title: ACCOUNT_PROVIDER_ATTRS_MAP[aws_china].title
title: ACCOUNT_PROVIDER_ATTRS_MAP[aws_international].title, },
type: 'primary', {
can: true, name: aws_international,
callback: this.createAccount(aws_international).bind(this) title: ACCOUNT_PROVIDER_ATTRS_MAP[aws_international].title
}, },
{ {
name: huaweicloud, name: huaweicloud,
title: ACCOUNT_PROVIDER_ATTRS_MAP[huaweicloud].title, title: ACCOUNT_PROVIDER_ATTRS_MAP[huaweicloud].title
type: 'primary', },
can: true, {
callback: this.createAccount(huaweicloud).bind(this) name: azure,
}, title: ACCOUNT_PROVIDER_ATTRS_MAP[azure].title
{ },
name: azure, {
title: ACCOUNT_PROVIDER_ATTRS_MAP[azure].title, name: vmware,
type: 'primary', title: ACCOUNT_PROVIDER_ATTRS_MAP[vmware].title
can: true, }
callback: this.createAccount(azure).bind(this) ]
}, }
{
name: vmware,
title: ACCOUNT_PROVIDER_ATTRS_MAP[vmware].title,
type: 'primary',
can: true,
callback: this.createAccount(vmware).bind(this)
}
]
} }
} }
}, },