File tree Expand file tree Collapse file tree 4 files changed +23
-19
lines changed Expand file tree Collapse file tree 4 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ struct AddGitHubPipelineSheet: View {
15
15
@StateObject private var repository = DebouncedText ( )
16
16
@StateObject private var repositoryList = GitHubRepositoryList ( )
17
17
@StateObject private var workflowList = GitHubWorkflowList ( )
18
+ @StateObject private var branch = DebouncedText ( )
18
19
@StateObject private var branchList = GitHubBranchList ( )
19
20
@StateObject private var builder = GitHubPipelineBuilder ( )
20
21
@@ -105,15 +106,16 @@ struct AddGitHubPipelineSheet: View {
105
106
builder. workflow = workflowList. selected
106
107
}
107
108
108
- Picker ( " Branch: " , selection: $branchList. selected) {
109
- ForEach ( branchList. items) { b in
110
- Text ( b. name) . tag ( b)
111
- }
112
- }
113
- . accessibilityIdentifier ( " Branch picker " )
114
- . disabled ( !branchList. selected. isValid)
115
- . onChange ( of: branchList. selected) { _ in
116
- builder. branch = branchList. selected
109
+ LabeledContent ( " Branch: " ) {
110
+ ComboBox ( items: branchList. items. map ( { $0. name } ) , text: $branch. input)
111
+ . accessibilityIdentifier ( " Branch combo box " )
112
+ . disabled ( owner. text. isEmpty || repository. text. isEmpty || repository. text. starts ( with: " ( " ) )
113
+ . onReceive ( branch. $text) { t in
114
+ builder. branch = t
115
+ }
116
+ . onSubmit {
117
+ branch. takeInput ( )
118
+ }
117
119
}
118
120
. padding ( . bottom)
119
121
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class GitHubBranchList: ObservableObject {
22
22
if branches. count > 0 && !branches[ 0 ] . isValid {
23
23
return branches
24
24
}
25
- branches. insert ( GitHubBranch ( name: " all branches " ) , at: 0 )
25
+ branches. insert ( GitHubBranch ( name: " " ) , at: 0 )
26
26
return branches
27
27
}
28
28
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ class GitHubPipelineBuilder: ObservableObject {
11
11
var owner : String ?
12
12
var repository : String ? { didSet { setDefaultName ( ) } }
13
13
var workflow : GitHubWorkflow ? { didSet { setDefaultName ( ) } }
14
- var branch : GitHubBranch ? { didSet { setDefaultName ( ) } }
14
+ var branch : String ? { didSet { setDefaultName ( ) } }
15
15
16
16
func setDefaultName( ) {
17
17
var newName = " "
@@ -29,7 +29,7 @@ class GitHubPipelineBuilder: ObservableObject {
29
29
guard let owner else { return false }
30
30
guard let repository else { return false }
31
31
guard let workflow, workflow. isValid else { return false }
32
- guard let branch, branch . isValid else { return false }
32
+ guard let branch else { return false }
33
33
return true
34
34
}
35
35
@@ -38,8 +38,8 @@ class GitHubPipelineBuilder: ObservableObject {
38
38
guard let owner else { return nil }
39
39
guard let repository else { return nil }
40
40
guard let workflow, workflow. isValid else { return nil }
41
- guard let branch, branch . isValid else { return nil }
42
- let branchName = branch. isAllBranchPlaceholder ? nil : branch. name
41
+ guard let branch else { return nil }
42
+ let branchName = branch. isEmpty ? nil : branch
43
43
44
44
var url : URL ? = nil
45
45
let workflowPathComponents = [ workflow. filename, String ( workflow. id) ]
Original file line number Diff line number Diff line change @@ -203,13 +203,15 @@ class GitHubTests: XCTestCase {
203
203
// Make sure that the repositories and branches are loaded
204
204
let repositoryBox = sheet. comboBoxes [ " Repository combo box " ]
205
205
expectation ( for: NSPredicate ( format: " value == 'ccmenu2' " ) , evaluatedWith: repositoryBox)
206
- let branchPicker = sheet. popUpButtons [ " Branch picker " ]
207
- expectation ( for: NSPredicate ( format: " value == 'all branches ' " ) , evaluatedWith: branchPicker )
206
+ let branchBox = sheet. comboBoxes [ " Branch combo box " ]
207
+ expectation ( for: NSPredicate ( format: " value == '' " ) , evaluatedWith: branchBox )
208
208
waitForExpectations ( timeout: 5 )
209
209
210
- // Open the branch picker, select the main branch, and close the sheet
211
- branchPicker. click ( )
212
- branchPicker. menuItems [ " main " ] . click ( )
210
+ // Open the branch combo box, select the main branch, and close the sheet
211
+ branchBox. descendants ( matching: . button) . firstMatch. click ( )
212
+ branchBox. textFields [ " main " ] . click ( )
213
+ expectation ( for: NSPredicate ( format: " value == 'main' " ) , evaluatedWith: branchBox)
214
+ waitForExpectations ( timeout: 2 )
213
215
sheet. buttons [ " Apply " ] . click ( )
214
216
215
217
// Make sure the status is fetched and the request uses the branch
You can’t perform that action at this time.
0 commit comments