-
Notifications
You must be signed in to change notification settings - Fork 40
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
IGitHubSearchResult
andIGitHubSearchData
interfaces 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
Search
we will enter theexecuteViewSumbmitHandler
case 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
executeViewSumbmitHandler
and it will trigger thegithubSearchResultModal
and display the results.
- A given search result can be sent to the current Rocket.Chat Room but clicking on
Share
. - When
Share
is clicked, theExecuteBlockActionHandler
is triggered and it gets the shareable message in thecontextInteractionData
value
. - Here we use the
sendMessage
helper function from thelib/helperMessage.ts
to send this to the Rocket.Chat Room.
- click on
Add
to 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 Session
aIGitHubSearchData
object is created which storesIGitHubSearchResult
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
, theshare
field of thatIGitHubSearchResult
is set to true and the overall persistent data is updated usingExecuteBlockActionHandler
and the Modal is re-rendered. - When the user clicks on
Share
, theexecuteViewSumbmitHandler
runs the case forSEARCH_RESULT_VIEW
which checks the persistent storage for the search results which haveshare
set totrue
and this data is passed intogithubSearchResultShare
Modal. -
githubSearchResultShare
modal will load the added search results along with the search query in aMultilineInputElement
which can be edited. - Clicking on
Share
inside thegithubSearchResultShare
modal will send the message to the current Rocket.Chat channel. - Search Results are cleared from persistent storage when
githubSearchResultModal
is closed by exciting theSEARCH_RESULT_VIEW
case inExecuteViewClosedHandler
.
- All pull request search results will have a
View Changes
button. - When user clicks on
ViewChanges
,ExecuteBlockActionHandler
will parse thecontextInteractionData
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 infileCodeModal