Skip to content

Commit

Permalink
Merge pull request raycast#1 from Loskir/gitlab-optimize
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
tonka3000 authored Apr 5, 2022
2 parents 4063432 + 5b8d637 commit 13fe376
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion extensions/gitlab/src/components/commits/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function RecentCommitsList(): JSX.Element {
return (
<List isLoading={isLoading} searchBarAccessory={<MyProjectsDropdown onChange={setProject} />}>
{commits?.map((e) => (
<EventCommitListItem event={e} key={`${e.target_id}${e.project_id}`} />
<EventCommitListItem event={e} key={`${e.id}`} />
))}
</List>
);
Expand Down
44 changes: 22 additions & 22 deletions extensions/gitlab/src/components/jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export function JobList(props: {
if (error) {
showToast(Toast.Style.Failure, "Cannot search Pipelines", error);
}
if (!stages) {
return <List isLoading navigationTitle="Jobs" />;
}
return (
<List isLoading={isLoading} navigationTitle="Jobs">
{Object.keys(stages).map((stagekey) => (
Expand All @@ -193,12 +196,12 @@ export function useSearch(
pipelineID: string,
pipelineIID?: string | undefined
): {
stages: Record<string, Job[]>;
stages: Record<string, Job[]> | undefined;
error?: string;
isLoading: boolean;
refresh: () => void;
} {
const [stages, setStages] = useState<Record<string, Job[]>>({});
const [stages, setStages] = useState<Record<string, Job[]> | undefined>(undefined);
const [error, setError] = useState<string>();
const [isLoading, setIsLoading] = useState<boolean>(false);
const [timestamp, setTimestamp] = useState<Date>(now());
Expand Down Expand Up @@ -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<string, Job[]> = {};
for (const job of jobs) {
if (!stages[job.stage]) {
Expand Down Expand Up @@ -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 <List isLoading={isLoading} searchBarPlaceholder="Loading" />;
} else {
if (commit.last_pipeline) {
return (
<JobList
projectFullPath={props.project.fullPath}
pipelineID={`${commit.last_pipeline.id}`}
pipelineIID={commit.last_pipeline.iid ? `${commit.last_pipeline.iid}` : undefined}
/>
);
} else {
return (
<List>
<List.Item title="No piplelines attached" />
</List>
);
}
return <List isLoading />;
}
if (commit.last_pipeline) {
return (
<JobList
projectFullPath={props.project.fullPath}
pipelineID={`${commit.last_pipeline.id}`}
pipelineIID={commit.last_pipeline.iid ? `${commit.last_pipeline.iid}` : undefined}
/>
);
}
return (
<List>
<List.Item title="No pipelines attached" />
</List>
);
}

function useCommit(
Expand Down

0 comments on commit 13fe376

Please sign in to comment.