@camunda/camunda-composite-components 0.20.3 → 0.20.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/camunda-composite-components",
3
- "version": "0.20.3",
3
+ "version": "0.20.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,7 +1,4 @@
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";
5
2
  export declare enum HelpCenterHintType {
6
3
  HelpCenter = "help-center",
7
4
  Onboarding = "onboarding"
@@ -16,20 +13,6 @@ export type C3HelpCenterContextValue = {
16
13
  setShowHintOnClose: (showHintOnClose: boolean) => void;
17
14
  hintType: HelpCenterHintType;
18
15
  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>;
33
16
  };
34
17
  export declare const C3HelpCenterContext: React.Context<C3HelpCenterContextValue>;
35
18
  export declare const C3HelpCenterProvider: FC<PropsWithChildren>;
@@ -1,10 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React, { useCallback, useEffect, useRef, useState, } from "react";
3
- import { getConfig, getOnboardingConfig, getTiles } from "../../api/help-center";
4
- import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
5
- import { defaultHelpCenterConfig, } from "./defaultHelpCenterConfig";
6
- import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
7
- import { defaultOnboardingConfig, } from "../c3-onboarding-survey/defaultOnboardingConfig";
2
+ import React, { useEffect, useState } from "react";
8
3
  export var HelpCenterHintType;
9
4
  (function (HelpCenterHintType) {
10
5
  HelpCenterHintType["HelpCenter"] = "help-center";
@@ -19,18 +14,6 @@ export const C3HelpCenterContext = React.createContext({
19
14
  setShowHintOnClose: () => undefined,
20
15
  hintType: HelpCenterHintType.Onboarding,
21
16
  setHintType: () => undefined,
22
- helpCenterConfig: defaultHelpCenterConfig,
23
- persona: undefined,
24
- setPersona: () => undefined,
25
- rawTabTiles: {},
26
- isLoadingTiles: false,
27
- updateFlags: () => undefined,
28
- updateAutoStartSurvey: () => undefined,
29
- showSurvey: false,
30
- setShowSurvey: () => undefined,
31
- onboadingConfig: defaultOnboardingConfig,
32
- isLoadingOnboardingConfig: false,
33
- getOnboadingSurveyConfig: () => undefined,
34
17
  });
35
18
  export const C3HelpCenterProvider = ({ children }) => {
36
19
  const [isHelpCenterOpen, setIsHelpCenterOpen] = useState(false);
@@ -38,97 +21,10 @@ export const C3HelpCenterProvider = ({ children }) => {
38
21
  const [showHint, setShowHint] = useState(false);
39
22
  const [showHintOnClose, setShowHintOnClose] = useState(false);
40
23
  const [hintType, setHintType] = useState(HelpCenterHintType.Onboarding);
41
- const [helpCenterConfig, setHelpCenterConfig] = useState(defaultHelpCenterConfig);
42
- const [showSurvey, setShowSurvey] = useState(false);
43
- const [onboadingConfig, setOnboardConfig] = useState(defaultOnboardingConfig);
44
- const [isLoadingOnboardingConfig, setIsLoadingOnboardingConfig] = useState(false);
45
- const { activeOrg: organization, clusters } = useC3Profile();
46
- const clusterIds = (clusters || []).map((cluster) => cluster.uuid);
47
- const [rawTabTiles, setRawTabTiles] = useState({});
48
- const [isLoadingTiles, setIsLoadingTiles] = useState(true);
49
- const [persona, setPersona] = useState(undefined);
50
- const tabCache = useRef(new Map());
51
- const flags = useRef([]);
52
- const updateFlags = (updatedFlags) => {
53
- flags.current = updatedFlags;
54
- };
55
- const autoStartSurvey = useRef(false);
56
- const updateAutoStartSurvey = (autoStart) => {
57
- autoStartSurvey.current = autoStart;
58
- };
59
- const { userToken, activeOrganizationId, decodedAudience, decodedToken } = useC3UserConfiguration();
60
- const getTileData = async (tabs) => {
61
- if (!decodedAudience) {
62
- return;
63
- }
64
- const { persona: tokenPersona } = decodedToken ?? {};
65
- const tiles = {};
66
- setIsLoadingTiles(true);
67
- for (const singleTab of tabs) {
68
- if (userToken) {
69
- if (tabCache.current.has(singleTab.id)) {
70
- tiles[singleTab.id] = tabCache.current.get(singleTab.id);
71
- continue;
72
- }
73
- const { result } = await getTiles({
74
- tileConfig: singleTab.tiles,
75
- cloudAudience: decodedAudience,
76
- persona: tokenPersona ?? {},
77
- clusterIds,
78
- salesPlanType: organization?.salesPlan?.type ?? "",
79
- flags: flags.current,
80
- accessToken: userToken,
81
- });
82
- if (result) {
83
- tiles[singleTab.id] = result;
84
- tabCache.current.set(singleTab.id, result);
85
- }
86
- }
87
- }
88
- setIsLoadingTiles(false);
89
- setRawTabTiles(tiles);
90
- };
91
- const getOnboadingSurveyConfig = useCallback(async (decodedAudience) => {
92
- setIsLoadingOnboardingConfig(true);
93
- const { result: config } = await getOnboardingConfig({
94
- audience: decodedAudience,
95
- camundaAuth: { token: userToken },
96
- orgId: activeOrganizationId,
97
- });
98
- if (config) {
99
- setOnboardConfig(config);
100
- }
101
- setIsLoadingOnboardingConfig(false);
102
- }, [activeOrganizationId, userToken]);
103
- const openHelpCenter = async (showTabId) => {
24
+ const openHelpCenter = (showTabId) => {
104
25
  if (!isHelpCenterOpen) {
105
26
  setIsHelpCenterOpen(true);
106
27
  setShowHint(false);
107
- if (decodedAudience) {
108
- const { persona: tokenPersona } = decodedToken ?? {};
109
- if (showSurvey || autoStartSurvey.current || !tokenPersona?.wasShown) {
110
- setIsLoadingTiles(false);
111
- await getOnboadingSurveyConfig(decodedAudience);
112
- }
113
- else {
114
- const { result } = await getConfig(userToken, decodedAudience, activeOrganizationId);
115
- const config = result || defaultHelpCenterConfig;
116
- await getTileData(config?.tabs);
117
- setHelpCenterConfig(config);
118
- }
119
- if (tokenPersona !== undefined) {
120
- setPersona(tokenPersona);
121
- if (tokenPersona.wasShown) {
122
- setShowSurvey(false);
123
- }
124
- }
125
- else {
126
- setPersona({ wasShown: false });
127
- }
128
- if (autoStartSurvey.current && !tokenPersona?.wasShown) {
129
- setIsHelpCenterOpen(true);
130
- }
131
- }
132
28
  }
133
29
  if (showTabId)
134
30
  setActiveTabId(showTabId);
@@ -152,18 +48,6 @@ export const C3HelpCenterProvider = ({ children }) => {
152
48
  setShowHintOnClose,
153
49
  hintType,
154
50
  setHintType,
155
- helpCenterConfig,
156
- persona,
157
- setPersona,
158
- rawTabTiles,
159
- isLoadingTiles,
160
- updateFlags,
161
- showSurvey,
162
- setShowSurvey,
163
- onboadingConfig,
164
- isLoadingOnboardingConfig,
165
- updateAutoStartSurvey,
166
- getOnboadingSurveyConfig,
167
51
  }, children: children }));
168
52
  };
169
53
  export const useC3HelpCenter = () => React.useContext(C3HelpCenterContext);
@@ -9,6 +9,8 @@ export interface C3HelpCenterProps {
9
9
  activeTab?: string;
10
10
  autoStartSurvey?: boolean;
11
11
  onPersonaChange?: (persona: Persona) => void;
12
+ onRequestClose?: () => void;
13
+ onRequestOpen?: () => void;
12
14
  mixpanelTrack?: (event: string, data: Dict | undefined) => void;
13
15
  }
14
16
  export declare const C3HelpCenter: FC<C3HelpCenterProps>;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ActionableNotification, ComposedModal, Layer, ModalBody, ModalHeader, } from "@carbon/react";
3
- import React, { useCallback, useEffect, useRef, useState } from "react";
3
+ import React, { useEffect, useRef, useState } from "react";
4
4
  import { HelpCenter } from "./help-center";
5
+ import { defaultHelpCenterConfig } from "./defaultHelpCenterConfig";
5
6
  import { C3OnboardingSurvey } from "../c3-onboarding-survey/c3-onboarding-survey";
6
- import { updatePersona } from "../../api/help-center";
7
+ import { getConfig, updatePersona } from "../../api/help-center";
7
8
  import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
8
9
  import { defaultTheme, useC3Profile, } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
9
10
  import { resolveTheme, } from "../c3-user-configuration/c3-profile-provider/carbon-theme-provider";
@@ -15,26 +16,29 @@ const StyledComposedModal = styled(ComposedModal) `
15
16
  mask-image: none;
16
17
  }
17
18
  `;
18
- export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: customMixpanelTrack, theme, onPersonaChange, activeTab, }) => {
19
- const { isHelpCenterOpen: isOpen, setIsHelpCenterOpen, setShowHintOnClose, helpCenterConfig, persona, setPersona, showSurvey, setShowSurvey, updateAutoStartSurvey, getOnboadingSurveyConfig, } = useC3HelpCenter();
19
+ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, onRequestClose, mixpanelTrack: customMixpanelTrack, onRequestOpen, theme, onPersonaChange, activeTab, }) => {
20
+ const { isHelpCenterOpen: isOpen, setIsHelpCenterOpen, setShowHintOnClose, } = useC3HelpCenter();
20
21
  const { userToken, decodedToken, activeOrganizationId, handleTheme, decodedAudience, analyticsTrack, currentApp, } = useC3UserConfiguration();
21
- const { theme: themeConfig, isEnabled } = useC3Profile();
22
+ const { theme: themeConfig, isEnabled, reloadClusters } = useC3Profile();
22
23
  const themeHandlingEnabled = isEnabled && !!handleTheme && !!themeConfig;
23
24
  const themeRef = useRef();
24
25
  const [resolvedTheme, setResolvedTheme] = useState(defaultTheme);
25
- const userId = decodedToken?.userId ?? "";
26
- const email = decodedToken?.meta?.email ?? "";
26
+ const [persona, setPersona] = useState(undefined);
27
+ const [userId, setUserId] = useState("");
28
+ const [helpCenterConfig, setHelpCenterConfig] = useState(defaultHelpCenterConfig);
29
+ const [email, setEmail] = useState("");
30
+ const [showSurvey, setShowSurvey] = useState(autoStartSurvey);
27
31
  if (!origin && !currentApp)
28
32
  console.warn("No app provided to the help center. Please provide the `currentApp` prop to the `C3UserConfigurationProvider`.");
29
33
  const hostApp = origin || currentApp === "modeler" ? "webmodeler" : currentApp || "console";
30
- const mixpanelTrack = useCallback((event, data) => {
34
+ const mixpanelTrack = (event, data) => {
31
35
  if (customMixpanelTrack) {
32
36
  customMixpanelTrack(event, data);
33
37
  }
34
38
  else if (analyticsTrack) {
35
39
  analyticsTrack(event, data);
36
40
  }
37
- }, []);
41
+ };
38
42
  useEffect(() => {
39
43
  const updateResolvedTheme = ({ matches }) => {
40
44
  if (themeRef.current === "system") {
@@ -54,13 +58,56 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: cu
54
58
  const newTheme = themeHandlingEnabled ? themeConfig : theme;
55
59
  themeRef.current = newTheme;
56
60
  setResolvedTheme(resolveTheme(newTheme || "light"));
57
- }, [theme, themeConfig, isOpen, themeHandlingEnabled]);
58
- useEffect(() => {
59
- if (autoStartSurvey) {
60
- setShowSurvey(autoStartSurvey);
61
+ }, [theme, themeConfig, isOpen]);
62
+ const fetchConfig = async () => {
63
+ if (!userToken || !decodedAudience)
64
+ return;
65
+ const { result: config } = await getConfig(userToken, decodedAudience, activeOrganizationId);
66
+ setHelpCenterConfig(config || defaultHelpCenterConfig);
67
+ };
68
+ const isFirstLoad = useRef(true);
69
+ const fetchData = async () => {
70
+ if (!userToken || !decodedToken || !decodedAudience)
71
+ return;
72
+ const { userId, meta, persona: tokenPersona } = decodedToken;
73
+ if (tokenPersona !== undefined) {
74
+ setPersona(tokenPersona);
75
+ if (tokenPersona.wasShown) {
76
+ setShowSurvey(false);
77
+ }
78
+ }
79
+ else {
80
+ setPersona({ wasShown: false });
61
81
  }
62
- }, [autoStartSurvey, setShowSurvey]);
63
- updateAutoStartSurvey(autoStartSurvey ?? false);
82
+ if (meta)
83
+ setEmail(meta.email);
84
+ if (userId)
85
+ setUserId(userId);
86
+ if (autoStartSurvey && !tokenPersona?.wasShown) {
87
+ setIsHelpCenterOpen(true);
88
+ onRequestOpen?.();
89
+ }
90
+ await fetchConfig();
91
+ isFirstLoad.current = false;
92
+ };
93
+ React.useEffect(() => {
94
+ fetchData();
95
+ }, [JSON.stringify(decodedToken), decodedAudience]);
96
+ useEffect(() => {
97
+ if (isFirstLoad.current ||
98
+ !userToken ||
99
+ !decodedAudience ||
100
+ !persona?.complete)
101
+ return;
102
+ fetchConfig();
103
+ reloadClusters();
104
+ }, [persona?.complete]);
105
+ useEffect(() => {
106
+ if (isFirstLoad.current || !activeOrganizationId)
107
+ return;
108
+ fetchConfig();
109
+ reloadClusters();
110
+ }, [activeOrganizationId]);
64
111
  React.useEffect(() => {
65
112
  const tabs = helpCenterConfig.tabs;
66
113
  const firstTab = tabs[0]?.id;
@@ -83,21 +130,7 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: cu
83
130
  from: origin,
84
131
  });
85
132
  }
86
- }, [
87
- activeOrganizationId,
88
- activeTab,
89
- autoStartSurvey,
90
- decodedAudience,
91
- helpCenterConfig.tabs,
92
- isOpen,
93
- mixpanelTrack,
94
- origin,
95
- persona,
96
- setPersona,
97
- setShowHintOnClose,
98
- userId,
99
- userToken,
100
- ]);
133
+ }, [isOpen]);
101
134
  const onRequestRetakeSurvey = () => {
102
135
  if (!userToken || !activeOrganizationId || !decodedAudience)
103
136
  return;
@@ -116,10 +149,9 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: cu
116
149
  onPersonaChange?.(newPersona);
117
150
  setShowSurvey(true);
118
151
  };
