-
Notifications
You must be signed in to change notification settings - Fork 44
GitHub Search
Samad Yar Khan edited this page Aug 27, 2022
·
2 revisions
- 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
IGitHubSearchResultandIGitHubSearchDatainterfaces which facilitate the multi-share feature.
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
Searchwe will enter theexecuteViewSumbmitHandlercase forGitHubSearchModal. - Here a the search query inputs will be parsed and will be passed as input to the
githubSearchIssuesPulls()method fromGitHubSDK. -
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
executeViewSumbmitHandlerand it will trigger thegithubSearchResultModaland display the results.

- A given search result can be sent to the current Rocket.Chat Room but clicking on
Share. - When
Shareis clicked, theExecuteBlockActionHandleris triggered and it gets the shareable message in thecontextInteractionDatavalue. - Here we use the
sendMessagehelper function from thelib/helperMessage.tsto send this to the Rocket.Chat Room.

- click on
Addto add multiple search results and then share them together in a message by clicking inShare. - Users can append a personal message along with the search results.

- 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 SessionaIGitHubSearchDataobject is created which storesIGitHubSearchResultin 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, thesharefield of thatIGitHubSearchResultis set to true and the overall persistent data is updated usingExecuteBlockActionHandlerand the Modal is re-rendered. - When the user clicks on
Share, theexecuteViewSumbmitHandlerruns the case forSEARCH_RESULT_VIEWwhich checks the persistent storage for the search results which haveshareset totrueand this data is passed intogithubSearchResultShareModal. -
githubSearchResultSharemodal will load the added search results along with the search query in aMultilineInputElementwhich can be edited. - Clicking on
Shareinside thegithubSearchResultSharemodal will send the message to the current Rocket.Chat channel. - Search Results are cleared from persistent storage when
githubSearchResultModalis closed by exciting theSEARCH_RESULT_VIEWcase inExecuteViewClosedHandler.
- All pull request search results will have a
View Changesbutton. - When user clicks on
ViewChanges,ExecuteBlockActionHandlerwill parse thecontextInteractionDatato 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,ExecuteBlockActionHandlerwill be called again and the file code/file changes will be fetched and displayed infileCodeModal
