diff --git a/extensions/gitlab/src/components/commits/list.tsx b/extensions/gitlab/src/components/commits/list.tsx index c5bd662df310c..f748848fa6a96 100644 --- a/extensions/gitlab/src/components/commits/list.tsx +++ b/extensions/gitlab/src/components/commits/list.tsx @@ -105,7 +105,7 @@ export function RecentCommitsList(): JSX.Element { return ( }> {commits?.map((e) => ( - + ))} ); diff --git a/extensions/gitlab/src/components/jobs.tsx b/extensions/gitlab/src/components/jobs.tsx index a0379adc3ffc5..8c8e801cff8d5 100644 --- a/extensions/gitlab/src/components/jobs.tsx +++ b/extensions/gitlab/src/components/jobs.tsx @@ -167,6 +167,9 @@ export function JobList(props: { if (error) { showToast(Toast.Style.Failure, "Cannot search Pipelines", error); } + if (!stages) { + return ; + } return ( {Object.keys(stages).map((stagekey) => ( @@ -193,12 +196,12 @@ export function useSearch( pipelineID: string, pipelineIID?: string | undefined ): { - stages: Record; + stages: Record | undefined; error?: string; isLoading: boolean; refresh: () => void; } { - const [stages, setStages] = useState>({}); + const [stages, setStages] = useState | undefined>(undefined); const [error, setError] = useState(); const [isLoading, setIsLoading] = useState(false); const [timestamp, setTimestamp] = useState(now()); @@ -243,9 +246,8 @@ export function useSearch( const projectUE = encodeURIComponent(projectFullPath); const jobs: RESTJob[] = await gitlab .fetch(`projects/${projectUE}/pipelines/${pipelineID}/jobs`) - .then((data) => { - return data.map((j: any) => j as RESTJob); - }); + .then((data) => data as RESTJob[]); + jobs.sort((a, b) => a.id - b.id); const stages: Record = {}; for (const job of jobs) { if (!stages[job.stage]) { @@ -306,24 +308,22 @@ export function PipelineJobsListByCommit(props: { project: Project; sha: string showToast(Toast.Style.Failure, "Could not fetch Commit Details", error); } if (isLoading || !commit) { - return ; - } else { - if (commit.last_pipeline) { - return ( - - ); - } else { - return ( - - - - ); - } + return ; + } + if (commit.last_pipeline) { + return ( + + ); } + return ( + + + + ); } function useCommit(