Perf: Remove isPam item

This commit is contained in:
zhaojisen
2025-01-20 11:05:48 +08:00
committed by ZhaoJiSen
parent 14c3b249a7
commit 58bb69c252
4 changed files with 66 additions and 47 deletions

View File

@@ -6,8 +6,6 @@ import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSettin
export const accountFieldsMeta = (vm) => {
const defaultPrivilegedAccounts = ['root', 'administrator']
const isPam = vm.$route.query.flag === 'copy' || vm.$route.query.flag === 'move'
return {
assets: {
component: Select2,
@@ -30,7 +28,9 @@ export const accountFieldsMeta = (vm) => {
component: Select2,
rules: [Required],
el: {
disabled: isPam,
get disabled() {
return vm.isDisabled
},
multiple: false,
ajax: {
url: '/api/v1/accounts/account-templates/',
@@ -48,7 +48,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('AccountPolicy'),
helpTip: vm.$t('AccountPolicyHelpText'),
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.platform || vm.asset
@@ -58,7 +60,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('Name'),
rules: [RequiredChange],
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
on: {
input: ([value], updateForm) => {
@@ -79,7 +83,9 @@ export const accountFieldsMeta = (vm) => {
},
username: {
el: {
disabled: !!vm.account?.name || isPam
get disabled() {
return !!vm.account?.name || vm.isDisabled
}
},
on: {
input: ([value], updateForm) => {
@@ -99,7 +105,9 @@ export const accountFieldsMeta = (vm) => {
privileged: {
label: vm.$t('Privileged'),
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.addTemplate
@@ -113,7 +121,11 @@ export const accountFieldsMeta = (vm) => {
el: {
multiple: false,
clearable: true,
disabled: isPam,
disabled: {
get disabled() {
return vm.isDisabled
}
},
ajax: {
url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`,
transformOption: (item) => {
@@ -124,7 +136,11 @@ export const accountFieldsMeta = (vm) => {
},
su_from_username: {
label: vm.$t('UserSwitchFrom'),
disabled: isPam,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => {
return vm.platform || vm.asset || vm.addTemplate
}
@@ -133,7 +149,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('Password'),
component: UpdateToken,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => {
return formValue.secret_type !== 'password' || vm.addTemplate
@@ -143,7 +161,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('PrivateKey'),
component: UploadSecret,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
@@ -151,7 +171,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('Passphrase'),
component: UpdateToken,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
@@ -159,7 +181,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('Token'),
component: UploadSecret,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'token' || vm.addTemplate
},
@@ -168,7 +192,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('AccessKey'),
component: UploadSecret,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'access_key' || vm.addTemplate
},
@@ -177,7 +203,9 @@ export const accountFieldsMeta = (vm) => {
label: vm.$t('ApiKey'),
component: UploadSecret,
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'api_key' || vm.addTemplate
},
@@ -185,7 +213,9 @@ export const accountFieldsMeta = (vm) => {
type: 'radio-group',
options: [],
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.addTemplate
@@ -223,19 +253,25 @@ export const accountFieldsMeta = (vm) => {
is_active: {
label: vm.$t('IsActive'),
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
}
},
comment: {
label: vm.$t('Comment'),
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
}
},
secret_reset: {
label: vm.$t('SecretReset'),
el: {
disabled: isPam
get disabled() {
return vm.isDisabled
}
}
}
}

View File

@@ -45,6 +45,7 @@ export default {
data() {
return {
loading: true,
isDisabled: false,
usernameChanged: false,
submitBtnText: this.$t('Confirm'),
iPlatform: {
@@ -74,6 +75,16 @@ export default {
hasSaveContinue: false
}
},
watch: {
'$route.query': {
handler(nv, ov) {
if (nv && (nv.flag === 'move' || nv.flag === 'copy')) {
this.isDisabled = true
}
},
immediate: true
}
},
async mounted() {
try {
await this.getPlatform()

View File

@@ -99,7 +99,3 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -96,8 +96,6 @@ export default {
data() {
const vm = this
return {
showDrawer: false,
dynamicTemplateComponent: null,
defaultMoreActions: [
{
title: this.$t('DeleteSelected'),
@@ -226,20 +224,9 @@ export default {
const { href } = this.$router.resolve(route)
window.open(href, '_blank')
} else {
if (route.isPam) {
this.showDrawer = true
this.dynamicTemplateComponent = route.name
return
}
this.$router.push(route)
}
},
handleCloseDrawer() {
this.showDrawer = false
this.dynamicTemplateComponent = null
},
defaultBulkDeleteCallback({ selectedRows, reloadTable }) {
const msg = this.$t('DeleteWarningMsg') + ' ' + selectedRows.length + ' ' + this.$t('Rows') + ' ?'
const title = this.$tc('Info')
@@ -280,15 +267,4 @@ export default {
</script>
<style lang="scss" scoped>
::v-deep .ibox {
height: 100% !important;
margin: unset !important;
border: unset !important;
.el-card__body {
padding-top: unset !important;
padding-bottom: unset !important;
height: 100% !important;
}
}
</style>