@camunda/camunda-composite-components 0.2.4-rc.0 → 0.2.4-rc.2
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/components/c3-cluster-tag/c3-cluster-tag.js +4 -7
- package/lib/esm/components/c3-cluster-tag/c3-cluster-tag.types.d.ts +1 -3
- package/lib/esm/components/c3-help-center/c3-help-center.js +4 -5
- package/lib/esm/components/c3-navigation/c3-navigation.js +9 -5
- package/lib/esm/components/c3-onboarding-survey/c3-onboarding-survey.js +1 -3
- package/lib/esm/components/c3-user-configuration/authToken.d.ts +7 -6
- package/lib/esm/components/c3-user-configuration/c3-profile-provider/c3-profile-provider.js +1 -3
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.d.ts +6 -2
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.js +12 -3
- package/package.json +1 -1
|
@@ -3,16 +3,13 @@ import { Tag } from "@carbon/react";
|
|
|
3
3
|
import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
|
|
4
4
|
export const C3ClusterTag = (props) => {
|
|
5
5
|
const { clusters } = useC3Profile();
|
|
6
|
-
return "stage" in props ? (React.createElement(Tag, {
|
|
6
|
+
return "stage" in props ? (React.createElement(Tag, { type: getColorForStage(props.stage) }, props.stage)) : "clusterUuid" in props ? (generateFromInput(props.clusterUuid, clusters)) : (React.createElement(React.Fragment, null));
|
|
7
7
|
};
|
|
8
|
-
function generateFromInput(clusterUuid, allClusters
|
|
8
|
+
function generateFromInput(clusterUuid, allClusters) {
|
|
9
9
|
const foundCluster = allClusters?.find((cluster) => cluster.uuid === clusterUuid);
|
|
10
|
-
if (foundCluster &&
|
|
11
|
-
foundCluster.labels &&
|
|
12
|
-
foundCluster.labels.camunda &&
|
|
13
|
-
foundCluster.labels.camunda.length > 0) {
|
|
10
|
+
if (foundCluster?.labels?.camunda && foundCluster.labels.camunda.length > 0) {
|
|
14
11
|
const label = foundCluster.labels.camunda[0];
|
|
15
|
-
return getColorForStage(label) ? (React.createElement(Tag, {
|
|
12
|
+
return getColorForStage(label) ? (React.createElement(Tag, { type: getColorForStage(label) }, label)) : (React.createElement(React.Fragment, null));
|
|
16
13
|
}
|
|
17
14
|
return React.createElement(React.Fragment, null);
|
|
18
15
|
}
|
|
@@ -7,9 +7,7 @@ export declare const StageClusterLabels: {
|
|
|
7
7
|
export type CamundaClusterStage = keyof typeof StageClusterLabels;
|
|
8
8
|
export type CamundaClusterStageLabel = (typeof StageClusterLabels)[CamundaClusterStage];
|
|
9
9
|
export type C3ClusterTagProps = {
|
|
10
|
-
style?: any;
|
|
11
|
-
} & ({
|
|
12
10
|
clusterUuid: string;
|
|
13
11
|
} | {
|
|
14
12
|
stage: CamundaClusterStage;
|
|
15
|
-
}
|
|
13
|
+
};
|
|
@@ -4,12 +4,11 @@ import { HelpCenter } from "./help-center";
|
|
|
4
4
|
import { defaultHelpCenterConfig } from "./defaultHelpCenterConfig";
|
|
5
5
|
import { C3OnboardingSurvey } from "../c3-onboarding-survey/c3-onboarding-survey";
|
|
6
6
|
import { getClusters, getConfig, getOrg, updatePersona, } from "../../api/help-center";
|
|
7
|
-
import { decodeJWT } from "../c3-user-configuration/authToken";
|
|
8
7
|
import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
|
|
9
8
|
import { defaultTheme, useC3Profile, } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
|
|
10
9
|
import { resolveTheme, } from "../c3-user-configuration/c3-profile-provider/carbon-theme-provider";
|
|
11
10
|
export const C3HelpCenter = ({ autoStartSurvey, origin, flags, isOpen, onRequestClose, mixpanelTrack, onRequestOpen, theme, onPersonaChange, activeTab, }) => {
|
|
12
|
-
const { userToken, activeOrganizationId, handleTheme } = useC3UserConfiguration() || {};
|
|
11
|
+
const { userToken, decodedToken, activeOrganizationId, handleTheme } = useC3UserConfiguration() || {};
|
|
13
12
|
const { theme: themeConfig, isEnabled } = useC3Profile();
|
|
14
13
|
const themeHandlingEnabled = isEnabled && !!handleTheme && !!themeConfig;
|
|
15
14
|
const themeRef = useRef();
|
|
@@ -45,7 +44,6 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, isOpen, onRequest
|
|
|
45
44
|
setResolvedTheme(resolveTheme(newTheme || "light"));
|
|
46
45
|
}, [theme, themeConfig, isOpen]);
|
|
47
46
|
const fetchData = async () => {
|
|
48
|
-
const decodedToken = decodeJWT(userToken);
|
|
49
47
|
if (!decodedToken)
|
|
50
48
|
return;
|
|
51
49
|
const { userId, meta, audience, persona } = decodedToken;
|
|
@@ -78,13 +76,14 @@ export const C3HelpCenter = ({ autoStartSurvey, origin, flags, isOpen, onRequest
|
|
|
78
76
|
React.useEffect(() => {
|
|
79
77
|
const tokenChanged = token !== userToken && !!userToken;
|
|
80
78
|
const orgChanged = organizationId !== activeOrganizationId && !!activeOrganizationId;
|
|
79
|
+
const decodedTokenChanged = !tokenChanged && !orgChanged;
|
|
81
80
|
if (tokenChanged)
|
|
82
81
|
setToken(userToken);
|
|
83
82
|
if (orgChanged)
|
|
84
83
|
setOrganizationId(activeOrganizationId);
|
|
85
|
-
if (tokenChanged || orgChanged)
|
|
84
|
+
if (tokenChanged || decodedTokenChanged || orgChanged)
|
|
86
85
|
fetchData();
|
|
87
|
-
}, [userToken, activeOrganizationId]);
|
|
86
|
+
}, [userToken, decodedToken, activeOrganizationId]);
|
|
88
87
|
React.useEffect(() => {
|
|
89
88
|
const tabs = helpCenterConfig.tabs;
|
|
90
89
|
const firstTab = tabs[0].id;
|
|
@@ -30,6 +30,13 @@ const StyledToggletipContent = styled(ToggletipContent) `
|
|
|
30
30
|
color: var(--cds-link-hover-text-color);
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
|
+
const ClusterTagWrapper = styled.div `
|
|
34
|
+
.cds--tag {
|
|
35
|
+
height: 1.5rem;
|
|
36
|
+
margin-top: 0.75rem;
|
|
37
|
+
padding: 0 1rem;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
33
40
|
export const C3Navigation = ({ app, appBar, forwardRef, navbar, orgSideBar, infoSideBar, infoButton, helpCenter, actionButtons, userSideBar, notificationSideBar, clusterUuid, }) => {
|
|
34
41
|
const isLargeScreen = useMediaQuery(`(min-width: ${BREAKPOINT_LG_WIDTH}`);
|
|
35
42
|
const appBarElementsLength = appBar.elements?.length ?? 0;
|
|
@@ -80,11 +87,8 @@ export const C3Navigation = ({ app, appBar, forwardRef, navbar, orgSideBar, info
|
|
|
80
87
|
padding: "0 1rem",
|
|
81
88
|
}, type: tag.color }, tag.label));
|
|
82
89
|
}),
|
|
83
|
-
clusterUuid && (React.createElement(
|
|
84
|
-
|
|
85
|
-
marginTop: "0.75rem",
|
|
86
|
-
padding: "0 1rem",
|
|
87
|
-
}, clusterUuid: clusterUuid })),
|
|
90
|
+
clusterUuid && (React.createElement(ClusterTagWrapper, null,
|
|
91
|
+
React.createElement(C3ClusterTag, { clusterUuid: clusterUuid }))),
|
|
88
92
|
navbar.orgName && (React.createElement("div", { className: "bodyText", style: {
|
|
89
93
|
fontSize: "14px",
|
|
90
94
|
lineHeight: "3rem",
|
|
@@ -2,10 +2,9 @@ import React, { useState } from "react";
|
|
|
2
2
|
import { OnboardingSurvey } from "./onboardingSurvey";
|
|
3
3
|
import { defaultOnboardingConfig } from "./defaultOnboardingConfig";
|
|
4
4
|
import { getOnboardingConfig, submitSurvey, updatePersona, } from "../../api/help-center";
|
|
5
|
-
import { decodeJWT } from "../c3-user-configuration/authToken";
|
|
6
5
|
import { useC3UserConfiguration } from "../c3-user-configuration/c3-user-configuration-provider";
|
|
7
6
|
export const C3OnboardingSurvey = (props) => {
|
|
8
|
-
const { userToken, activeOrganizationId } = useC3UserConfiguration() || {};
|
|
7
|
+
const { userToken, decodedToken, activeOrganizationId } = useC3UserConfiguration() || {};
|
|
9
8
|
const [persona, setPersona] = useState(props.persona);
|
|
10
9
|
const [userId, setUserId] = useState("");
|
|
11
10
|
const [token, setToken] = useState("");
|
|
@@ -18,7 +17,6 @@ export const C3OnboardingSurvey = (props) => {
|
|
|
18
17
|
return;
|
|
19
18
|
setToken(userToken);
|
|
20
19
|
(async () => {
|
|
21
|
-
const decodedToken = decodeJWT(userToken);
|
|
22
20
|
if (!decodedToken)
|
|
23
21
|
return;
|
|
24
22
|
const { userId, meta, audience, persona } = decodedToken;
|
|
@@ -19,11 +19,12 @@ export type Meta = {
|
|
|
19
19
|
email: string;
|
|
20
20
|
};
|
|
21
21
|
export declare const getMeta: (token: Token) => Meta | undefined;
|
|
22
|
-
export
|
|
23
|
-
audience?: string | string[]
|
|
24
|
-
persona?: Persona
|
|
22
|
+
export type DecodedToken = {
|
|
23
|
+
audience?: string | string[];
|
|
24
|
+
persona?: Persona;
|
|
25
25
|
decodedToken: Token;
|
|
26
|
-
userId?: string
|
|
27
|
-
meta?: Meta
|
|
28
|
-
}
|
|
26
|
+
userId?: string;
|
|
27
|
+
meta?: Meta;
|
|
28
|
+
};
|
|
29
|
+
export declare const decodeJWT: (userToken: string) => null | DecodedToken;
|
|
29
30
|
export {};
|
|
@@ -3,7 +3,6 @@ import { C3UserConfigurationContext } from "../c3-user-configuration-provider";
|
|
|
3
3
|
import { getUserTheme, updateTheme } from "../../../api/profile";
|
|
4
4
|
import { CarbonThemeProvider, resolveTheme, } from "./carbon-theme-provider";
|
|
5
5
|
import { getClusters } from "../../../api/help-center";
|
|
6
|
-
import { decodeJWT } from "../authToken";
|
|
7
6
|
export const defaultTheme = "light";
|
|
8
7
|
export const C3ProfileContext = createContext({
|
|
9
8
|
isEnabled: false,
|
|
@@ -13,13 +12,12 @@ export const C3ProfileContext = createContext({
|
|
|
13
12
|
onThemeChange: () => undefined,
|
|
14
13
|
});
|
|
15
14
|
export const C3ProfileProvider = ({ children }) => {
|
|
16
|
-
const config = useContext(C3UserConfigurationContext);
|
|
15
|
+
const { decodedToken, ...config } = useContext(C3UserConfigurationContext);
|
|
17
16
|
const isEnabled = !!config;
|
|
18
17
|
const themeRef = useRef(getUserTheme(config.userToken) || defaultTheme);
|
|
19
18
|
const [resolvedTheme, setResolvedTheme] = useState(defaultTheme);
|
|
20
19
|
const [clusters, setClusters] = useState(null);
|
|
21
20
|
useEffect(() => {
|
|
22
|
-
const decodedToken = decodeJWT(config?.userToken);
|
|
23
21
|
if (!decodedToken)
|
|
24
22
|
return;
|
|
25
23
|
const { audience } = decodedToken;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC, ReactNode } from "react";
|
|
2
2
|
import { Endpoints, Stage } from "../../api/endpoints.const";
|
|
3
|
+
import { DecodedToken } from "./authToken";
|
|
3
4
|
type C3UserConfigurationBase = {
|
|
4
5
|
activeOrganizationId: string;
|
|
5
6
|
userToken: string;
|
|
@@ -14,9 +15,12 @@ type C3UserConfigurationWithStage = C3UserConfigurationBase & {
|
|
|
14
15
|
handleTheme?: boolean;
|
|
15
16
|
};
|
|
16
17
|
export type C3UserConfiguration = C3UserConfigurationWithEndpoints | C3UserConfigurationWithStage;
|
|
17
|
-
export
|
|
18
|
+
export type C3UserConfigurationContextValue = C3UserConfiguration & {
|
|
19
|
+
decodedToken: DecodedToken | null;
|
|
20
|
+
};
|
|
21
|
+
export declare const C3UserConfigurationContext: React.Context<C3UserConfigurationContextValue>;
|
|
18
22
|
declare const C3UserConfigurationProvider: FC<C3UserConfiguration & {
|
|
19
23
|
children?: ReactNode;
|
|
20
24
|
}>;
|
|
21
|
-
export declare const useC3UserConfiguration: () =>
|
|
25
|
+
export declare const useC3UserConfiguration: () => C3UserConfigurationContextValue;
|
|
22
26
|
export default C3UserConfigurationProvider;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
2
2
|
import { C3ProfileProvider } from "./c3-profile-provider/c3-profile-provider";
|
|
3
|
+
import { decodeJWT } from "./authToken";
|
|
3
4
|
export const C3UserConfigurationContext = React.createContext({
|
|
4
5
|
stage: "dev",
|
|
5
6
|
activeOrganizationId: "",
|
|
6
7
|
userToken: "",
|
|
8
|
+
decodedToken: null,
|
|
7
9
|
getNewUserToken: () => Promise.resolve(""),
|
|
8
10
|
});
|
|
9
|
-
const C3UserConfigurationProvider = ({ children, ...config }) =>
|
|
10
|
-
|
|
11
|
+
const C3UserConfigurationProvider = ({ children, ...config }) => {
|
|
12
|
+
const [decodedToken, setDecodedToken] = useState(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (config.userToken)
|
|
15
|
+
setDecodedToken(decodeJWT(config.userToken));
|
|
16
|
+
}, [config.userToken]);
|
|
17
|
+
return (React.createElement(C3UserConfigurationContext.Provider, { value: { ...config, decodedToken } },
|
|
18
|
+
React.createElement(C3ProfileProvider, null, children)));
|
|
19
|
+
};
|
|
11
20
|
export const useC3UserConfiguration = () => useContext(C3UserConfigurationContext);
|
|
12
21
|
export default C3UserConfigurationProvider;
|