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'),
type: 'primary',
has: true,
can: true,
can: this.canCreate,
dropdown: [],
callback: this.handleCreate
}

View File

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

View File

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

View File

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

View File

@@ -67,7 +67,7 @@
<script>
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 Dialog from '@/components/Dialog'
import TreeTable from '@/components/TreeTable'
@@ -138,7 +138,7 @@ export default {
},
connectivity: {
label: this.$t('assets.Reachable'),
formatter: BooleanFormatter,
formatter: ChoicesFormatter,
formatterArgs: {
iconChoices: {
0: 'fa-times text-danger',

View File

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