-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduced TypeScript type definitions SearchJiraResponse and JiraQueryResults to represent Jira search responses and pagination details. #127
Open
SaachiNayyer
wants to merge
1
commit into
AxisCommunications:main
Choose a base branch
from
Ericsson:improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@axis-backstage/plugin-jira-dashboard-backend': major | ||
'@axis-backstage/plugin-jira-dashboard-common': minor | ||
--- | ||
|
||
Introduced TypeScript type definitions SearchJiraResponse and JiraQueryResults to represent Jira search responses and pagination details. | ||
Updated the searchJira function to return search results as a SearchJiraResponse, incorporating the new types. | ||
The searchJira function now returns an object containing both the search results and the HTTP status code, improving error resilience and clarity in handling search operations. | ||
The JiraQueryResults type outlines the structure of a paginated Jira search response, facilitating better data handling. | ||
These changes streamline the Jira Dashboard plugin's codebase, improving error resilience and clarity in handling search operations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { | |
Filter, | ||
Issue, | ||
Project, | ||
SearchJiraResponse, | ||
} from '@axis-backstage/plugin-jira-dashboard-common'; | ||
import { resolveJiraBaseUrl, resolveJiraToken } from './config'; | ||
import { jqlQueryBuilder } from './queries'; | ||
|
@@ -93,14 +94,15 @@ export type SearchOptions = { | |
* @param config - A Backstage config | ||
* @param jqlQuery - A string containing the jql query. | ||
* @param options - Query options that will be passed on to the POST request. | ||
* | ||
* @returns A promise that resolves with the search results and status code. | ||
* @throws If an error occurs during the search process. | ||
* @public | ||
*/ | ||
export const searchJira = async ( | ||
config: Config, | ||
jqlQuery: string, | ||
options: SearchOptions, | ||
): Promise<Issue[]> => { | ||
): Promise<SearchJiraResponse> => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the error handling a bit? I would prefer if this would return "JiraQueryResults" directly. What is the benefit of having the caller of this function have to check the response status? Maybe something like this? const response = await fetch(`${resolveJiraBaseUrl(config)}search`, {
....
});
if (response.ok) {
return await response.json();
}
throw new Error(`${response.status}`) |
||
const response = await fetch(`${resolveJiraBaseUrl(config)}search`, { | ||
method: 'POST', | ||
body: JSON.stringify({ jql: jqlQuery, ...options }), | ||
|
@@ -109,8 +111,13 @@ export const searchJira = async ( | |
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
}).then(resp => resp.json()); | ||
return response.issues; | ||
}); | ||
const jsonResponse = await response.json(); | ||
|
||
return { | ||
results: jsonResponse, | ||
statusCode: response.status, | ||
} as SearchJiraResponse; | ||
}; | ||
|
||
export const getIssuesByComponent = async ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this changes the "searchJira" call in a breaking way please update this with code examples how it has changed and how to update any code that is using it.