119
- const onRequestResumeSurvey = async () => {
152
+ const onRequestResumeSurvey = () => {
120
153
  if (!userToken || !activeOrganizationId || !decodedAudience)
121
154
  return;
122
- await getOnboadingSurveyConfig(decodedAudience);
123
155
  const newPersona = { ...persona, ...{ complete: false, wasShown: true } };
124
156
  setPersona(newPersona);
125
157
  updatePersona({
@@ -165,6 +197,9 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: cu
165
197
  userId,
166
198
  });
167
199
  }
200
+ onRequestClose?.();
201
+ fetchConfig();
202
+ reloadClusters();
168
203
  // wait for modal transition
169
204
  setTimeout(() => {
170
205
  setShowSurvey(false);
@@ -172,5 +207,5 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, mixpanelTrack: cu
172
207
  };
173
208
  return (_jsx(Layer, { children: _jsx(StyledComposedModal, { open: isOpen, size: "lg", onClose: closeFn, className: "help-center", "aria-label": "HelpCenter", style: showSurvey || !persona?.wasShown
174
209
  ? { backgroundColor: "rgba(22,22,22, 0.8)" }
175
- : {}, children: _jsx(ErrorBoundary, { fallbackRender: () => (_jsxs(_Fragment, { children: [_jsx(ModalHeader, { title: "Help Center", closeModal: closeFn }), _jsx(ModalBody, { children: _jsx(ActionableNotification, { inline: true, hideCloseButton: true, lowContrast: true, kind: "error", title: "Something went wrong.", subtitle: "Try reloading the page.", actionButtonLabel: "Reload", onActionButtonClick: () => window.location.reload() }) })] })), children: showSurvey || (persona && !persona?.wasShown) ? (_jsx(C3OnboardingSurvey, { personaCallback: personaCallback, persona: persona, mixpanelTrack: mixpanelTrack, onRequestClose: closeFn, onRequestSkip: onRequestSkipSurvey, theme: resolvedTheme, origin: hostApp, modal: true })) : (_jsx(HelpCenter, { configuration: helpCenterConfig, persona: persona ?? {}, audience: decodedAudience || "", flags: flags, onRequestResumeSurvey: onRequestResumeSurvey, onRequestRetakeSurvey: onRequestRetakeSurvey, onRequestClose: closeFn, mixpanelTrack: mixpanelTrack, email: email, theme: resolvedTheme, origin: hostApp, initialTab: activeTab })) }) }) }));
210
+ : {}, children: _jsx(ErrorBoundary, { fallbackRender: () => (_jsxs(_Fragment, { children: [_jsx(ModalHeader, { title: "Help Center", closeModal: closeFn }), _jsx(ModalBody, { children: _jsx(ActionableNotification, { inline: true, hideCloseButton: true, lowContrast: true, kind: "error", title: "Something went wrong.", subtitle: "Try reloading the page.", actionButtonLabel: "Reload", onActionButtonClick: () => window.location.reload() }) })] })), children: showSurvey || !persona?.wasShown ? (_jsx(C3OnboardingSurvey, { personaCallback: personaCallback, persona: persona, mixpanelTrack: mixpanelTrack, onRequestClose: closeFn, onRequestSkip: onRequestSkipSurvey, theme: resolvedTheme, origin: hostApp, modal: true })) : (_jsx(HelpCenter, { configuration: helpCenterConfig, persona: persona, audience: decodedAudience || "", flags: flags, onRequestResumeSurvey: onRequestResumeSurvey, onRequestRetakeSurvey: onRequestRetakeSurvey, onRequestClose: closeFn, mixpanelTrack: mixpanelTrack, email: email, theme: resolvedTheme, origin: hostApp, initialTab: activeTab })) }) }) }));
176
211
  };
