Skip to content
Samad Yar Khan edited this page Aug 27, 2022 · 2 revisions

GitHub Search Integration

  • GitHub Search enables users to search issue and pull request on GitHub.
  • Search Results can be filtered based on different filters : Repository, Authors, Labels etc.
  • Users can share selected search result to Rocket.Chat rooms.
  • Users can view the code changes of any Pull Request Search Results.
  • We fetch the search results using the GitHub Search API.
  • Search Query are formed according to GitHub search query documentation.
  • Search Results are stored temporarily using IGitHubSearchResult and IGitHubSearchData interfaces which facilitate the multi-share feature.

User Flow

Search Query

Users can enter the /github search slash command to trigger the GithubSearchModal. Here the user will be prompted to enter different fields as shown. Search can be filtered based upon the following parameters :

  • Repository
  • Authtors
  • Labels
  • Resource State
  • Milestones

This is the application workflow :

  • Once the user click on Search we will enter the executeViewSumbmitHandler case for GitHubSearchModal.
  • Here a the search query inputs will be parsed and will be passed as input to the githubSearchIssuesPulls() method from GitHubSDK.
  • githubSearchIssuesPulls() will form a search query based on the input parameters and will use the GitHub Search API to fetch relevant results.
  • The Results will returned to executeViewSumbmitHandler and it will trigger the githubSearchResultModal and display the results.

search

Sharing Single Search Results

  • A given search result can be sent to the current Rocket.Chat Room but clicking on Share.
  • When Share is clicked, the ExecuteBlockActionHandler is triggered and it gets the shareable message in the contextInteractionData value.
  • Here we use the sendMessage helper function from the lib/helperMessage.ts to send this to the Rocket.Chat Room.

share

Sharing Multiple Search Results

  • click on Add to add multiple search results and then share them together in a message by clicking in Share.
  • Users can append a personal message along with the search results.

image

  • When search results are fetched from GitHub, they are stored as IGitHubSearchResult.
export interface IGitHubSearchResult{
    result_id: string|number,
    title?: string,
    html_url?: string, 
    number?: string|number
    labels?: string,
    pull_request?: boolean, 
    pull_request_url?: string,
    user_login?:string,
    state?:string,
    share?:boolean,//true if seacrh result is to be shareed
    result: string,
}
  • For each Search Session a IGitHubSearchData object is created which stores IGitHubSearchResult in an array.
//search results for a user 
export interface IGitHubSearchResultData{
    user_id : string ,
    room_id : string,
    search_query : string,
    total_count? : string|number,
    search_results : Array<IGitHubSearchResult> 
}
  • Whenever a user clicks on Add, the share field of that IGitHubSearchResult is set to true and the overall persistent data is updated using ExecuteBlockActionHandler and the Modal is re-rendered.
  • When the user clicks on Share, the executeViewSumbmitHandler runs the case for SEARCH_RESULT_VIEW which checks the persistent storage for the search results which have share set to true and this data is passed into githubSearchResultShare Modal.
  • githubSearchResultShare modal will load the added search results along with the search query in a MultilineInputElement which can be edited.
  • Clicking on Share inside the githubSearchResultShare modal will send the message to the current Rocket.Chat channel.
  • Search Results are cleared from persistent storage when githubSearchResultModal is closed by exciting the SEARCH_RESULT_VIEW case in ExecuteViewClosedHandler.

View Pull Request Result Code Changes

  • All pull request search results will have a View Changes button.
  • When user clicks on ViewChanges, ExecuteBlockActionHandler will parse the contextInteractionData to fetch repository name and pull number.
  • These will be passed to pullDetailsModal , where the changed files will be listed.
  • When user click on View File/View Changes, ExecuteBlockActionHandler will be called again and the file code/file changes will be fetched and displayed in fileCodeModal

file changes