diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 94fee9e2..3ce8decb 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -278,7 +278,6 @@ export function cleanServiceGroups(groups) { server, // docker widget container, currency, // coinmarketcap widget - userEmail, // azuredevops symbols, slugs, defaultinterval, @@ -294,6 +293,8 @@ export function cleanServiceGroups(groups) { node, // Proxmox snapshotHost, // kopia snapshotPath, + userEmail, // azuredevops + branchName } = cleanedService.widget; let fieldsList = fields; @@ -315,6 +316,7 @@ export function cleanServiceGroups(groups) { if (type === "azuredevops") { if (userEmail) cleanedService.widget.userEmail = userEmail; + if (branchName) cleanedService.widget.branchName = branchName; } if (type === "coinmarketcap") { diff --git a/src/widgets/azuredevops/component.jsx b/src/widgets/azuredevops/component.jsx index 7838a7a2..433ae800 100644 --- a/src/widgets/azuredevops/component.jsx +++ b/src/widgets/azuredevops/component.jsx @@ -7,16 +7,24 @@ import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; - const { userEmail } = widget; + const { userEmail, branchName } = widget; + const includePR = userEmail !== undefined && branchName !== undefined; const { data: prData, error: prError } = useWidgetAPI(widget, "pr"); const { data: pipelineData, error: pipelineError } = useWidgetAPI(widget, "pipeline"); - if (pipelineError || prError) { - const finalError = pipelineError ?? prError; + if ( + pipelineError || + (includePR && (prError || prData?.errorCode !== null)) + ) { + 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)) { + if (!pipelineData || !Array.isArray(pipelineData.value) || (includePR && !prData)) { return ( @@ -35,22 +43,26 @@ export default function Component({ service }) { )} - - item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase()) - .length, - })} - /> - item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase()) - .filter((item) => item.reviewers.some((reviewer) => reviewer.vote === 10)).length, - })} - /> + {includePR && + <> + + item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase()) + .length, + })} + /> + item.createdBy.uniqueName.toLowerCase() === userEmail.toLowerCase()) + .filter((item) => item.reviewers.some((reviewer) => reviewer.vote === 10)).length, + })} + /> + + } );