diff --git a/public/locales/en/common.json b/public/locales/en/common.json index a85c0304..49f57d69 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -594,6 +594,13 @@ "gross_percent_1y": "One year", "gross_percent_max": "All time" }, + "gitea": { + "notifications": "Notifications", + "Issue": "Issues", + "Pull": "Pull Requests", + "Commit": "Commits", + "Repository": "Repositories" + }, "audiobookshelf": { "podcasts": "Podcasts", "books": "Books", diff --git a/src/widgets/components.js b/src/widgets/components.js index c909bfe0..fe125ede 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -19,6 +19,7 @@ const components = { fileflows: dynamic(() => import("./fileflows/component")), flood: dynamic(() => import("./flood/component")), freshrss: dynamic(() => import("./freshrss/component")), + gitea: dynamic(() => import("./gitea/component")), ghostfolio: dynamic(() => import("./ghostfolio/component")), gluetun: dynamic(() => import("./gluetun/component")), gotify: dynamic(() => import("./gotify/component")), diff --git a/src/widgets/gitea/component.jsx b/src/widgets/gitea/component.jsx new file mode 100644 index 00000000..881ef043 --- /dev/null +++ b/src/widgets/gitea/component.jsx @@ -0,0 +1,46 @@ +import { useTranslation } from "next-i18next"; + +import Block from "components/services/widget/block"; +import Container from "components/services/widget/container"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + + + + +export default function Component ({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + + const { data: notifications, error: giteaError } = useWidgetAPI(widget, "allNotifications"); + const notificationTypes = (notifications ?? []).reduce((acc, notification) => { + acc[notification.subject.type].push(notification); + return acc; + } + , { + "Issue": [], + "Pull": [], + "Commit": [], + "Repository": [] + } + ); + + if (giteaError) { + return ; + } + + if (!notifications) return ( + + + + ); + + return ( + + {Object.keys(notificationTypes).map((type) => + + )} + + ); +} diff --git a/src/widgets/gitea/widget.js b/src/widgets/gitea/widget.js new file mode 100644 index 00000000..cf967c27 --- /dev/null +++ b/src/widgets/gitea/widget.js @@ -0,0 +1,17 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/v1/{endpoint}?access_token={key}", + proxyHandler: genericProxyHandler, + + mappings: { + "allNotifications": { + endpoint: "notifications", + }, + "newNotifications": { + endpoint: "notifications/new", + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 20f36a2b..33ad2623 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -15,6 +15,7 @@ import fileflows from "./fileflows/widget"; import flood from "./flood/widget"; import freshrss from "./freshrss/widget"; import ghostfolio from "./ghostfolio/widget"; +import gitea from "./gitea/widget"; import gluetun from "./gluetun/widget"; import gotify from "./gotify/widget"; import grafana from "./grafana/widget"; @@ -97,6 +98,7 @@ const widgets = { flood, freshrss, ghostfolio, + gitea, gluetun, gotify, grafana,