51
51
<!-- New Branch -->
52
52
<span class =" flex-sizing" >
53
53
<label class =" options-label soft mb-8" style =" display : block " for =" branch-input"
54
- >Optional - Create a Branch from an Existing Branch </label
54
+ >Create Branch - Optional for CodeCatalyst Repos </label
55
55
>
56
56
<input
57
57
id =" branch-input"
58
58
type =" text"
59
- placeholder =" branch-name"
59
+ :placeholder =" newBranchNamePlaceholder"
60
+ :disabled =" !newBranchNameAllowed"
60
61
v-model =" model.newBranch"
61
62
@input =" update"
62
63
/>
@@ -116,6 +117,8 @@ export default defineComponent({
116
117
branches: {} as Record <string , CodeCatalystBranch [] | undefined >,
117
118
loadingProjects: false ,
118
119
loadingBranches: {} as Record <string , boolean | undefined >,
120
+ newBranchNameAllowed: false ,
121
+ newBranchNamePlaceholder: ' Select branch first...' ,
119
122
}
120
123
},
121
124
async created() {
@@ -133,6 +136,40 @@ export default defineComponent({
133
136
this .useFirstBranch ()
134
137
}
135
138
},
139
+ async ' model.selectedBranch' (branch ? : CodeCatalystBranch ) {
140
+ if (this .model .type !== ' linked' || branch === undefined ) {
141
+ this .newBranchNameAllowed = false
142
+ this .newBranchNamePlaceholder = ' '
143
+ return
144
+ }
145
+
146
+ // Disable user input for new branch name while calculating
147
+ this .newBranchNameAllowed = false
148
+ this .newBranchNamePlaceholder = ' Loading...'
149
+
150
+ // Clear the existing new branch value so user does not see it
151
+ const previousNewBranch = this .model .newBranch
152
+ this .$emit (' update:modelValue' , { ... this .model , newBranch: undefined })
153
+
154
+ // Only want to allow users to set a branch name if first party repo
155
+ const isThirdPartyRepo = await client .isThirdPartyRepo ({
156
+ spaceName: branch .org .name ,
157
+ projectName: branch .project .name ,
158
+ sourceRepositoryName: branch .repo .name ,
159
+ })
160
+ if (isThirdPartyRepo ) {
161
+ this .newBranchNamePlaceholder = ' Not Applicable for Linked Repo'
162
+ this .newBranchNameAllowed = false
163
+ // Clear the new branch in case one was already selected
164
+ this .$emit (' update:modelValue' , { ... this .model , newBranch: undefined })
165
+ } else {
166
+ // First Party
167
+ this .newBranchNamePlaceholder = ' branch-name'
168
+ this .newBranchNameAllowed = true
169
+ // Since this can have a new branch, set this back to what it previously was
170
+ this .$emit (' update:modelValue' , { ... this .model , newBranch: previousNewBranch })
171
+ }
172
+ },
136
173
},
137
174
computed: {
138
175
model() {
0 commit comments