mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Enhancement: Add Repositories field to Gitea (#5053)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
d853bbfe44
commit
a4b07b91fe
@ -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.
|
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
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
|
@ -883,9 +883,10 @@
|
|||||||
"species": "Species"
|
"species": "Species"
|
||||||
},
|
},
|
||||||
"gitea": {
|
"gitea": {
|
||||||
"notifications": "Notifications",
|
"notifications": "Notifications",
|
||||||
"issues": "Issues",
|
"issues": "Issues",
|
||||||
"pulls": "Pull Requests"
|
"pulls": "Pull Requests",
|
||||||
|
"repositories": "Repositories"
|
||||||
},
|
},
|
||||||
"stash": {
|
"stash": {
|
||||||
"scenes": "Scenes",
|
"scenes": "Scenes",
|
||||||
|
@ -8,17 +8,21 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const { data: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications");
|
const { data: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications");
|
||||||
const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues");
|
const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues");
|
||||||
|
const { data: giteaRepositories, error: giteaRepositoriesError } = useWidgetAPI(widget, "repositories");
|
||||||
|
|
||||||
if (giteaNotificationsError || giteaIssuesError) {
|
if (giteaNotificationsError || giteaIssuesError || giteaRepositoriesError) {
|
||||||
return <Container service={service} error={giteaNotificationsError ?? giteaIssuesError} />;
|
return (
|
||||||
|
<Container service={service} error={giteaNotificationsError ?? giteaIssuesError ?? giteaRepositoriesError} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!giteaNotifications || !giteaIssues) {
|
if (!giteaNotifications || !giteaIssues || !giteaRepositories) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="gitea.notifications" />
|
<Block label="gitea.notifications" />
|
||||||
<Block label="gitea.issues" />
|
<Block label="gitea.issues" />
|
||||||
<Block label="gitea.pulls" />
|
<Block label="gitea.pulls" />
|
||||||
|
<Block label="gitea.repositories" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -28,6 +32,7 @@ export default function Component({ service }) {
|
|||||||
<Block label="gitea.notifications" value={giteaNotifications.length} />
|
<Block label="gitea.notifications" value={giteaNotifications.length} />
|
||||||
<Block label="gitea.issues" value={giteaIssues.issues.length} />
|
<Block label="gitea.issues" value={giteaIssues.issues.length} />
|
||||||
<Block label="gitea.pulls" value={giteaIssues.pulls.length} />
|
<Block label="gitea.pulls" value={giteaIssues.pulls.length} />
|
||||||
|
<Block label="gitea.repositories" value={giteaRepositories.data.length} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,9 @@ const widget = {
|
|||||||
issues: asJson(data).filter((issue) => !issue.pull_request),
|
issues: asJson(data).filter((issue) => !issue.pull_request),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
repositories: {
|
||||||
|
endpoint: "repos/search",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user