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 <Container service={service} error={giteaNotificationsError ?? giteaIssuesError} />; + if (giteaNotificationsError || giteaIssuesError || giteaRepositoriesError) { + return ( + <Container service={service} error={giteaNotificationsError ?? giteaIssuesError ?? giteaRepositoriesError} /> + ); } - if (!giteaNotifications || !giteaIssues) { + if (!giteaNotifications || !giteaIssues || !giteaRepositories) { return ( <Container service={service}> <Block label="gitea.notifications" /> <Block label="gitea.issues" /> <Block label="gitea.pulls" /> + <Block label="gitea.repositories" /> </Container> ); } @@ -28,6 +32,7 @@ export default function Component({ service }) { <Block label="gitea.notifications" value={giteaNotifications.length} /> <Block label="gitea.issues" value={giteaIssues.issues.length} /> <Block label="gitea.pulls" value={giteaIssues.pulls.length} /> + <Block label="gitea.repositories" value={giteaRepositories.data.length} /> </Container> ); } 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", + }, }, };