Skip to content

Open New Issues from Rocket.Chat

Samad Yar Khan edited this page Sep 3, 2022 · 1 revision

Open New Issues

  • The Rocket.Chat.Apps-Engine allows users to enter input inside a PlainTextInputElement and submit the response. The submitted responses can be fetched using context.getInteractionData() inside the ExecuteViewSubmitHandler.
  • 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.

User Flow

  • Users can enter /github issue to trigger newIssueStarterModal.
  • After entering the repository name in newIssueStarterModal, the repository templates are fetched using getIssueTemplates() 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.

image

Fetching issue templates

  • 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 the download_url for each file is set as the value for ISSUE_TEMPLATE_SELECTION_ACTION button.
  • When the ISSUE_TEMPLATE_SELECTION_ACTION is clicked, the ExecuteBlockActionHandler calls the getIssueTemplateCode method and fetches the template files code and then the triggers newIssueModal with the fetched template code.