@camunda/camunda-composite-components 0.19.1 → 0.20.1
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/lib/esm/package.json +3 -3
- package/lib/esm/src/api/api.d.ts +1 -0
- package/lib/esm/src/api/api.js +1 -0
- package/lib/esm/src/api/endpoints.const.d.ts +1 -0
- package/lib/esm/src/api/endpoints.const.js +6 -0
- package/lib/esm/src/api/help-center.d.ts +2 -1
- package/lib/esm/src/api/help-center.js +10 -6
- package/lib/esm/src/api/status.d.ts +7 -0
- package/lib/esm/src/api/status.js +41 -0
- package/lib/esm/src/components/c3-app-teaser/c3-app-teaser-page.js +6 -30
- package/lib/esm/src/components/c3-app-teaser/c3-app-teaser.js +6 -19
- package/lib/esm/src/components/c3-data-table/c3-data-table.js +10 -6
- package/lib/esm/src/components/c3-empty-state/c3-empty-state.js +13 -2
- package/lib/esm/src/components/c3-help-center/c3-help-center-provider.d.ts +17 -0
- package/lib/esm/src/components/c3-help-center/c3-help-center-provider.js +118 -2
- package/lib/esm/src/components/c3-help-center/c3-help-center.d.ts +0 -2
- package/lib/esm/src/components/c3-help-center/c3-help-center.js +33 -68
- package/lib/esm/src/components/c3-help-center/help-center.js +81 -80
- package/lib/esm/src/components/c3-help-center/styles.js +3 -0
- package/lib/esm/src/components/c3-help-center/tile.js +41 -35
- package/lib/esm/src/components/c3-navigation/c3-navigation-appbar/c3-navigation-appbar.js +14 -0
- package/lib/esm/src/components/c3-navigation/c3-navigation.js +81 -8
- package/lib/esm/src/components/c3-navigation/c3-navigation.types.d.ts +1 -0
- package/lib/esm/src/components/c3-navigation/c3-org-name.js +0 -1
- package/lib/esm/src/components/c3-onboarding-survey/c3-onboarding-survey.js +8 -36
- package/lib/esm/src/components/c3-onboarding-survey/elements/dropdownSelect.js +2 -1
- package/lib/esm/src/components/c3-user-configuration/c3-user-configuration-provider.js +5 -12
- package/package.json +3 -3
package/lib/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camunda/camunda-composite-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"@carbon/react": "1.x",
|
|
106
106
|
"event-source-polyfill": "1.0.x",
|
|
107
|
-
"react": "18.x",
|
|
108
|
-
"react-dom": "18.x",
|
|
107
|
+
"react": "18.x || 19.x",
|
|
108
|
+
"react-dom": "18.x || 19.x",
|
|
109
109
|
"styled-components": "5.x || 6.x"
|
|
110
110
|
},
|
|
111
111
|
"description": "Camunda Composite Components",
|
package/lib/esm/src/api/api.d.ts
CHANGED
package/lib/esm/src/api/api.js
CHANGED
|
@@ -12,6 +12,7 @@ export interface Endpoints {
|
|
|
12
12
|
export declare const NOTIFICATIONS: Endpoint;
|
|
13
13
|
export declare const ACCOUNTS: Endpoint;
|
|
14
14
|
export declare const CONSOLE: Endpoint;
|
|
15
|
+
export declare const STATUS: Endpoint;
|
|
15
16
|
export type Stage = "dev" | "int" | "prod";
|
|
16
17
|
export declare function getEndpoint(stage: Stage, endpoint: Endpoint): string;
|
|
17
18
|
export declare function getEndpointByOptions(options: {
|
|
@@ -16,6 +16,12 @@ export const CONSOLE = {
|
|
|
16
16
|
int: "https://console.cloud.ultrawombat.com",
|
|
17
17
|
prod: "https://console.cloud.camunda.io",
|
|
18
18
|
};
|
|
19
|
+
export const STATUS = {
|
|
20
|
+
id: "status",
|
|
21
|
+
dev: "https://camundaultrawombat.statuspage.io/",
|
|
22
|
+
int: "https://camundaultrawombat.statuspage.io/",
|
|
23
|
+
prod: "https://status.camunda.io",
|
|
24
|
+
};
|
|
19
25
|
export function getEndpoint(stage, endpoint) {
|
|
20
26
|
switch (stage) {
|
|
21
27
|
case "dev":
|
|
@@ -3,7 +3,7 @@ import { Persona, TileConfig, WpCardType } from "../components/c3-help-center/c3
|
|
|
3
3
|
import { OnboardingConfig } from "../components/c3-onboarding-survey/defaultOnboardingConfig";
|
|
4
4
|
import { RequestPayload, RequestResponse } from "./api";
|
|
5
5
|
export declare const getConfig: (accessToken: string, audience: string, orgId: string) => Promise<RequestResponse<HelpCenterConfig | null>>;
|
|
6
|
-
export declare const getTiles: ({ accessToken, tileConfig, salesPlanType, clusterIds, persona, flags, cloudAudience, }: {
|
|
6
|
+
export declare const getTiles: ({ accessToken, tileConfig, salesPlanType, clusterIds, persona, flags, cloudAudience, signal, }: {
|
|
7
7
|
accessToken: string;
|
|
8
8
|
tileConfig: TileConfig[];
|
|
9
9
|
cloudAudience: string;
|
|
@@ -13,6 +13,7 @@ export declare const getTiles: ({ accessToken, tileConfig, salesPlanType, cluste
|
|
|
13
13
|
clusterIds: string[];
|
|
14
14
|
salesPlanType: string;
|
|
15
15
|
flags: string[];
|
|
16
|
+
signal?: AbortSignal | undefined;
|
|
16
17
|
}) => Promise<RequestResponse<WpCardType[]>>;
|
|
17
18
|
export declare const getOnboardingConfig: ({ camundaAuth, audience, orgId, }: {
|
|
18
19
|
audience: string;
|
|
@@ -8,13 +8,17 @@ export const getConfig = async (accessToken, audience, orgId) => {
|
|
|
8
8
|
},
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
export const getTiles = async ({ accessToken, tileConfig, salesPlanType, clusterIds, persona, flags, cloudAudience, }) => {
|
|
11
|
+
export const getTiles = async ({ accessToken, tileConfig, salesPlanType, clusterIds, persona, flags, cloudAudience, signal, }) => {
|
|
12
12
|
const availableTileTypes = recommendations(persona, flags, tileConfig, salesPlanType, clusterIds?.length > 0);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (availableTileTypes.length) {
|
|
14
|
+
return await request({
|
|
15
|
+
url: `https://helpcenter.${cloudAudience}/cards?card_id=${availableTileTypes.join(",")}`,
|
|
16
|
+
responseType: "json",
|
|
17
|
+
camundaAuth: { token: accessToken },
|
|
18
|
+
signal,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return { success: true };
|
|
18
22
|
};
|
|
19
23
|
export const getOnboardingConfig = ({ camundaAuth, audience, orgId, }) => request({
|
|
20
24
|
url: `https://helpcenter.${audience}/survey/config/${orgId}`,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { request } from "./api";
|
|
2
|
+
import { getEndpoint, STATUS } from "./endpoints.const";
|
|
3
|
+
export class StatusService {
|
|
4
|
+
static async camundaStatus(decodedAudience) {
|
|
5
|
+
try {
|
|
6
|
+
let stage = "dev";
|
|
7
|
+
switch (decodedAudience) {
|
|
8
|
+
case "cloud.dev.ultrawombat.com":
|
|
9
|
+
stage = "dev";
|
|
10
|
+
break;
|
|
11
|
+
case "cloud.ultrawombat.com":
|
|
12
|
+
stage = "int";
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
stage = "prod";
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
const endpoint = getEndpoint(stage, STATUS);
|
|
19
|
+
const resp = await request({
|
|
20
|
+
url: `${endpoint}/api/v2/status.json`,
|
|
21
|
+
method: "get",
|
|
22
|
+
type: "json",
|
|
23
|
+
responseType: "json",
|
|
24
|
+
});
|
|
25
|
+
let result = resp.result;
|
|
26
|
+
if (!resp.success ||
|
|
27
|
+
!result?.status.indicator ||
|
|
28
|
+
!result?.status.description) {
|
|
29
|
+
return { error: false, description: "", endpoint };
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
error: result?.status.indicator === "major",
|
|
33
|
+
description: result?.status.description ?? "",
|
|
34
|
+
endpoint,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (_error) {
|
|
38
|
+
return { error: false, description: "", endpoint: STATUS.dev };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { C3AppTeaser } from "./c3-app-teaser";
|
|
3
3
|
import { canCreateCluster, canUpgradePlan, isTrialExpired, } from "../../utils/camunda";
|
|
4
4
|
import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
|
|
5
5
|
import { Loading } from "@carbon/react";
|
|
6
|
-
import { getStartingPrice } from "../../api/organizations";
|
|
7
6
|
import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
|
|
8
7
|
export const C3AppTeaserPage = ({ appName, redirectToClusters, redirectToCreateCluster, redirectToCheckout, }) => {
|
|
9
|
-
const { activeOrganizationId,
|
|
8
|
+
const { activeOrganizationId, domain, analyticsTrack } = useC3UserConfiguration();
|
|
10
9
|
const { activeOrg, clusters } = useC3Profile();
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!userToken || !decodedAudience)
|
|
16
|
-
return;
|
|
17
|
-
(async () => {
|
|
18
|
-
const { result } = await getStartingPrice({
|
|
19
|
-
token: userToken,
|
|
20
|
-
audience: decodedAudience,
|
|
21
|
-
});
|
|
22
|
-
if (result) {
|
|
23
|
-
setPricing(result);
|
|
24
|
-
}
|
|
25
|
-
})();
|
|
26
|
-
}, [userToken, decodedAudience]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (activeOrg)
|
|
29
|
-
setHasTrialExpired(isTrialExpired(activeOrg));
|
|
30
|
-
}, [activeOrg]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (clusters && appName) {
|
|
33
|
-
const sleepingCluster = clusters.find((c) => c.status[appName] === "Suspended");
|
|
34
|
-
setHasSleepingCluster(!!sleepingCluster);
|
|
35
|
-
}
|
|
36
|
-
}, [clusters, appName]);
|
|
10
|
+
const hasTrialExpired = (activeOrg && isTrialExpired(activeOrg)) ?? false;
|
|
11
|
+
const sleepingCluster = clusters && clusters.find((c) => c.status[appName] === "Suspended");
|
|
12
|
+
const hasSleepingCluster = (clusters && appName && !!sleepingCluster) ?? false;
|
|
37
13
|
const onClickCta = () => {
|
|
38
14
|
if (hasTrialExpired) {
|
|
39
15
|
analyticsTrack?.("checkout:open", { appTeaser: appName });
|
|
@@ -63,5 +39,5 @@ export const C3AppTeaserPage = ({ appName, redirectToClusters, redirectToCreateC
|
|
|
63
39
|
}
|
|
64
40
|
}
|
|
65
41
|
};
|
|
66
|
-
return activeOrg && appName ? (React.createElement(C3AppTeaser, { appName: appName, canCreateCluster: canCreateCluster(activeOrg), canUpgradePlan: canUpgradePlan(activeOrg), hasTrialExpired: hasTrialExpired, hasSleepingCluster: hasSleepingCluster, onClickCta: onClickCta, pricing:
|
|
42
|
+
return activeOrg && appName ? (React.createElement(C3AppTeaser, { appName: appName, canCreateCluster: canCreateCluster(activeOrg), canUpgradePlan: canUpgradePlan(activeOrg), hasTrialExpired: hasTrialExpired, hasSleepingCluster: hasSleepingCluster, onClickCta: onClickCta, pricing: null })) : (React.createElement(Loading, { withOverlay: true }));
|
|
67
43
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Add,
|
|
2
|
+
import { Add, Settings } from "@carbon/react/icons";
|
|
3
3
|
import { AppTeaserCards } from "./app-teaser-cards";
|
|
4
4
|
import { getReadableAppName } from "../../utils/camunda";
|
|
5
5
|
import { DefaultStyleWrapper } from "../styles";
|
|
6
6
|
import { appTeaserCardsConfig } from "./app-teaser-cards-config";
|
|
7
7
|
export const teaserApps = ["tasklist", "operate", "optimize"];
|
|
8
|
-
export const C3AppTeaser = ({ appName: app, hasTrialExpired, hasSleepingCluster, canUpgradePlan, canCreateCluster, onClickCta,
|
|
8
|
+
export const C3AppTeaser = ({ appName: app, hasTrialExpired, hasSleepingCluster, canUpgradePlan, canCreateCluster, onClickCta, }) => {
|
|
9
9
|
const appName = app ? getReadableAppName(app) : "";
|
|
10
10
|
const variants = {
|
|
11
11
|
upgrade: {
|
|
12
12
|
title: `Upgrade your plan${appName ? ` to use ${appName}` : ""}`,
|
|
13
13
|
subtitle: `Creating a cluster and accessing the ${appName} app and features
|
|
14
14
|
are not available with the Modeling plan`,
|
|
15
|
-
ctaText: "
|
|
16
|
-
ctaIcon:
|
|
15
|
+
ctaText: "Contact us",
|
|
16
|
+
ctaIcon: null,
|
|
17
17
|
disabledMessage: "Contact your admin to upgrade",
|
|
18
18
|
},
|
|
19
19
|
manageClusters: {
|
|
20
20
|
title: `Resume your cluster${appName ? ` to use ${appName}` : ""}`,
|
|
21
|
-
subtitle: `The ${appName} app requires an active
|
|
21
|
+
subtitle: `The ${appName} app requires an active
|
|
22
22
|
cluster to run.`,
|
|
23
23
|
ctaText: "Manage clusters",
|
|
24
24
|
ctaIcon: Settings,
|
|
@@ -38,21 +38,8 @@ export const C3AppTeaser = ({ appName: app, hasTrialExpired, hasSleepingCluster,
|
|
|
38
38
|
: hasSleepingCluster
|
|
39
39
|
? variants.manageClusters
|
|
40
40
|
: variants.createClusters;
|
|
41
|
-
const currency = pricing?.currency === "€" ? "EUR" : pricing?.currency;
|
|
42
|
-
const locale = navigator.language || "en";
|
|
43
|
-
const price = pricing?.amount &&
|
|
44
|
-
currency &&
|
|
45
|
-
locale &&
|
|
46
|
-
Intl.NumberFormat(locale, {
|
|
47
|
-
style: "currency",
|
|
48
|
-
currency,
|
|
49
|
-
minimumFractionDigits: 0,
|
|
50
|
-
maximumFractionDigits: pricing.amount % 1 === 0 ? 0 : 2,
|
|
51
|
-
}).format(pricing.amount);
|
|
52
41
|
return (React.createElement(DefaultStyleWrapper, null,
|
|
53
|
-
React.createElement(AppTeaserCards, { title: variant.title, subtitle: React.createElement(React.Fragment, null, variant.subtitle), subtext:
|
|
54
|
-
? `Plans starting at ${price}${pricing.interval ? `/${pricing.interval}` : ""}`
|
|
55
|
-
: "", cta: {
|
|
42
|
+
React.createElement(AppTeaserCards, { title: variant.title, subtitle: React.createElement(React.Fragment, null, variant.subtitle), subtext: "", cta: {
|
|
56
43
|
action: onClickCta,
|
|
57
44
|
text: variant.ctaText,
|
|
58
45
|
renderIcon: variant.ctaIcon,
|
|
@@ -325,7 +325,8 @@ export const C3DataTable = ({ data, headers, options, toolbar: singleToolbar, to
|
|
|
325
325
|
}
|
|
326
326
|
else if (toolbarElement.type === "search") {
|
|
327
327
|
const searchElement = toolbarElement;
|
|
328
|
-
const
|
|
328
|
+
const filterId = searchElement.id ?? searchElement.queryName;
|
|
329
|
+
const defaultValue = currentFilters.current.get(filterId);
|
|
329
330
|
toolbarComponents.push(React.createElement(TableToolbarSearch, { key: searchElement.id, onFocus: (event, handleExpand) => {
|
|
330
331
|
handleExpand(event, true);
|
|
331
332
|
if (searchElement.queryName) {
|
|
@@ -337,16 +338,15 @@ export const C3DataTable = ({ data, headers, options, toolbar: singleToolbar, to
|
|
|
337
338
|
}
|
|
338
339
|
updateFilterURLState(searchElement.queryName ?? searchElement.id, event.target.value);
|
|
339
340
|
}, onChange: (event) => {
|
|
340
|
-
currentFilters.current.set(
|
|
341
|
-
searchTerm: event.target?.value ??
|
|
342
|
-
getQueryKey(searchElement.queryName ?? ""),
|
|
341
|
+
currentFilters.current.set(filterId, {
|
|
342
|
+
searchTerm: event.target?.value ?? defaultValue?.searchTerm,
|
|
343
343
|
});
|
|
344
344
|
updateFilteredData();
|
|
345
345
|
} }));
|
|
346
346
|
}
|
|
347
347
|
else if (toolbarElement.type === "button") {
|
|
348
348
|
const buttonElement = toolbarElement;
|
|
349
|
-
toolbarComponents.push(React.createElement(Button, { key: buttonElement.id, onClick: () => {
|
|
349
|
+
toolbarComponents.push(React.createElement(Button, { id: buttonElement.id, key: buttonElement.id, onClick: () => {
|
|
350
350
|
if (buttonElement.onClick) {
|
|
351
351
|
buttonElement.onClick();
|
|
352
352
|
}
|
|
@@ -444,7 +444,11 @@ export const C3DataTable = ({ data, headers, options, toolbar: singleToolbar, to
|
|
|
444
444
|
headerKeys.map((key) => {
|
|
445
445
|
return rowCell(key);
|
|
446
446
|
}),
|
|
447
|
-
hasActions && (React.createElement(TableCell, { style: { textAlign: "right" } },
|
|
447
|
+
hasActions && (React.createElement(TableCell, { style: { textAlign: "right" } },
|
|
448
|
+
React.createElement("div", { style: {
|
|
449
|
+
display: "flex",
|
|
450
|
+
alignItems: "center",
|
|
451
|
+
} }, renderActions(row))))));
|
|
448
452
|
if (row.expansion) {
|
|
449
453
|
rowComponent = (React.createElement(React.Fragment, { key: row.id },
|
|
450
454
|
React.createElement(TableExpandRow, { key: row.id, isExpanded: isRowExpanded(row), "aria-label": `row ${row.id}`, onExpand: () => {
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { Stack, Tile, Button, Link, MenuButton, MenuItem } from "@carbon/react";
|
|
2
|
+
import styled from "styled-components";
|
|
2
3
|
import React from "react";
|
|
4
|
+
const ResponsiveStack = styled.div `
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: ${({ orientation }) => `${orientation === "vertical" ? "column" : "row"}`};
|
|
7
|
+
gap: ${({ gap }) => `${typeof gap === "string" ? gap : `${gap ?? 0 * 16}px`}`};
|
|
8
|
+
|
|
9
|
+
@media (max-width: 768px) {
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
3
13
|
export const C3EmptyState = ({ icon, heading, description, button, link, }) => (React.createElement(Tile, { style: {
|
|
4
14
|
paddingLeft: "5rem",
|
|
5
15
|
paddingTop: "3rem",
|
|
6
16
|
paddingBottom: "3rem",
|
|
7
17
|
} },
|
|
8
|
-
React.createElement(
|
|
9
|
-
icon && React.createElement("
|
|
18
|
+
React.createElement(ResponsiveStack, { orientation: "horizontal", gap: "1.5rem" },
|
|
19
|
+
icon && (React.createElement("div", { style: { maxWidth: "80px" } },
|
|
20
|
+
React.createElement("img", { src: icon.path, alt: icon.altText }))),
|
|
10
21
|
React.createElement(Stack, { gap: 3 },
|
|
11
22
|
React.createElement("h2", null, heading),
|
|
12
23
|
React.createElement(Stack, { gap: 6 },
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React, { FC, PropsWithChildren } from "react";
|
|
2
|
+
import { HelpCenterConfig } from "./defaultHelpCenterConfig";
|
|
3
|
+
import { Persona, WpCardType } from "./c3-help-center.types";
|
|
4
|
+
import { OnboardingConfig } from "../c3-onboarding-survey/defaultOnboardingConfig";
|
|
2
5
|
export declare enum HelpCenterHintType {
|
|
3
6
|
HelpCenter = "help-center",
|
|
4
7
|
Onboarding = "onboarding"
|
|
@@ -13,6 +16,20 @@ export type C3HelpCenterContextValue = {
|
|
|
13
16
|
setShowHintOnClose: (showHintOnClose: boolean) => void;
|
|
14
17
|
hintType: HelpCenterHintType;
|
|
15
18
|
setHintType: (hintType: HelpCenterHintType) => void;
|
|
19
|
+
helpCenterConfig: HelpCenterConfig;
|
|
20
|
+
persona: Persona | undefined;
|
|
21
|
+
setPersona: (persona: Persona | undefined) => void;
|
|
22
|
+
rawTabTiles: {
|
|
23
|
+
[id: string]: WpCardType[];
|
|
24
|
+
};
|
|
25
|
+
isLoadingTiles: boolean;
|
|
26
|
+
updateFlags: (flags: string[]) => void;
|
|
27
|
+
updateAutoStartSurvey: (autoStart: boolean) => void;
|
|
28
|
+
showSurvey: boolean;
|
|
29
|
+
setShowSurvey: (showSurvey: boolean) => void;
|
|
30
|
+
onboadingConfig: OnboardingConfig;
|
|
31
|
+
isLoadingOnboardingConfig: boolean;
|
|
32
|
+
getOnboadingSurveyConfig: (audience: string) => Promise<void>;
|
|
16
33
|
};
|
|
17
34
|
export declare const C3HelpCenterContext: React.Context<C3HelpCenterContextValue>;
|
|
18
35
|
export declare const C3HelpCenterProvider: FC<PropsWithChildren>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState, } from "react";
|
|
2
|
+
import { getConfig, getOnboardingConfig, getTiles } from "../../api/help-center";
|
|
3
|
+
import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
|
|
4
|
+
import { defaultHelpCenterConfig, } from "./defaultHelpCenterConfig";
|
|
5
|
+
import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
|
|
6
|
+
import { defaultOnboardingConfig, } from "../c3-onboarding-survey/defaultOnboardingConfig";
|
|
2
7
|
export var HelpCenterHintType;
|
|
3
8
|
(function (HelpCenterHintType) {
|
|
4
9
|
HelpCenterHintType["HelpCenter"] = "help-center";
|
|
@@ -13,6 +18,18 @@ export const C3HelpCenterContext = React.createContext({
|
|
|
13
18
|
setShowHintOnClose: () => undefined,
|
|
14
19
|
hintType: HelpCenterHintType.Onboarding,
|
|
15
20
|
setHintType: () => undefined,
|
|
21
|
+
helpCenterConfig: defaultHelpCenterConfig,
|
|
22
|
+
persona: undefined,
|
|
23
|
+
setPersona: () => undefined,
|
|
24
|
+
rawTabTiles: {},
|
|
25
|
+
isLoadingTiles: false,
|
|
26
|
+
updateFlags: () => undefined,
|
|
27
|
+
updateAutoStartSurvey: () => undefined,
|
|
28
|
+
showSurvey: false,
|
|
29
|
+
setShowSurvey: () => undefined,
|
|
30
|
+
onboadingConfig: defaultOnboardingConfig,
|
|
31
|
+
isLoadingOnboardingConfig: false,
|
|
32
|
+
getOnboadingSurveyConfig: () => undefined,
|
|
16
33
|
});
|
|
17
34
|
export const C3HelpCenterProvider = ({ children }) => {
|
|
18
35
|
const [isHelpCenterOpen, setIsHelpCenterOpen] = useState(false);
|
|
@@ -20,10 +37,97 @@ export const C3HelpCenterProvider = ({ children }) => {
|
|
|
20
37
|
const [showHint, setShowHint] = useState(false);
|
|
21
38
|
const [showHintOnClose, setShowHintOnClose] = useState(false);
|
|
22
39
|
const [hintType, setHintType] = useState(HelpCenterHintType.Onboarding);
|
|
23
|
-
const
|
|
40
|
+
const [helpCenterConfig, setHelpCenterConfig] = useState(defaultHelpCenterConfig);
|
|
41
|
+
const [showSurvey, setShowSurvey] = useState(false);
|
|
42
|
+
const [onboadingConfig, setOnboardConfig] = useState(defaultOnboardingConfig);
|
|
43
|
+
const [isLoadingOnboardingConfig, setIsLoadingOnboardingConfig] = useState(false);
|
|
44
|
+
const { activeOrg: organization, clusters } = useC3Profile();
|
|
45
|
+
const clusterIds = (clusters || []).map((cluster) => cluster.uuid);
|
|
46
|
+
const [rawTabTiles, setRawTabTiles] = useState({});
|
|
47
|
+
const [isLoadingTiles, setIsLoadingTiles] = useState(true);
|
|
48
|
+
const [persona, setPersona] = useState(undefined);
|
|
49
|
+
const tabCache = useRef(new Map());
|
|
50
|
+
const flags = useRef([]);
|
|
51
|
+
const updateFlags = (updatedFlags) => {
|
|
52
|
+
flags.current = updatedFlags;
|
|
53
|
+
};
|
|
54
|
+
const autoStartSurvey = useRef(false);
|
|
55
|
+
const updateAutoStartSurvey = (autoStart) => {
|
|
56
|
+
autoStartSurvey.current = autoStart;
|
|
57
|
+
};
|
|
58
|
+
const { userToken, activeOrganizationId, decodedAudience, decodedToken } = useC3UserConfiguration();
|
|
59
|
+
const getTileData = async (tabs) => {
|
|
60
|
+
if (!decodedAudience) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { persona: tokenPersona } = decodedToken ?? {};
|
|
64
|
+
const tiles = {};
|
|
65
|
+
setIsLoadingTiles(true);
|
|
66
|
+
for (const singleTab of tabs) {
|
|
67
|
+
if (userToken) {
|
|
68
|
+
if (tabCache.current.has(singleTab.id)) {
|
|
69
|
+
tiles[singleTab.id] = tabCache.current.get(singleTab.id);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const { result } = await getTiles({
|
|
73
|
+
tileConfig: singleTab.tiles,
|
|
74
|
+
cloudAudience: decodedAudience,
|
|
75
|
+
persona: tokenPersona ?? {},
|
|
76
|
+
clusterIds,
|
|
77
|
+
salesPlanType: organization?.salesPlan?.type ?? "",
|
|
78
|
+
flags: flags.current,
|
|
79
|
+
accessToken: userToken,
|
|
80
|
+
});
|
|
81
|
+
if (result) {
|
|
82
|
+
tiles[singleTab.id] = result;
|
|
83
|
+
tabCache.current.set(singleTab.id, result);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
setIsLoadingTiles(false);
|
|
88
|
+
setRawTabTiles(tiles);
|
|
89
|
+
};
|
|
90
|
+
const getOnboadingSurveyConfig = useCallback(async (decodedAudience) => {
|
|
91
|
+
setIsLoadingOnboardingConfig(true);
|
|
92
|
+
const { result: config } = await getOnboardingConfig({
|
|
93
|
+
audience: decodedAudience,
|
|
94
|
+
camundaAuth: { token: userToken },
|
|
95
|
+
orgId: activeOrganizationId,
|
|
96
|
+
});
|
|
97
|
+
if (config) {
|
|
98
|
+
setOnboardConfig(config);
|
|
99
|
+
}
|
|
100
|
+
setIsLoadingOnboardingConfig(false);
|
|
101
|
+
}, [activeOrganizationId, userToken]);
|
|
102
|
+
const openHelpCenter = async (showTabId) => {
|
|
24
103
|
if (!isHelpCenterOpen) {
|
|
25
104
|
setIsHelpCenterOpen(true);
|
|
26
105
|
setShowHint(false);
|
|
106
|
+
if (decodedAudience) {
|
|
107
|
+
const { persona: tokenPersona } = decodedToken ?? {};
|
|
108
|
+
if (showSurvey || autoStartSurvey.current || !tokenPersona?.wasShown) {
|
|
109
|
+
setIsLoadingTiles(false);
|
|
110
|
+
await getOnboadingSurveyConfig(decodedAudience);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const { result } = await getConfig(userToken, decodedAudience, activeOrganizationId);
|
|
114
|
+
const config = result || defaultHelpCenterConfig;
|
|
115
|
+
await getTileData(config?.tabs);
|
|
116
|
+
setHelpCenterConfig(config);
|
|
117
|
+
}
|
|
118
|
+
if (tokenPersona !== undefined) {
|
|
119
|
+
setPersona(tokenPersona);
|
|
120
|
+
if (tokenPersona.wasShown) {
|
|
121
|
+
setShowSurvey(false);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
setPersona({ wasShown: false });
|
|
126
|
+
}
|
|
127
|
+
if (autoStartSurvey.current && !tokenPersona?.wasShown) {
|
|
128
|
+
setIsHelpCenterOpen(true);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
27
131
|
}
|
|
28
132
|
if (showTabId)
|
|
29
133
|
setActiveTabId(showTabId);
|
|
@@ -47,6 +151,18 @@ export const C3HelpCenterProvider = ({ children }) => {
|
|
|
47
151
|
setShowHintOnClose,
|
|
48
152
|
hintType,
|
|
49
153
|
setHintType,
|
|
154
|
+
helpCenterConfig,
|
|
155
|
+
persona,
|
|
156
|
+
setPersona,
|
|
157
|
+
rawTabTiles,
|
|
158
|
+
isLoadingTiles,
|
|
159
|
+
updateFlags,
|
|
160
|
+
showSurvey,
|
|
161
|
+
setShowSurvey,
|
|
162
|
+
onboadingConfig,
|
|
163
|
+
isLoadingOnboardingConfig,
|
|
164
|
+
updateAutoStartSurvey,
|
|
165
|
+
getOnboadingSurveyConfig,
|
|
50
166
|
} }, children));
|
|
51
167
|
};
|
|
52
168
|
export const useC3HelpCenter = () => React.useContext(C3HelpCenterContext);
|
|
@@ -9,8 +9,6 @@ export interface C3HelpCenterProps {
|
|
|
9
9
|
activeTab?: string;
|
|
10
10
|
autoStartSurvey?: boolean;
|
|
11
11
|
onPersonaChange?: (persona: Persona) => void;
|
|
12
|
-
onRequestClose?: () => void;
|
|
13
|
-
onRequestOpen?: () => void;
|
|
14
12
|
mixpanelTrack?: (event: string, data: Dict | undefined) => void;
|
|
15
13
|
}
|
|
16
14
|
export declare const C3HelpCenter: FC<C3HelpCenterProps>;
|