mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Feature: gitlab service widget (#4317)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
36
src/widgets/gitlab/component.jsx
Normal file
36
src/widgets/gitlab/component.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
|
||||
const { data: gitlabCounts, error: gitlabCountsError } = useWidgetAPI(widget, "counts");
|
||||
|
||||
if (gitlabCountsError) {
|
||||
return <Container service={service} error={gitlabCountsError} />;
|
||||
}
|
||||
|
||||
if (!gitlabCounts) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitlab.groups" />
|
||||
<Block label="gitlab.issues" />
|
||||
<Block label="gitlab.merges" />
|
||||
<Block label="gitlab.projects" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitlab.groups" value={t("common.number", { value: gitlabCounts.groups_count })} />
|
||||
<Block label="gitlab.issues" value={t("common.number", { value: gitlabCounts.issues_count })} />
|
||||
<Block label="gitlab.merges" value={t("common.number", { value: gitlabCounts.merge_requests_count })} />
|
||||
<Block label="gitlab.projects" value={t("common.number", { value: gitlabCounts.projects_count })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user