mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-05 00:40:29 +00:00
feat: Add permission checks for platform editing
This commit is contained in:
parent
320613d15d
commit
23fae59411
@ -122,7 +122,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onCanSetting() {
|
onCanSetting() {
|
||||||
const filterField = Object.keys(this.remoteMeta)
|
const filterField = Object.keys(this.remoteMeta)
|
||||||
this.canSetting = filterField.includes(this.method)
|
this.canSetting = filterField.includes(this.method) && this.$hasPerm('assets.change_platform')
|
||||||
this.$emit('canSetting', this.canSetting)
|
this.$emit('canSetting', this.canSetting)
|
||||||
return this.canSetting
|
return this.canSetting
|
||||||
},
|
},
|
||||||
|
@ -27,6 +27,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const canEdit = !this.object['internal'] && this.$hasPerm('assets.change_platform')
|
||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
initial: {
|
initial: {
|
||||||
@ -35,14 +36,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
url: `/api/v1/assets/platforms/`,
|
url: `/api/v1/assets/platforms/`,
|
||||||
disabled: this.object.internal,
|
disabled: !canEdit,
|
||||||
hasReset: false,
|
hasReset: false,
|
||||||
hasDetailInMsg: false,
|
hasDetailInMsg: false,
|
||||||
submitMethod: () => 'patch',
|
submitMethod: () => 'patch',
|
||||||
fields: [['', ['automation']]],
|
fields: [['', ['automation']]],
|
||||||
fieldsMeta: platformFieldsMeta(this),
|
fieldsMeta: platformFieldsMeta(this),
|
||||||
onSubmit: this.submit,
|
onSubmit: this.submit,
|
||||||
canSubmit: !this.object.internal,
|
canSubmit: canEdit,
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
afterGetFormValue: (obj) => {
|
afterGetFormValue: (obj) => {
|
||||||
updateAutomationParams(this, obj)
|
updateAutomationParams(this, obj)
|
||||||
@ -65,7 +66,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit(validValues) {
|
submit(validValues) {
|
||||||
if (!this.$hasPerm('assets.change_platform') || !this.isSystemAdmin) {
|
if (!this.canSubmit || !this.isSystemAdmin) {
|
||||||
return this.$message.error(this.$tc('NoPermission'))
|
return this.$message.error(this.$tc('NoPermission'))
|
||||||
}
|
}
|
||||||
this.$axios.patch(`${this.url}${this.object.id}/`, validValues).then(() => {
|
this.$axios.patch(`${this.url}${this.object.id}/`, validValues).then(() => {
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
v-if="protocolChoices"
|
v-if="protocolChoices"
|
||||||
v-model="object.protocols"
|
v-model="object.protocols"
|
||||||
:choices="protocolChoices"
|
:choices="protocolChoices"
|
||||||
:readonly="object['internal']"
|
:readonly="!canEdit"
|
||||||
/>
|
/>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="!object.internal"
|
v-if="canEdit"
|
||||||
size="small"
|
size="small"
|
||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -71,7 +71,8 @@ export default {
|
|||||||
],
|
],
|
||||||
|
|
||||||
protocolChoices: null,
|
protocolChoices: null,
|
||||||
constraints: {}
|
constraints: {},
|
||||||
|
canEdit: !this.object['internal'] && this.$hasPerm('assets.change_platform')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
@ -103,7 +104,7 @@ export default {
|
|||||||
attrs: {
|
attrs: {
|
||||||
label: this.$t('Update'),
|
label: this.$t('Update'),
|
||||||
model: object['domain_enabled'],
|
model: object['domain_enabled'],
|
||||||
disabled: object['internal'] || this.constraints['domain_enabled'] === false
|
disabled: !this.canEdit || this.constraints['domain_enabled'] === false
|
||||||
},
|
},
|
||||||
callbacks: Object.freeze({
|
callbacks: Object.freeze({
|
||||||
change: (val) => {
|
change: (val) => {
|
||||||
@ -120,7 +121,7 @@ export default {
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
attrs: {
|
attrs: {
|
||||||
model: object['su_enabled'],
|
model: object['su_enabled'],
|
||||||
disabled: object['internal'] || this.constraints['su_enabled'] === false
|
disabled: !this.canEdit || this.constraints['su_enabled'] === false
|
||||||
},
|
},
|
||||||
callbacks: Object.freeze({
|
callbacks: Object.freeze({
|
||||||
change: (val) => {
|
change: (val) => {
|
||||||
@ -136,7 +137,8 @@ export default {
|
|||||||
title: this.$t('SyncProtocolToAsset'),
|
title: this.$t('SyncProtocolToAsset'),
|
||||||
attrs: {
|
attrs: {
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
label: this.$t('Sync')
|
label: this.$t('Sync'),
|
||||||
|
disabled: !this.canEdit
|
||||||
},
|
},
|
||||||
callbacks: Object.freeze({
|
callbacks: Object.freeze({
|
||||||
click: () => {
|
click: () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user