Skip to content

Commit 0a658fb

Browse files
Update autoGen function to check existence of components before prefill
Signed-off-by: Natalia Luzuriaga <natalia.luzuriaga@cms.hhs.gov>
1 parent 5095086 commit 0a658fb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

js/autoGenerateFields.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function getLicenseURL(repoURL) {
163163

164164
const licenseFile = files.find(file => {
165165
const fileName = file.name.toLowerCase()
166-
return fileName.startsWith('license')
166+
return fileName.startsWith('license')
167167
})
168168

169169
if (licenseFile) {
@@ -244,7 +244,7 @@ async function preFillFields(repoData, languages) {
244244
}
245245

246246
// Update languages list by combining any the user has entered
247-
if (languages) {
247+
if (form.getComponent('languages') && languages) {
248248
const languagesComp = form.getComponent('languages')
249249
const newLanguages = Object.keys(languages) || []
250250

@@ -274,18 +274,16 @@ async function preFillFields(repoData, languages) {
274274
// Update feedback mechanisms
275275
if (repoData.html_url) {
276276
const feedbackComp = form.getComponent('feedbackMechanisms')
277-
let currentFeedback = form.getComponent('feedbackMechanisms').getValue
278-
currentFeedback = []
279277

280278
const issuesUrl = repoData.html_url + "/issues"
281279

282-
currentFeedback.push(issuesUrl)
283-
feedbackComp.setValue(currentFeedback)
280+
feedbackComp.setValue(issuesUrl)
284281
}
285282

286283
// Update upstream
287-
if (repoData.html_url) {
288-
const upstreamComp = form.getComponent('upstream')
284+
285+
if (form.getComponent('upstream') && repoData.html_url) {
286+
const upstreamComp = form.getComponent('upstream');
289287
const urlParts = repoData.html_url.split('/')
290288

291289
if (urlParts.length >= 2) {
@@ -299,7 +297,7 @@ async function preFillFields(repoData, languages) {
299297
}
300298

301299
// Update repositoryHost
302-
if (repoData.html_url) {
300+
if (form.getComponent('repositoryHost') && repoData.html_url) {
303301
if (repoData.html_url.includes('github.cms.gov')) {
304302
form.getComponent('repositoryHost').setValue('github.cms.gov')
305303
} else if (repoData.html_url.includes('github.com/CMSgov')) {

0 commit comments

Comments
 (0)