@@ -1,5 +1,5 @@
1
1
  import { Dict } from "mixpanel-browser";
2
- import type { FC } from "react";
2
+ import { FC } from "react";
3
3
  import { Persona } from "./c3-help-center.types";
4
4
  import { HelpCenterConfig } from "./defaultHelpCenterConfig";
5
5
  export declare const HelpCenter: FC<{
@@ -1,16 +1,16 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, ModalFooter, SideNav, SideNavItems, SideNavMenuItem, Stack, } from "@carbon/react";
3
3
  import { Undo } from "@carbon/react/icons";
4
- import { useEffect, useState } from "react";
4
+ import React, { useEffect, useState } from "react";
5
5
  import { Feedback } from "./tabs/feedback";
6
6
  import { TabContent } from "./tabs/tabContent";
7
+ import { getTiles } from "../../api/help-center";
7
8
  import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
8
9
  import { useC3HelpCenter } from "./c3-help-center-provider";
9
10
  import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
10
11
  import { TabContentSkeleton } from "./tabs/tabContentSkeleton";
11
12
  import { StyledModalBody, StyledModalHeader } from "./styles";
12
13
  import styled from "styled-components";
13
- import { C3Tabs } from "../c3-page/c3-tabs/c3-tabs";
14
14
  const StyledModalFooter = styled(ModalFooter) `
15
15
  height: 62px;
16
16
  padding-right: 16px;
@@ -21,33 +21,53 @@ const StyledModalFooter = styled(ModalFooter) `
21
21
  border-color: ${({ $hcTheme }) => $hcTheme === "light" ? "#E0E0E0" : "#727272"};
