-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐ Pass login info from front to back (#139)
* ⭐ Pass login info from front to back * 'loginInfo' no longer needs to be a global variable; it is passed from from top-level to all functions that require it * Temporarily remove code of updating & deleting labels/milestones * Numerous minor updates
- Loading branch information
1 parent
8948338
commit 29ca259
Showing
26 changed files
with
315 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,76 @@ | ||
export const buildHttpRequestBodyForLabels = () => { | ||
export const buildHttpRequestBodyForLabelToBeCreatedOnGithub = (label) => { | ||
const { name, description, color } = label; | ||
const colorWithoutLeadingHex = color.substring(1); | ||
|
||
const body = { | ||
name: 'type: feature request', | ||
color: '001122', | ||
description: 'Suggestion to new features', | ||
name, | ||
description, | ||
color: colorWithoutLeadingHex, | ||
}; | ||
|
||
return body; | ||
}; | ||
|
||
export const buildHttpRequestBodyForMilestones = () => { | ||
export const buildHttpRequestBodyForLabel = (loginInfo, label) => { | ||
const { domain } = loginInfo; | ||
const { action } = label; | ||
|
||
const funcToBuildHttpRequestBodyForLabelToBe = { | ||
github: { | ||
create: (_label) => buildHttpRequestBodyForLabelToBeCreatedOnGithub(_label), | ||
}, | ||
}; | ||
|
||
const buildHttpRequestBodyForLabelToBe = | ||
funcToBuildHttpRequestBodyForLabelToBe[domain][action]; | ||
|
||
const body = buildHttpRequestBodyForLabelToBe(label); | ||
return body; | ||
}; | ||
|
||
export const buildHttpRequestBodyForMilestoneToBeCreatedOnGithub = (milestone) => { | ||
const { title, state, description, dueOn } = milestone; | ||
|
||
const body = { | ||
title: 'Backlog', | ||
state: 'open', | ||
description: 'Work not yet planned for a specific release', | ||
due_on: '2030-04-01T09:00:00Z', | ||
title, | ||
state, | ||
description, | ||
due_on: dueOn, | ||
}; | ||
|
||
return body; | ||
}; | ||
|
||
export const buildHttpRequestBodyForMilestone = (loginInfo, milestone) => { | ||
const { domain } = loginInfo; | ||
const { action } = milestone; | ||
|
||
const funcToBuildHttpRequestBodyForMilestoneToBe = { | ||
github: { | ||
create: (_milestone) => | ||
buildHttpRequestBodyForMilestoneToBeCreatedOnGithub(_milestone), | ||
}, | ||
}; | ||
|
||
const buildHttpRequestBodyForMilestoneToBe = | ||
funcToBuildHttpRequestBodyForMilestoneToBe[domain][action]; | ||
|
||
const body = buildHttpRequestBodyForMilestoneToBe(milestone); | ||
return body; | ||
}; | ||
|
||
export const buildHttpRequestBody = (entryType) => { | ||
const httpRequestBodyBuilders = { | ||
labels: buildHttpRequestBodyForLabels(), | ||
milestones: buildHttpRequestBodyForMilestones(), | ||
export const buildHttpRequestBody = (loginInfo, entryType, entry) => { | ||
const funcToBuildHttpRequestBodyForEntryType = { | ||
labels: (_loginInfo, label) => buildHttpRequestBodyForLabel(_loginInfo, label), | ||
milestones: (_loginInfo, milestone) => | ||
buildHttpRequestBodyForMilestone(_loginInfo, milestone), | ||
}; | ||
const body = httpRequestBodyBuilders[entryType]; | ||
return JSON.stringify(body); | ||
|
||
const buildHttpRequestBodyForEntryType = | ||
funcToBuildHttpRequestBodyForEntryType[entryType]; | ||
|
||
const body = buildHttpRequestBodyForEntryType(loginInfo, entry); | ||
|
||
// Note: the returned body is not stringified | ||
return body; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.