Skip to content

Commit 51d2957

Browse files
author
Bryan
authored
fe: add auto-complete functionality to input fields(#372) (#1100)
Signed-off-by: bryans-go <[email protected]>
1 parent 47338c2 commit 51d2957

File tree

8 files changed

+97
-2
lines changed

8 files changed

+97
-2
lines changed

pkg/api/docs/docs.go

+7
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,13 @@ const docTemplate = `{
28382838
"type": "string"
28392839
}
28402840
},
2841+
"suggestions": {
2842+
"description": "Suggestions is an optional list of auto-complete values to assist the user while filling the field",
2843+
"type": "array",
2844+
"items": {
2845+
"type": "string"
2846+
}
2847+
},
28412848
"type": {
28422849
"$ref": "#/definitions/provider.ProviderTargetPropertyType"
28432850
}

pkg/api/docs/swagger.json

+7
Original file line numberDiff line numberDiff line change
@@ -2835,6 +2835,13 @@
28352835
"type": "string"
28362836
}
28372837
},
2838+
"suggestions": {
2839+
"description": "Suggestions is an optional list of auto-complete values to assist the user while filling the field",
2840+
"type": "array",
2841+
"items": {
2842+
"type": "string"
2843+
}
2844+
},
28382845
"type": {
28392846
"$ref": "#/definitions/provider.ProviderTargetPropertyType"
28402847
}

pkg/api/docs/swagger.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,12 @@ definitions:
785785
items:
786786
type: string
787787
type: array
788+
suggestions:
789+
description: Suggestions is an optional list of auto-complete values to assist
790+
the user while filling the field
791+
items:
792+
type: string
793+
type: array
788794
type:
789795
$ref: '#/definitions/provider.ProviderTargetPropertyType'
790796
type: object

pkg/apiclient/api/openapi.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2596,6 +2596,12 @@ components:
25962596
items:
25972597
type: string
25982598
type: array
2599+
suggestions:
2600+
description: Suggestions is an optional list of auto-complete values to
2601+
assist the user while filling the field
2602+
items:
2603+
type: string
2604+
type: array
25992605
type:
26002606
$ref: '#/components/schemas/provider.ProviderTargetPropertyType'
26012607
type: object

pkg/apiclient/docs/ProviderProviderTargetProperty.md

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Name | Type | Description | Notes
99
**DisabledPredicate** | Pointer to **string** | A regex string matched with the name of the target to determine if the property should be disabled If the regex matches the target name, the property will be disabled E.g. \&quot;^local$\&quot; will disable the property for the local target | [optional]
1010
**InputMasked** | Pointer to **bool** | | [optional]
1111
**Options** | Pointer to **[]string** | Options is only used if the Type is ProviderTargetPropertyTypeOption | [optional]
12+
**Suggestions** | Pointer to **[]string** | Suggestions is an optional list of auto-complete values to assist the user while filling the field | [optional]
1213
**Type** | Pointer to [**ProviderProviderTargetPropertyType**](ProviderProviderTargetPropertyType.md) | | [optional]
1314

1415
## Methods
@@ -155,6 +156,31 @@ SetOptions sets Options field to given value.
155156

156157
HasOptions returns a boolean if a field has been set.
157158

159+
### GetSuggestions
160+
161+
`func (o *ProviderProviderTargetProperty) GetSuggestions() []string`
162+
163+
GetSuggestions returns the Suggestions field if non-nil, zero value otherwise.
164+
165+
### GetSuggestionsOk
166+
167+
`func (o *ProviderProviderTargetProperty) GetSuggestionsOk() (*[]string, bool)`
168+
169+
GetSuggestionsOk returns a tuple with the Suggestions field if it's non-nil, zero value otherwise
170+
and a boolean to check if the value has been set.
171+
172+
### SetSuggestions
173+
174+
`func (o *ProviderProviderTargetProperty) SetSuggestions(v []string)`
175+
176+
SetSuggestions sets Suggestions field to given value.
177+
178+
### HasSuggestions
179+
180+
`func (o *ProviderProviderTargetProperty) HasSuggestions() bool`
181+
182+
HasSuggestions returns a boolean if a field has been set.
183+
158184
### GetType
159185

160186
`func (o *ProviderProviderTargetProperty) GetType() ProviderProviderTargetPropertyType`

pkg/apiclient/model_provider_provider_target_property.go

+39-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/provider/types.go

+2
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,6 @@ type ProviderTargetProperty struct {
7676
Description string
7777
// Options is only used if the Type is ProviderTargetPropertyTypeOption
7878
Options []string
79+
// Suggestions is an optional list of auto-complete values to assist the user while filling the field
80+
Suggestions []string
7981
}

pkg/views/target/set.go

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ func getInput(name string, property apiclient.ProviderProviderTargetProperty, in
182182
input = input.EchoMode(huh.EchoModePassword)
183183
}
184184

185+
if len(property.Suggestions) > 0 {
186+
input = input.Suggestions(property.Suggestions)
187+
}
188+
185189
return input, value
186190
}
187191

0 commit comments

Comments
 (0)