22
22
  background-color: ${({ $hcTheme }) => $hcTheme === "light" ? "#FFFFFF" : "#161616"};
23
23
  `;
24
- const SideNavWrapper = styled.div `
25
- @media (max-width: 768px) {
26
- display: none;
27
- }
28
- `;
29
- const SideNavMobileWrapper = styled.div `
30
- display: none;
31
- @media (max-width: 768px) {
32
- display: block;
33
- }
34
- `;
35
- const StyledHeading = styled.h4 `
36
- margin-left: 16rem;
37
- @media (max-width: 768px) {
38
- margin-left: 0rem;
39
- }
40
- `;
41
24
  export const HelpCenter = ({ configuration, persona, email, audience, flags = [], onRequestResumeSurvey, onRequestRetakeSurvey, onRequestClose, mixpanelTrack, theme, origin, initialTab, }) => {
42
25
  const { tabs } = configuration;
43
26
  const firstTab = tabs[0].id;
44
- const { activeOrganizationId, domain } = useC3UserConfiguration();
27
+ const { userToken: token, activeOrganizationId, domain, } = useC3UserConfiguration();
45
28
  const { activeOrg: organization, clusters } = useC3Profile();
46
29
  const clusterIds = (clusters || []).map((cluster) => cluster.uuid);
47
- const { showTabId, rawTabTiles, isLoadingTiles, updateFlags } = useC3HelpCenter();
30
+ const { showTabId } = useC3HelpCenter();
48
31
  const [activeTab, setActiveTab] = useState(firstTab);
49
- updateFlags(flags);
50
- const getTabTiles = () => {
32
+ const [rawTabTiles, setRawTabTiles] = useState({});
33
+ const [tabTiles, setTabTiles] = useState({});
34
+ const [isLoadingTiles, setIsLoadingTiles] = useState(false);
35
+ let header = "";
36
+ let content = _jsx(_Fragment, {});
37
+ React.useEffect(() => {
38
+ ;
39
+ (async () => {
40
+ const tiles = {};
41
+ setIsLoadingTiles(true);
42
+ for (const singleTab of tabs) {
43
+ if (token) {
44
+ const { result } = await getTiles({
45
+ tileConfig: singleTab.tiles,
46
+ cloudAudience: audience,
47
+ persona,
48
+ clusterIds,
49
+ salesPlanType: organization?.salesPlan?.type ?? "",
50
+ flags,
51
+ accessToken: token,
52
+ });
53
+ if (result)
54
+ tiles[singleTab.id] = result;
55
+ }
56
+ }
57
+ setIsLoadingTiles(false);
58
+ setRawTabTiles(tiles);
59
+ })();
60
+ }, [
61
+ token,
62
+ JSON.stringify(persona),
63
+ audience,
64
+ JSON.stringify(organization),
65
+ JSON.stringify(clusters),
66
+ JSON.stringify(tabs),
67
+ ]);
68
+ useEffect(() => {
69
+ if (!tabs || !rawTabTiles)
70
+ return;
51
71
  const tiles = {};
52
72
  for (const tab of tabs) {
53
73
  if (rawTabTiles[tab.id])
@@ -61,11 +81,8 @@ export const HelpCenter = ({ configuration, persona, email, audience, flags = []
61
81
  return card;
62
82
  }) || [];
63
83
  }
64
- return tiles;
65
- };
66
- const tabTiles = getTabTiles();
67
- let header = "";
68
- let content = _jsx(_Fragment, {});
84
+ setTabTiles(tiles);
85
+ }, [JSON.stringify(rawTabTiles), email, domain]);
69
86
  useEffect(() => {
70
87
  setActiveTab(initialTab ?? firstTab);
71
88
  }, [initialTab]);
@@ -126,53 +143,38 @@ export const HelpCenter = ({ configuration, persona, email, audience, flags = []
126
143
  return (_jsxs(_Fragment, { children: [_jsx(StyledModalHeader, { title: "", label: "", closeModal: onRequestClose, style: {
127
144
  backgroundColor: theme === "light" ? "#FFFFFF" : "#161616",
128
145
  marginBottom: "0",
129
- }, children: _jsx(StyledHeading, { children: header }) }), _jsx(StyledModalBody, { style: {
146
+ }, children: _jsx("h4", { style: { marginLeft: "16rem" }, children: header }) }), _jsx(StyledModalBody, { style: {
130
147
  backgroundColor: theme === "light" ? "#FFFFFF" : "#161616",
131
148
  marginBottom: 0,
132
149
  }, children: _jsxs("div", { style: {
133
150
  height: persona.complete && activeTab === "recommendations"
134
151
  ? "634px"
135
152
  : "696px",
136
- }, children: [_jsx(SideNavMobileWrapper, { children: _jsx(C3Tabs, { tabs: tabBar.map((link) => {
137
- return {
138
- id: link.id,
139
- label: link.text,
140
- content: null,
141
- };
142
- }), desiredTabId: activeTab, onTabChange: (tabId) => {
143
- const link = tabBar.find((item) => item.id === tabId);
144
- if (link) {
145
- setActiveTab(link.name);
146
- mixpanelTrack?.("helpcenter:open", {
147
- to: link.id,
148
- from: origin,
149
- });
150
- }
151
- } }) }), _jsx(SideNavWrapper, { children: _jsx(SideNav, { isFixedNav: true, expanded: true, isChildOfHeader: false, "aria-label": "Side nav", children: _jsxs(SideNavItems, { children: [_jsx(SideNavMenuItem, { children: _jsx("h5", { children: "Help Center" }) }), _jsx("li", { style: { marginTop: "4px" }, children: _jsx(Stack, { children: _jsx("ul", { children: tabBar.map(({ name, id, text }) => {
152
- const active = activeTab === name;
153
- let tabBackgroundColor = theme === "light" ? "#F4F4F4" : "#161616";
154
- let tabButtonColor = theme === "light" ? "#525252" : "#f4f4f4";
155
- if (active) {
156
- tabBackgroundColor =
157
- theme === "light" ? "#E5E5E5" : "#8D8D8D3D";
158
- tabButtonColor =
159
- theme === "light" ? "#161616" : "#f4f4f4";
160
- }
161
- return (_jsx("li", { children: _jsx(Button, { className: active ? "active" : "", kind: "secondary", onClick: () => {
162
- setActiveTab(name);
163
- mixpanelTrack?.("helpcenter:open", {
164
- to: id,
165
- from: origin,
166
- });
167
- }, style: {
168
- width: "100%",
169
- backgroundColor: tabBackgroundColor,
170
- color: tabButtonColor,
171
- }, "aria-label": text, children: text }) }, name));
172
- }) }) }) }), _jsx("li", { style: { position: "absolute", bottom: "20px" }, children: _jsx("ul", { children: configuration.links?.map((link) => (_jsx(SideNavMenuItem, { href: link.link,
173
- // eslint-disable-next-line
174
- // @ts-ignore
175
- target: "_blank", children: _jsx("span", { className: "cds--link", children: link.label }) }, link.label.split(" ").join("-").toLowerCase()))) }) })] }) }) }), content, _jsx("div", { style: { display: activeTab === "feedback" ? "block" : "none" }, children: _jsx(Feedback, { audience: audience, theme: theme, mixpanelTrack: mixpanelTrack, setHeader: (head) => {
153
+ }, children: [_jsx(SideNav, { isFixedNav: true, expanded: true, isChildOfHeader: false, "aria-label": "Side nav", children: _jsxs(SideNavItems, { children: [_jsx(SideNavMenuItem, { children: _jsx("h5", { children: "Help Center" }) }), _jsx("li", { style: { marginTop: "4px" }, children: _jsx(Stack, { children: _jsx("ul", { children: tabBar.map(({ name, id, text }) => {
154
+ const active = activeTab === name;
155
+ let tabBackgroundColor = theme === "light" ? "#F4F4F4" : "#161616";
156
+ let tabButtonColor = theme === "light" ? "#525252" : "#f4f4f4";
157
+ if (active) {
158
+ tabBackgroundColor =
159
+ theme === "light" ? "#E5E5E5" : "#8D8D8D3D";
160
+ tabButtonColor =
161
+ theme === "light" ? "#161616" : "#f4f4f4";
162
+ }
163
+ return (_jsx("li", { children: _jsx(Button, { className: active ? "active" : "", kind: "secondary", onClick: () => {
164
+ setActiveTab(name);
165
+ mixpanelTrack?.("helpcenter:open", {
166
+ to: id,
167
+ from: origin,
168
+ });
169
+ }, style: {
170
+ width: "100%",
171
+ backgroundColor: tabBackgroundColor,
172
+ color: tabButtonColor,
173
+ }, "aria-label": text, children: text }) }, name));
174
+ }) }) }) }), _jsx("li", { style: { position: "absolute", bottom: "20px" }, children: _jsx("ul", { children: configuration.links?.map((link) => (_jsx(SideNavMenuItem, { href: link.link,
175
+ // eslint-disable-next-line
176
+ // @ts-ignore
177
+ target: "_blank", children: _jsx("span", { className: "cds--link", children: link.label }) }, link.label.split(" ").join("-").toLowerCase()))) }) })] }) }), content, _jsx("div", { style: { display: activeTab === "feedback" ? "block" : "none" }, children: _jsx(Feedback, { audience: audience, theme: theme, mixpanelTrack: mixpanelTrack, setHeader: (head) => {
176
178
  header = head;
177
179
  }, salesPlanType: organization?.salesPlan?.type ?? "" }) })] }) }), persona.complete && activeTab === "recommendations" && (_jsx(StyledModalFooter, { "$hcTheme": theme, children: _jsx("div", { children: _jsx(Button, { kind: "tertiary", renderIcon: Undo, onClick: onRequestRetakeSurvey, size: "sm", style: {
178
180
  maxWidth: "200px",
@@ -1,15 +1,43 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from "react";
2
+ import React, { useState } from "react";
3
3
  import { OnboardingSurvey } from "./onboardingSurvey";
4
- import { submitSurvey, updatePersona } from "../../api/help-center";
4
+ import { defaultOnboardingConfig } from "./defaultOnboardingConfig";
5
+ import { getOnboardingConfig, submitSurvey, updatePersona, } from "../../api/help-center";
5
6
  import { useC3UserConfiguration, } from "../c3-user-configuration/c3-user-configuration-provider";
6
- import { useC3HelpCenter } from "../c3-help-center/c3-help-center-provider";
7
7
  export const C3OnboardingSurvey = (props) => {
8
8
  const { userToken, decodedToken, activeOrganizationId, decodedAudience } = useC3UserConfiguration();
9
- const { persona, setPersona, onboadingConfig, isLoadingOnboardingConfig } = useC3HelpCenter();
10
- const userId = decodedToken?.userId ?? "";
11
- const email = decodedToken?.meta?.email ?? "";
12
- const givenName = decodedToken?.meta?.given_name ?? "";
9
+ const [persona, setPersona] = useState(props.persona);
10
+ const [userId, setUserId] = useState("");
11
+ const [onboardConfig, setOnboardConfig] = useState(defaultOnboardingConfig);
12
+ const [isLoadingConfig, setIsLoadingConfig] = useState(false);
13
+ const [givenName, setGivenName] = useState("");
14
+ const [email, setEmail] = useState("");
15
+ React.useEffect(() => {
16
+ if (!decodedToken || !decodedAudience)
17
+ return;
18
+ (async () => {
19
+ const { userId, meta, persona } = decodedToken;
20
+ if (props.persona === undefined && persona) {
21
+ setPersona(persona);
22
+ }
23
+ if (meta) {
24
+ setGivenName(meta.given_name);
25
+ setEmail(meta.email);
26
+ }
27
+ if (userId)
28
+ setUserId(userId);
29
+ setOnboardConfig(defaultOnboardingConfig);
30
+ setIsLoadingConfig(true);
31
+ const { result: config } = await getOnboardingConfig({
32
+ audience: decodedAudience,
33
+ camundaAuth: { token: userToken },
34
+ orgId: activeOrganizationId,
35
+ });
36
+ if (config)
37
+ setOnboardConfig(config);
38
+ setIsLoadingConfig(false);
39
+ })();
40
+ }, [JSON.stringify(decodedToken), decodedAudience]);
13
41
  React.useEffect(() => {
14
42
  setPersona(props.persona);
15
43
  }, [props.persona]);
@@ -57,5 +85,5 @@ export const C3OnboardingSurvey = (props) => {
57
85
  setPersona(newPersona);
58
86
  props.personaCallback(newPersona);
59
87
  };
60
- return (_jsx(OnboardingSurvey, { appTheme: props.theme, userFirstName: givenName, persona: persona, syncPersona: syncPersona, setPersona: setPersona, mixpanelTrack: props.mixpanelTrack, onRequestClose: closeFn, onboardingConfiguration: onboadingConfig, isLoadingConfig: isLoadingOnboardingConfig, modal: props.modal, origin: props.origin }));
88
+ return (_jsx(OnboardingSurvey, { appTheme: props.theme, userFirstName: givenName, persona: persona, syncPersona: syncPersona, setPersona: setPersona, mixpanelTrack: props.mixpanelTrack, onRequestClose: closeFn, onboardingConfiguration: onboardConfig, isLoadingConfig: isLoadingConfig, modal: props.modal, origin: props.origin }));
61
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/camunda-composite-components",
3
- "version": "0.20.3",
3
+ "version": "0.20.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"