From a4b07b91fedc85cad69df74d11a7001adb92328c Mon Sep 17 00:00:00 2001 From: chiragkrishna Date: Sat, 22 Mar 2025 20:15:27 +0530 Subject: [PATCH] Enhancement: Add Repositories field to Gitea (#5053) Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- docs/widgets/services/gitea.md | 2 +- public/locales/en/common.json | 7 ++++--- src/widgets/gitea/component.jsx | 11 ++++++++--- src/widgets/gitea/widget.js | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/widgets/services/gitea.md b/docs/widgets/services/gitea.md index 140c4ee7..eb47849d 100644 --- a/docs/widgets/services/gitea.md +++ b/docs/widgets/services/gitea.md @@ -7,7 +7,7 @@ Learn more about [Gitea](https://gitea.com). API token requires `notifications`, `repository` and `issue` permissions. See the [gitea documentation](https://docs.gitea.com/development/api-usage#generating-and-listing-api-tokens) for details on generating tokens. -Allowed fields: `["notifications", "issues", "pulls"]`. +Allowed fields: `["repositories", "notifications", "issues", "pulls"]`. ```yaml widget: diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 0535cd6e..4a9c33d5 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -883,9 +883,10 @@ "species": "Species" }, "gitea": { - "notifications": "Notifications", - "issues": "Issues", - "pulls": "Pull Requests" + "notifications": "Notifications", + "issues": "Issues", + "pulls": "Pull Requests", + "repositories": "Repositories" }, "stash": { "scenes": "Scenes", diff --git a/src/widgets/gitea/component.jsx b/src/widgets/gitea/component.jsx index 74e6dc82..c45ded06 100644 --- a/src/widgets/gitea/component.jsx +++ b/src/widgets/gitea/component.jsx @@ -8,17 +8,21 @@ export default function Component({ service }) { const { data: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications"); const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues"); + const { data: giteaRepositories, error: giteaRepositoriesError } = useWidgetAPI(widget, "repositories"); - if (giteaNotificationsError || giteaIssuesError) { - return ; + if (giteaNotificationsError || giteaIssuesError || giteaRepositoriesError) { + return ( + + ); } - if (!giteaNotifications || !giteaIssues) { + if (!giteaNotifications || !giteaIssues || !giteaRepositories) { return ( + ); } @@ -28,6 +32,7 @@ export default function Component({ service }) { + ); } diff --git a/src/widgets/gitea/widget.js b/src/widgets/gitea/widget.js index 32871b00..b0420ccc 100644 --- a/src/widgets/gitea/widget.js +++ b/src/widgets/gitea/widget.js @@ -16,6 +16,9 @@ const widget = { issues: asJson(data).filter((issue) => !issue.pull_request), }), }, + repositories: { + endpoint: "repos/search", + }, }, };