chore(ui): improve provider wizard docs link labels (#10244)

This commit is contained in:
Alejandro Bailo
2026-03-04 09:33:32 +01:00
committed by GitHub
parent e8d2b4a189
commit 73415e2f8a
3 changed files with 36 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ export function ProviderWizardModal({
<Button variant="link" size="link-sm" className="h-auto p-0" asChild>
<a href={docsLink} target="_blank" rel="noopener noreferrer">
<ExternalLink className="size-3.5 shrink-0" />
<span>{`Prowler Docs (${docsDestination})`}</span>
<span>{`${docsDestination} documentation`}</span>
</a>
</Button>
</div>

View File

@@ -58,7 +58,7 @@ describe("getProviderWizardDocsDestination", () => {
"https://goto.prowler.com/provider-aws",
);
expect(destination).toBe("aws");
expect(destination).toBe("AWS");
});
it("returns a compact destination label for long docs links", () => {
@@ -66,6 +66,6 @@ describe("getProviderWizardDocsDestination", () => {
"https://docs.prowler.com/user-guide/tutorials/prowler-cloud-aws-organizations",
);
expect(destination).toBe("aws-organizations");
expect(destination).toBe("AWS Organizations");
});
});

View File

@@ -29,6 +29,24 @@ export function getProviderWizardModalTitle(mode: ProviderWizardMode) {
}
export function getProviderWizardDocsDestination(docsLink: string) {
const destinationLabelMap: Record<string, string> = {
"aws-organizations": "AWS Organizations",
aws: "AWS",
azure: "Azure",
m365: "Microsoft 365",
gcp: "GCP",
k8s: "Kubernetes",
kubernetes: "Kubernetes",
github: "GitHub",
iac: "IaC",
oraclecloud: "Oracle Cloud",
mongodbatlas: "MongoDB Atlas",
alibabacloud: "Alibaba Cloud",
cloudflare: "Cloudflare",
openstack: "OpenStack",
help: "Cloud Provider",
};
try {
const parsed = new URL(docsLink);
const pathSegments = parsed.pathname
@@ -40,7 +58,21 @@ export function getProviderWizardDocsDestination(docsLink: string) {
return parsed.hostname;
}
return lastSegment.replace(/^provider-/, "").replace(/^prowler-cloud-/, "");
const compactDestination = lastSegment
.replace(/^provider-/, "")
.replace(/^prowler-cloud-/, "");
const mappedDestination = destinationLabelMap[compactDestination];
if (mappedDestination) {
return mappedDestination;
}
return compactDestination
.split("-")
.map((word) =>
word.length === 0 ? word : word[0].toUpperCase() + word.slice(1),
)
.join(" ");
} catch {
return docsLink;
}