-
Notifications
You must be signed in to change notification settings - Fork 41
Open New Issues from Rocket.Chat
Samad Yar Khan edited this page Sep 3, 2022
·
1 revision
- The Rocket.Chat.Apps-Engine allows users to enter input inside a
PlainTextInputElement
and submit the response. The submitted responses can be fetched usingcontext.getInteractionData()
inside theExecuteViewSubmitHandler
. - The
GitHub Open Issues
feature makes use of the above mentioned functionality to open a new issue on a GitHub repository. - On entering the Repository Name, a list of issue templates are fetched and any of these can be used.
- Users can add labels, add assignees, milestones etc to the new issue.
- Users can enter
/github issue
to triggernewIssueStarterModal
. - After entering the repository name in
newIssueStarterModal
, the repository templates are fetched usinggetIssueTemplates()
method. - The selected templates issue body is pre populated in
ISSUE_BODY_INPUT
block. - User can fill the fields to add issue title, issue body, assignees and labels, and create a new issue.
- When a new issue is created, a message notification is sent to the channel along with the issue url.
- Fetching issue templates was a challenging part as GitHub does not yet offer an API to enter repository templates.
- To fetch issue templates we use the GitHub Repository Contents API.
- As templates are usually stored in the path -
./github/ISSUE_TEMPLATES/
we can fetch all the files under./github/ISSUE_TEMPLATES/
using the following API ->https://api.github.com/repos/${repoName}/contents/.github/ISSUE_TEMPLATE/
. - Now, in
issueTemplateSelectionModal
, the files names are made as template names and thedownload_url
for each file is set as the value forISSUE_TEMPLATE_SELECTION_ACTION
button. - When the
ISSUE_TEMPLATE_SELECTION_ACTION
is clicked, theExecuteBlockActionHandler
calls thegetIssueTemplateCode
method and fetches the template files code and then the triggersnewIssueModal
with the fetched template code.