diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 6091c0b1..66aa19ab 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -665,7 +665,7 @@
"seriesCount": "Series",
"totalFiles": "Files"
},
- "azurePipelines": {
+ "azuredevops": {
"result": "Result",
"status": "Status",
"buildId": "Build ID",
@@ -673,7 +673,10 @@
"notStarted": "Not Started",
"failed": "Failed",
"canceled": "Canceled",
- "inProgress": "In Progress"
+ "inProgress": "In Progress",
+ "totalPrs": "Total PRs",
+ "myPrs": "My PRs",
+ "approved": "Approved"
},
"gamedig": {
"name": "Name",
diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js
index dc625f2e..92fa7b22 100644
--- a/src/utils/config/service-helpers.js
+++ b/src/utils/config/service-helpers.js
@@ -293,6 +293,8 @@ export function cleanServiceGroups(groups) {
node, // Proxmox
snapshotHost, // kopia
snapshotPath,
+ userEmail, // azuredevops
+ repositoryId
} = cleanedService.widget;
let fieldsList = fields;
@@ -312,6 +314,11 @@ export function cleanServiceGroups(groups) {
service_group: serviceGroup.name,
};
+ if (type === "azuredevops") {
+ if (userEmail) cleanedService.widget.userEmail = userEmail;
+ if (repositoryId) cleanedService.widget.repositoryId = repositoryId;
+ }
+
if (type === "coinmarketcap") {
if (currency) cleanedService.widget.currency = currency;
if (symbols) cleanedService.widget.symbols = symbols;
diff --git a/src/utils/proxy/api-helpers.js b/src/utils/proxy/api-helpers.js
index ca2721ec..be73a5b7 100644
--- a/src/utils/proxy/api-helpers.js
+++ b/src/utils/proxy/api-helpers.js
@@ -5,7 +5,7 @@ export function formatApiCall(url, args) {
return args[key] || "";
};
- return url.replace(/\/+$/, "").replace(find, replace);
+ return url.replace(/\/+$/, "").replace(find, replace).replace(find,replace);
}
function getURLSearchParams(widget, endpoint) {
diff --git a/src/utils/proxy/handlers/credentialed.js b/src/utils/proxy/handlers/credentialed.js
index 3d181ead..498c0d6d 100644
--- a/src/utils/proxy/handlers/credentialed.js
+++ b/src/utils/proxy/handlers/credentialed.js
@@ -62,7 +62,7 @@ export default async function credentialedProxyHandler(req, res, map) {
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
}
}
- else if (widget.type === "azurePipelines") {
+ else if (widget.type === "azuredevops") {
headers.Authorization = `Basic ${Buffer.from(`$:${widget.key}`).toString("base64")}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
diff --git a/src/widgets/azurePipelines/component.jsx b/src/widgets/azurePipelines/component.jsx
deleted file mode 100644
index a47296f3..00000000
--- a/src/widgets/azurePipelines/component.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-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: pipelineData, error: pipelineError } = useWidgetAPI(widget);
-
- if (pipelineError) {
- return ;
- }
-
- if (!pipelineData || !Array.isArray(pipelineData.value)) {
- return (
-
-
-
-
- );
- }
-
- return (
-
- {pipelineData.value[0].result ?
- :
-
- }
-
-
- );
-}
diff --git a/src/widgets/azurePipelines/widget.js b/src/widgets/azurePipelines/widget.js
deleted file mode 100644
index 708266d2..00000000
--- a/src/widgets/azurePipelines/widget.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
-
-const widget = {
- api: "https://dev.azure.com/{organization}/{project}/_apis/build/Builds?branchName={branchName}&definitions={definitionId}",
- proxyHandler: credentialedProxyHandler,
-};
-
-export default widget;
\ No newline at end of file
diff --git a/src/widgets/azuredevops/component.jsx b/src/widgets/azuredevops/component.jsx
new file mode 100644
index 00000000..a9db4403
--- /dev/null
+++ b/src/widgets/azuredevops/component.jsx
@@ -0,0 +1,65 @@
+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 { userEmail, repositoryId } = widget;
+ const includePR = userEmail !== undefined && repositoryId !== undefined;
+ const { data: prData, error: prError } = useWidgetAPI(widget, includePR ? "pr" : null);
+ const { data: pipelineData, error: pipelineError } = useWidgetAPI(widget, "pipeline");
+
+ if (
+ pipelineError ||
+ (includePR && (prError || prData?.errorCode !== undefined))
+ ) {
+ let finalError = pipelineError ?? prError;
+ if (includePR && prData?.errorCode !== null) {
+ // pr call failed possibly with more specific message
+ finalError = { message: prData?.message ?? 'Error communicating with Azure API' }
+ }
+ return ;
+ }
+
+ if (!pipelineData || !Array.isArray(pipelineData.value) || (includePR && !prData)) {
+ return (
+
+
+
+
+
+
+ );
+ }
+
+ return (
+
+ {pipelineData.value[0].result ? (
+
+ ) : (
+
+ )}
+
+ {includePR && }
+ {includePR && item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase())
+ .length,
+ })}
+ />}
+ {includePR && item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase())
+ .filter((item) => item.reviewers.some((reviewer) => reviewer.vote === 10)).length,
+ })}
+ />}
+
+
+ );
+}
diff --git a/src/widgets/azuredevops/widget.js b/src/widgets/azuredevops/widget.js
new file mode 100644
index 00000000..84c9fdf3
--- /dev/null
+++ b/src/widgets/azuredevops/widget.js
@@ -0,0 +1,18 @@
+import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
+
+const widget = {
+ api: "https://dev.azure.com/{organization}/{project}/_apis/{endpoint}",
+ proxyHandler: credentialedProxyHandler,
+
+ mappings: {
+ pr: {
+ endpoint: "git/repositories/{repositoryId}/pullrequests"
+ },
+
+ pipeline: {
+ endpoint: "build/Builds?branchName={branchName}&definitions={definitionId}&$top=1"
+ },
+ },
+};
+
+export default widget;
diff --git a/src/widgets/components.js b/src/widgets/components.js
index 4b7ef50c..0c372ce9 100644
--- a/src/widgets/components.js
+++ b/src/widgets/components.js
@@ -5,7 +5,7 @@ const components = {
audiobookshelf: dynamic(() => import("./audiobookshelf/component")),
authentik: dynamic(() => import("./authentik/component")),
autobrr: dynamic(() => import("./autobrr/component")),
- azurePipelines: dynamic(() => import("./azurePipelines/component")),
+ azuredevops: dynamic(() => import("./azuredevops/component")),
bazarr: dynamic(() => import("./bazarr/component")),
caddy: dynamic(() => import("./caddy/component")),
changedetectionio: dynamic(() => import("./changedetectionio/component")),
diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js
index 6ae47efd..14dc2cd2 100644
--- a/src/widgets/widgets.js
+++ b/src/widgets/widgets.js
@@ -2,7 +2,7 @@ import adguard from "./adguard/widget";
import audiobookshelf from "./audiobookshelf/widget";
import authentik from "./authentik/widget";
import autobrr from "./autobrr/widget";
-import azurePipelines from "./azurePipelines/widget";
+import azuredevops from "./azuredevops/widget";
import bazarr from "./bazarr/widget";
import caddy from "./caddy/widget";
import changedetectionio from "./changedetectionio/widget";
@@ -93,7 +93,7 @@ const widgets = {
audiobookshelf,
authentik,
autobrr,
- azurePipelines,
+ azuredevops,
bazarr,
caddy,
changedetectionio,