@growth-operations/ui-shared 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/home/HelpfulLinks.jsx +67 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Flex, Text, Link, Divider } from "@hubspot/ui-extensions";
|
|
3
|
+
|
|
4
|
+
// Build the in-app app-pages deep link (the app's Home/tabs live under /app).
|
|
5
|
+
function appPagesUrl(portalId, appId, pagePath = "") {
|
|
6
|
+
const suffix = pagePath ? `/${pagePath.replace(/^\//, "")}` : "";
|
|
7
|
+
return `https://app.hubspot.com/app/${portalId}/${appId}${suffix}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// HelpfulLinks — a standard "Helpful Links" section for every Growth Operations
|
|
11
|
+
// app. Renders a labeled list of links: optionally an "Open <app>" deep link
|
|
12
|
+
// back to the app pages (so the settings extension isn't a dead end), docs +
|
|
13
|
+
// support from the app config, and any app-specific extras.
|
|
14
|
+
//
|
|
15
|
+
// Props:
|
|
16
|
+
// portalId — context.portal.id (number/string).
|
|
17
|
+
// appId — this app's HubSpot app id (per-env). Needed for the app-pages
|
|
18
|
+
// deep link; omit to hide that link.
|
|
19
|
+
// appName — display name, e.g. "Sparkfly" (used in the deep-link label).
|
|
20
|
+
// appPages — when true (default) and appId is set, show "Open <appName> →"
|
|
21
|
+
// linking to the app pages. Set the page path via appPagesPath.
|
|
22
|
+
// appPagesPath — optional pages route to deep-link into (default: Home).
|
|
23
|
+
// docsUrl, supportUrl — external help links (omit to hide).
|
|
24
|
+
// links — app-specific extras: [{ label, url }]. Rendered after the
|
|
25
|
+
// standard links.
|
|
26
|
+
// title — section heading (default "Helpful Links").
|
|
27
|
+
export function HelpfulLinks({
|
|
28
|
+
portalId,
|
|
29
|
+
appId,
|
|
30
|
+
appName = "the app",
|
|
31
|
+
appPages = true,
|
|
32
|
+
appPagesPath = "",
|
|
33
|
+
docsUrl,
|
|
34
|
+
supportUrl,
|
|
35
|
+
links = [],
|
|
36
|
+
title = "Helpful Links",
|
|
37
|
+
}) {
|
|
38
|
+
const items = [];
|
|
39
|
+
|
|
40
|
+
if (appPages && appId && portalId != null) {
|
|
41
|
+
items.push({
|
|
42
|
+
label: `Open ${appName} →`,
|
|
43
|
+
url: appPagesUrl(portalId, appId, appPagesPath),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (docsUrl) items.push({ label: "Documentation", url: docsUrl });
|
|
47
|
+
if (supportUrl) items.push({ label: "Support", url: supportUrl });
|
|
48
|
+
for (const l of links) {
|
|
49
|
+
if (l && l.url && l.label) items.push({ label: l.label, url: l.url });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (items.length === 0) return null;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Flex direction="column" gap="small">
|
|
56
|
+
<Text format={{ fontWeight: "bold" }}>{title}</Text>
|
|
57
|
+
<Divider />
|
|
58
|
+
{items.map((item) => (
|
|
59
|
+
<Link key={item.url} href={{ url: item.url, external: true }}>
|
|
60
|
+
{item.label}
|
|
61
|
+
</Link>
|
|
62
|
+
))}
|
|
63
|
+
</Flex>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default HelpfulLinks;
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { OnboardingChecklist } from "./home/OnboardingChecklist";
|
|
|
12
12
|
export { SyncPulse } from "./home/SyncPulse";
|
|
13
13
|
export { FeatureNudges } from "./home/FeatureNudges";
|
|
14
14
|
export { CreditMeter } from "./home/CreditMeter";
|
|
15
|
+
export { HelpfulLinks } from "./home/HelpfulLinks";
|
|
15
16
|
|
|
16
17
|
// Billing.
|
|
17
18
|
export { BillingTab } from "./billing/BillingTab";
|