mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-21 18:58:04 +00:00
chore(ui): improve provider wizard docs link labels (#10244)
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user