added topTeams to PullRequestsPageProps and implemented through to backend

Signed-off-by: Quadman <QuadmanSWE@gmail.com>
This commit is contained in:
Quadman
2024-03-19 21:06:41 +01:00
parent 106b904f31
commit 11fa8ea465
6 changed files with 27 additions and 9 deletions
@@ -64,6 +64,7 @@ export interface AzureDevOpsApi {
getDashboardPullRequests(
projectName: string,
topTeams?: number,
): Promise<DashboardPullRequest[]>;
getAllTeams(topTeams?: number): Promise<Team[]>;
@@ -124,10 +124,15 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
public getDashboardPullRequests(
projectName: string,
topTeams?: number,
): Promise<DashboardPullRequest[]> {
return this.get<DashboardPullRequest[]>(
`dashboard-pull-requests/${projectName}?top=100`,
);
const queryString = new URLSearchParams();
queryString.append('top', '100');
if (topTeams) {
queryString.append('topTeams', topTeams.toString());
}
const urlSegment = `dashboard-pull-requests/${projectName}?${queryString}`;
return this.get<DashboardPullRequest[]>(urlSegment);
}
public getAllTeams(topTeams?: number): Promise<Team[]> {
@@ -70,14 +70,17 @@ type PullRequestsPageProps = {
projectName?: string;
pollingInterval?: number;
defaultColumnConfigs?: PullRequestColumnConfig[];
topTeams?: number;
};
export const PullRequestsPage = (props: PullRequestsPageProps) => {
const { projectName, pollingInterval, defaultColumnConfigs } = props;
const { projectName, pollingInterval, defaultColumnConfigs, topTeams } =
props;
const { pullRequests, loading, error } = useDashboardPullRequests(
projectName,
pollingInterval,
topTeams,
);
const [columnConfigs] = useState(
@@ -27,6 +27,7 @@ const POLLING_INTERVAL = 10000;
export function useDashboardPullRequests(
project?: string,
pollingInterval: number = POLLING_INTERVAL,
topTeams?: number,
): {
pullRequests?: DashboardPullRequest[];
loading: boolean;
@@ -43,7 +44,7 @@ export function useDashboardPullRequests(
}
try {
return await api.getDashboardPullRequests(project);
return await api.getDashboardPullRequests(project, topTeams);
} catch (error) {
if (error instanceof Error) {
errorApi.post(error);
@@ -51,7 +52,7 @@ export function useDashboardPullRequests(
return Promise.reject(error);
}
}, [project, api, errorApi]);
}, [project, api, topTeams, errorApi]);
const {
value: pullRequests,