@camunda/camunda-composite-components 0.2.18-rc.5 → 0.2.18-rc.6
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-navigation/c3-navigation-sidebar/c3-org-sidebar.js +3 -3
- package/lib/esm/components/c3-user-configuration/c3-profile-provider/c3-profile-provider.d.ts +2 -0
- package/lib/esm/components/c3-user-configuration/c3-profile-provider/c3-profile-provider.js +17 -4
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.d.ts +0 -1
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.js +0 -2
- package/package.json +1 -1
|
@@ -9,8 +9,8 @@ import { useC3UserConfiguration } from "../../c3-user-configuration/c3-user-conf
|
|
|
9
9
|
const C3OrgSidebar = ({ sideBar }) => {
|
|
10
10
|
const { customElements, switchToOrg, elements, ...sideBarProps } = sideBar;
|
|
11
11
|
const { isOpen, setIsOpen } = useOrgSidebarState();
|
|
12
|
-
const { decodedAudience,
|
|
13
|
-
const { activeOrg, orgs } = useC3Profile();
|
|
12
|
+
const { decodedAudience, analyticsTrack } = useC3UserConfiguration();
|
|
13
|
+
const { activeOrg, orgs, setActiveOrg } = useC3Profile();
|
|
14
14
|
const isCustomized = Boolean(customElements?.activeOrganization);
|
|
15
15
|
const onManageOrg = () => {
|
|
16
16
|
if (!isCustomized) {
|
|
@@ -29,7 +29,7 @@ const C3OrgSidebar = ({ sideBar }) => {
|
|
|
29
29
|
otherLabel: "Other Organizations",
|
|
30
30
|
};
|
|
31
31
|
const switchOrg = (orgId) => {
|
|
32
|
-
|
|
32
|
+
setActiveOrg(orgId);
|
|
33
33
|
analyticsTrack?.("navBar:orgSwitch:click", { orgId });
|
|
34
34
|
switchToOrg?.(orgId);
|
|
35
35
|
setIsOpen(false);
|
package/lib/esm/components/c3-user-configuration/c3-profile-provider/c3-profile-provider.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type C3ProfileContextValue = {
|
|
|
8
8
|
theme: Theme;
|
|
9
9
|
orgs: Organization[] | null;
|
|
10
10
|
activeOrg: Organization | null;
|
|
11
|
+
setActiveOrg: (orgId: string) => void;
|
|
12
|
+
reloadOrgs: () => void;
|
|
11
13
|
clusters: Cluster[] | null;
|
|
12
14
|
reloadClusters: () => void;
|
|
13
15
|
resolvedTheme: ResolvedTheme;
|
|
@@ -8,6 +8,8 @@ export const C3ProfileContext = createContext({
|
|
|
8
8
|
theme: defaultTheme,
|
|
9
9
|
orgs: null,
|
|
10
10
|
activeOrg: null,
|
|
11
|
+
setActiveOrg: () => undefined,
|
|
12
|
+
reloadOrgs: () => undefined,
|
|
11
13
|
clusters: null,
|
|
12
14
|
reloadClusters: () => undefined,
|
|
13
15
|
resolvedTheme: defaultTheme,
|
|
@@ -21,21 +23,24 @@ export const C3ProfileProvider = ({ children }) => {
|
|
|
21
23
|
const [orgs, setOrgs] = useState(null);
|
|
22
24
|
const [activeOrg, setActiveOrg] = useState(null);
|
|
23
25
|
const [clusters, setClusters] = useState(null);
|
|
26
|
+
const isConfigValid = config.userToken && config.activeOrganizationId && decodedAudience;
|
|
24
27
|
const loadClusters = () => {
|
|
25
|
-
if (!
|
|
28
|
+
if (!isConfigValid)
|
|
26
29
|
return;
|
|
27
30
|
getClusters(decodedAudience, config.userToken, config.activeOrganizationId).then((res) => {
|
|
28
31
|
setClusters(res);
|
|
29
32
|
});
|
|
30
33
|
};
|
|
31
|
-
|
|
32
|
-
if (!
|
|
34
|
+
const loadOrgs = () => {
|
|
35
|
+
if (!isConfigValid)
|
|
33
36
|
return;
|
|
34
|
-
}
|
|
35
37
|
getOrgs(decodedAudience, config.userToken).then((res) => {
|
|
36
38
|
setOrgs(res);
|
|
37
39
|
setActiveOrg(res?.find((org) => org.uuid === config.activeOrganizationId) || null);
|
|
38
40
|
});
|
|
41
|
+
};
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
loadOrgs();
|
|
39
44
|
loadClusters();
|
|
40
45
|
}, [
|
|
41
46
|
config?.activeOrganizationId,
|
|
@@ -81,6 +86,14 @@ export const C3ProfileProvider = ({ children }) => {
|
|
|
81
86
|
resolvedTheme,
|
|
82
87
|
orgs,
|
|
83
88
|
activeOrg,
|
|
89
|
+
setActiveOrg: (orgId) => {
|
|
90
|
+
if (orgs) {
|
|
91
|
+
const org = orgs.find((org) => org.uuid === orgId);
|
|
92
|
+
if (org)
|
|
93
|
+
setActiveOrg(org);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
reloadOrgs: loadOrgs,
|
|
84
97
|
clusters,
|
|
85
98
|
reloadClusters: loadClusters,
|
|
86
99
|
onThemeChange,
|
|
@@ -21,7 +21,6 @@ export type C3UserConfiguration = C3UserConfigurationWithEndpoints | C3UserConfi
|
|
|
21
21
|
export type C3UserConfigurationContextValue = C3UserConfiguration & {
|
|
22
22
|
decodedToken: DecodedToken | null;
|
|
23
23
|
decodedAudience: string | null;
|
|
24
|
-
setActiveOrgId: (newOrg: string) => void;
|
|
25
24
|
analyticsTrack?: MixPanelTrack;
|
|
26
25
|
};
|
|
27
26
|
export declare const C3UserConfigurationContext: React.Context<C3UserConfigurationContextValue>;
|
|
@@ -9,7 +9,6 @@ export const C3UserConfigurationContext = React.createContext({
|
|
|
9
9
|
decodedToken: null,
|
|
10
10
|
decodedAudience: null,
|
|
11
11
|
getNewUserToken: () => Promise.resolve(""),
|
|
12
|
-
setActiveOrgId: () => undefined,
|
|
13
12
|
});
|
|
14
13
|
const C3UserConfigurationProvider = ({ children, activeOrganizationId, ...config }) => {
|
|
15
14
|
const [decodedToken, setDecodedToken] = useState(null);
|
|
@@ -29,7 +28,6 @@ const C3UserConfigurationProvider = ({ children, activeOrganizationId, ...config
|
|
|
29
28
|
return (React.createElement(C3UserConfigurationContext.Provider, { value: {
|
|
30
29
|
...config,
|
|
31
30
|
activeOrganizationId: activeOrgId,
|
|
32
|
-
setActiveOrgId,
|
|
33
31
|
decodedToken,
|
|
34
32
|
decodedAudience,
|
|
35
33
|
} },
|