Skip to content

Commit

Permalink
fix: autoselect auth strategy if there is only one (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidma415 authored May 22, 2024
1 parent 986c719 commit 9370590
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/views/Applications/ApplicationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<KSelect
id="authStrat"
:items="appAuthStrategies"
:disabled="formMode === 'edit'"
:disabled="formMode === 'edit' || appAuthStrategies.length === 1"
data-testid="application-auth-strategy-select"
appearance="select"
width="100%"
Expand Down Expand Up @@ -373,15 +373,21 @@ export default defineComponent({
}))
}
const selected = rawAuthStrategies.length === 1
const hasOneAvailableAuthStrategy = rawAuthStrategies.length === 1
const prefilledAuthStrategy = hasOneAvailableAuthStrategy
? appAuthStrategies.value[0]
: appAuthStrategies.value.find((authStrat) => authStrat.selected === true)
if (selected) {
formData.value.auth_strategy_id = selected.value
appIsDcr.value = selected.isDcr
selectedAuthStrategy.value = selected
appIsSelfManaged.value = selected.isSelfManaged
if (prefilledAuthStrategy) {
if (hasOneAvailableAuthStrategy) {
prefilledAuthStrategy.selected = true
}
formData.value.auth_strategy_id = prefilledAuthStrategy.value
appIsDcr.value = prefilledAuthStrategy.isDcr
selectedAuthStrategy.value = prefilledAuthStrategy
appIsSelfManaged.value = prefilledAuthStrategy.isSelfManaged
}
fetchingAuthStrategies.value = false
Expand Down

0 comments on commit 9370590

Please sign in to comment.