Skip to content

Commit

Permalink
Updare cred form logic
Browse files Browse the repository at this point in the history
Signed-off-by: nurRiyad <asadnurriyad@gmail.com>
  • Loading branch information
nurRiyad committed Oct 8, 2024
1 parent 6642f9a commit c8bf3b9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/forms/cred-form/create-ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
{
"type": "select",
"label": "Credential Type",
"schema": "schema/properties/type"
"schema": "schema/properties/type",
"disable": "isUpdateForm",
"init": { "type": "func", "value": "setCredentialType" }
},
{
"type": "input",
"label": "Credential Name",
"schema": "schema/properties/name"
"schema": "schema/properties/name",
"disable": "isUpdateForm"
},
{
"type": "block-layout",
Expand Down Expand Up @@ -127,7 +130,8 @@
{
"type": "input",
"label": "Rancher Managed Cluster End Point",
"schema": "schema/properties/rancher/properties/endpoint"
"schema": "schema/properties/rancher/properties/endpoint",
"disable": "isUpdateForm"
},
{
"type": "input",
Expand Down
44 changes: 43 additions & 1 deletion src/forms/cred-form/function.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useRoute } from 'vue-router'

export function useFunc(model) {
const isCredType = ({ params }) => {
const type = params[1] || ''
Expand All @@ -6,5 +8,45 @@ export function useFunc(model) {
else return false
}

return { isCredType }
const isUpdateForm = () => {
const route = useRoute()
return route.path.split('/').pop() === 'edit'
}

function setCredentialType() {
const credList = [
{
provider: 'eks',
credType: 'Aws'
},
{
provider: 'aks',
credType: 'Azure'
},
{
provider: 'gke',
credType: 'GoogleCloud'
},
{
provider: 'digitalocean',
credType: 'DigitalOcean'
},
{
provider: 'linode',
credType: 'Linode'
},
{
provider: 'rancher',
credType: 'Rancher'
}
]
const route = useRoute()
const { query } = route || {}
const { provider } = query || {}
const cred = credList.find((el) => el.provider === provider)
if (cred) return cred.credType
else return ''
}

return { isCredType, isUpdateForm, setCredentialType }
}

0 comments on commit c8bf3b9

Please sign in to comment.