add azure pullrequrests
This commit is contained in:
parent
2aeb3f4c89
commit
a07baefb32
@ -664,5 +664,10 @@
|
|||||||
"kavita": {
|
"kavita": {
|
||||||
"seriesCount": "Series",
|
"seriesCount": "Series",
|
||||||
"totalFiles": "Files"
|
"totalFiles": "Files"
|
||||||
|
},
|
||||||
|
"azurePullrequests": {
|
||||||
|
"totalPrs": "Total PRs",
|
||||||
|
"myPrs": "My PRs",
|
||||||
|
"approvedNotCompleted": "My Approved Not Completed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else {
|
} else {
|
||||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (widget.type === "azurePullrequests") {
|
||||||
|
headers.Authorization = `Basic ${Buffer.from(`$:${widget.key}`).toString("base64")}`;
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/widgets/azurePullrequests/component.jsx
Normal file
36
src/widgets/azurePullrequests/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: prData, error: prError } = useWidgetAPI(widget, "pr");
|
||||||
|
|
||||||
|
if (prError) {
|
||||||
|
const finalError = prError ;
|
||||||
|
return <Container service={service} error={finalError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!prData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="azurePullrequests.totalPrs" />
|
||||||
|
<Block label="azurePullrequests-pr.myPrs" />
|
||||||
|
<Block label="azurePullrequests.approvedNotCompleted" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="azurePullrequests.totalPrs" value={t("common.number", { value: prData.count })} />
|
||||||
|
<Block label="azurePullrequests.myPrs" value={t("common.number", { value: prData.value.filter(item => item.createdBy.uniqueName === service.widget.userEmail).length })} />
|
||||||
|
<Block label="azurePullrequests.approvedNotCompleted" value={t("common.number", { value: prData.value.filter(item => item.reviewers.some(reviewer => reviewer.vote === 10)).length })} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
14
src/widgets/azurePullrequests/widget.js
Normal file
14
src/widgets/azurePullrequests/widget.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
active: {
|
||||||
|
pr: {
|
||||||
|
endpoint: "pr",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -5,6 +5,7 @@ const components = {
|
|||||||
audiobookshelf: dynamic(() => import("./audiobookshelf/component")),
|
audiobookshelf: dynamic(() => import("./audiobookshelf/component")),
|
||||||
authentik: dynamic(() => import("./authentik/component")),
|
authentik: dynamic(() => import("./authentik/component")),
|
||||||
autobrr: dynamic(() => import("./autobrr/component")),
|
autobrr: dynamic(() => import("./autobrr/component")),
|
||||||
|
azurePullrequests: dynamic(() => import("./azurePullrequests/component")),
|
||||||
bazarr: dynamic(() => import("./bazarr/component")),
|
bazarr: dynamic(() => import("./bazarr/component")),
|
||||||
caddy: dynamic(() => import("./caddy/component")),
|
caddy: dynamic(() => import("./caddy/component")),
|
||||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import adguard from "./adguard/widget";
|
|||||||
import audiobookshelf from "./audiobookshelf/widget";
|
import audiobookshelf from "./audiobookshelf/widget";
|
||||||
import authentik from "./authentik/widget";
|
import authentik from "./authentik/widget";
|
||||||
import autobrr from "./autobrr/widget";
|
import autobrr from "./autobrr/widget";
|
||||||
|
import azurePullrequests from "./azurePullrequests/widget";
|
||||||
import bazarr from "./bazarr/widget";
|
import bazarr from "./bazarr/widget";
|
||||||
import caddy from "./caddy/widget";
|
import caddy from "./caddy/widget";
|
||||||
import changedetectionio from "./changedetectionio/widget";
|
import changedetectionio from "./changedetectionio/widget";
|
||||||
@ -91,6 +92,7 @@ const widgets = {
|
|||||||
audiobookshelf,
|
audiobookshelf,
|
||||||
authentik,
|
authentik,
|
||||||
autobrr,
|
autobrr,
|
||||||
|
azurePullrequests,
|
||||||
bazarr,
|
bazarr,
|
||||||
caddy,
|
caddy,
|
||||||
changedetectionio,
|
changedetectionio,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user