@edifice.io/react 2.6.4 → 2.6.5-develop-b2school.20260908164713
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/dist/components/Tabs/hooks/useTabs.js +2 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useUserPreferences/index.d.ts +1 -0
- package/dist/hooks/useUserPreferences/useUserPreferences.d.ts +9 -0
- package/dist/hooks/useUserPreferences/useUserPreferences.js +39 -0
- package/dist/index.js +2 -0
- package/dist/modules/homepage/components/Header/Header.js +11 -4
- package/dist/modules/homepage/components/UserSpace/hooks/useProfileLinks.js +18 -8
- package/package.json +6 -6
|
@@ -12,8 +12,8 @@ const useTabs = ({
|
|
|
12
12
|
currentItem && (onChange == null || onChange(currentItem));
|
|
13
13
|
}, [activeTab]), useEffect(() => {
|
|
14
14
|
function setTabPosition() {
|
|
15
|
-
|
|
16
|
-
if (((
|
|
15
|
+
const activeElement = document.activeElement;
|
|
16
|
+
if (!((activeElement == null ? void 0 : activeElement.tagName) === "INPUT" || (activeElement == null ? void 0 : activeElement.tagName) === "TEXTAREA" || (activeElement == null ? void 0 : activeElement.isContentEditable))) {
|
|
17
17
|
const currentTabIndex = items.findIndex((item) => item.id === activeTab);
|
|
18
18
|
currentTabIndex === -1 && defaultId && setActiveTab(defaultId);
|
|
19
19
|
const currentTabRef = tabsRef.current[currentTabIndex];
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from './useUiOverride';
|
|
|
34
34
|
export * from './useUpload';
|
|
35
35
|
export * from './useUploadFiles';
|
|
36
36
|
export * from './useUser';
|
|
37
|
+
export * from './useUserPreferences';
|
|
37
38
|
export * from './useWorkspaceFile';
|
|
38
39
|
export * from './useWorkspaceFolders';
|
|
39
40
|
export * from './useWorkspaceSearch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, useUserPreferences } from './useUserPreferences';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const USER_PREFERENCES_QUERY_KEY: string[];
|
|
2
|
+
export declare function useUserPreferences<T extends Record<string, any> = Record<string, any>>(): {
|
|
3
|
+
preferences: T | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
isError: boolean;
|
|
6
|
+
refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<T, Error>>;
|
|
7
|
+
savePreferences: (preferences: T) => Promise<T>;
|
|
8
|
+
};
|
|
9
|
+
export default useUserPreferences;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { odeServices } from "@edifice.io/client";
|
|
2
|
+
import { useQueryClient, useQuery, queryOptions, useMutation } from "@tanstack/react-query";
|
|
3
|
+
const USER_PREFERENCES_QUERY_KEY = ["user", "preferences"];
|
|
4
|
+
function useUserPreferences() {
|
|
5
|
+
const queryClient = useQueryClient(), {
|
|
6
|
+
data: preferences,
|
|
7
|
+
isLoading,
|
|
8
|
+
isError,
|
|
9
|
+
refetch
|
|
10
|
+
} = useQuery(queryOptions({
|
|
11
|
+
queryKey: USER_PREFERENCES_QUERY_KEY,
|
|
12
|
+
queryFn: () => odeServices.conf().getUserPreferences(),
|
|
13
|
+
staleTime: 15e3
|
|
14
|
+
})), mutation = useMutation({
|
|
15
|
+
mutationFn: (preferences2) => odeServices.conf().saveUserPreferences(preferences2),
|
|
16
|
+
onMutate: async (preferences2) => {
|
|
17
|
+
queryClient.setQueryData(USER_PREFERENCES_QUERY_KEY, preferences2);
|
|
18
|
+
},
|
|
19
|
+
onError: () => {
|
|
20
|
+
queryClient.invalidateQueries({
|
|
21
|
+
queryKey: USER_PREFERENCES_QUERY_KEY
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
onSuccess: (preferences2) => {
|
|
25
|
+
queryClient.setQueryData(USER_PREFERENCES_QUERY_KEY, preferences2);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
preferences,
|
|
30
|
+
isLoading,
|
|
31
|
+
isError,
|
|
32
|
+
refetch,
|
|
33
|
+
savePreferences: (preferences2) => mutation.mutateAsync(preferences2)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
USER_PREFERENCES_QUERY_KEY,
|
|
38
|
+
useUserPreferences
|
|
39
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,7 @@ import { useOverlay } from "./components/PageLayout/hook/useOverlay.js";
|
|
|
160
160
|
import { useScreeb } from "./hooks/useScreeb/useScreeb.js";
|
|
161
161
|
import { useTreeSortable } from "./components/Tree/hooks/useTreeSortable.js";
|
|
162
162
|
import { useTreeView } from "./components/TreeView/hooks/useTreeView.js";
|
|
163
|
+
import { useUserPreferences } from "./hooks/useUserPreferences/useUserPreferences.js";
|
|
163
164
|
export {
|
|
164
165
|
AccessiblePalette,
|
|
165
166
|
default2 as ActionBar,
|
|
@@ -350,6 +351,7 @@ export {
|
|
|
350
351
|
default110 as useUpload,
|
|
351
352
|
default111 as useUploadFiles,
|
|
352
353
|
default112 as useUser,
|
|
354
|
+
useUserPreferences,
|
|
353
355
|
default113 as useWorkspaceFile,
|
|
354
356
|
default114 as useWorkspaceFolders,
|
|
355
357
|
default115 as useWorkspaceFoldersTree,
|
|
@@ -6,6 +6,7 @@ import { Navbar } from "../../../../components/Layout/components/Navbar.js";
|
|
|
6
6
|
import { NavItem } from "../../../../components/Layout/components/NavItem.js";
|
|
7
7
|
import { NavLink } from "../../../../components/Layout/components/NavLink.js";
|
|
8
8
|
import useHeader from "../../../../components/Layout/hooks/useHeader.js";
|
|
9
|
+
import SvgIconSetBackground from "../../../icons/components/IconSetBackground.js";
|
|
9
10
|
import SvgIconCommunitiesBeta from "../../../icons/components/nav/IconCommunitiesBeta.js";
|
|
10
11
|
import SvgIconDisconnect from "../../../icons/components/nav/IconDisconnect.js";
|
|
11
12
|
import SvgIconHomeBeta from "../../../icons/components/nav/IconHomeBeta.js";
|
|
@@ -86,10 +87,16 @@ const Header = ({
|
|
|
86
87
|
] }),
|
|
87
88
|
/* @__PURE__ */ jsxs(NavItem, { className: "position-relative", ref: userRef, id: popoverUserId, "aria-haspopup": "true", "aria-expanded": isUserHovered, "data-testid": "header-user-menu-button", children: [
|
|
88
89
|
/* @__PURE__ */ jsx(NavLink, { link: "/userbook/mon-compte", translate: t("navbar.myaccount"), "data-testid": "header-user-profile-button", children: /* @__PURE__ */ jsx(Avatar, { alt: userName, size: "sm", src: userAvatar, variant: "circle", className: "bg-white", width: "32", height: "32" }) }),
|
|
89
|
-
/* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
/* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */ jsxs(PopoverBody, { children: [
|
|
91
|
+
/* @__PURE__ */ jsxs("a", { href: "/timeline/customize", className: "nav-link customize d-flex align-items-center gap-8", "data-testid": "header-customize-button", children: [
|
|
92
|
+
/* @__PURE__ */ jsx(SvgIconSetBackground, { className: "icon" }),
|
|
93
|
+
/* @__PURE__ */ jsx("span", { id: "cutomize-label", className: "nav-text", children: t("navbar.customize") })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link logout d-flex align-items-center gap-8", "data-testid": "header-logout-button", children: [
|
|
96
|
+
/* @__PURE__ */ jsx(SvgIconDisconnect, { className: "icon logout" }),
|
|
97
|
+
/* @__PURE__ */ jsx("span", { id: "logout-label", className: "nav-text", children: t("navbar.disconnect") })
|
|
98
|
+
] })
|
|
99
|
+
] }) })
|
|
93
100
|
] })
|
|
94
101
|
] })
|
|
95
102
|
] }) });
|
|
@@ -17,18 +17,20 @@ function useProfileLinks(profile) {
|
|
|
17
17
|
structure: structureId
|
|
18
18
|
});
|
|
19
19
|
return `${baseUrl}?${params.toString()}`;
|
|
20
|
-
}, buildClassesUrl = (classIds = []) => {
|
|
21
|
-
const params = new URLSearchParams(
|
|
22
|
-
filters: "groups",
|
|
23
|
-
structure: structureId
|
|
24
|
-
});
|
|
20
|
+
}, buildClassesUrl = (parameters, classIds = []) => {
|
|
21
|
+
const params = new URLSearchParams(parameters);
|
|
25
22
|
return classIds.forEach((c) => params.append("class", String(c))), `${baseUrl}?${params.toString()}`;
|
|
26
23
|
};
|
|
27
24
|
switch (profile) {
|
|
28
25
|
case "Teacher":
|
|
29
26
|
return [{
|
|
30
27
|
text: t("homepage.userspace.teacher.link.classes"),
|
|
31
|
-
url: buildClassesUrl(
|
|
28
|
+
url: buildClassesUrl(
|
|
29
|
+
{
|
|
30
|
+
filters: "groups"
|
|
31
|
+
}
|
|
32
|
+
/* Do not explicitely add classes ids, because none <=> see all*/
|
|
33
|
+
)
|
|
32
34
|
}];
|
|
33
35
|
case "Student":
|
|
34
36
|
return [{
|
|
@@ -36,7 +38,12 @@ function useProfileLinks(profile) {
|
|
|
36
38
|
url: "/userbook/annuaire#/search?filters=groups&profile=Teacher"
|
|
37
39
|
}, {
|
|
38
40
|
text: t("homepage.userspace.student.link.classes"),
|
|
39
|
-
url: buildClassesUrl(
|
|
41
|
+
url: buildClassesUrl(
|
|
42
|
+
{
|
|
43
|
+
filters: "groups"
|
|
44
|
+
}
|
|
45
|
+
/* Do not explicitely add classes ids, because none <=> see all*/
|
|
46
|
+
)
|
|
40
47
|
}];
|
|
41
48
|
case "Relative":
|
|
42
49
|
return children != null && children.length ? children.map((child) => {
|
|
@@ -45,7 +52,10 @@ function useProfileLinks(profile) {
|
|
|
45
52
|
text: t("homepage.userspace.relative.link.classes", {
|
|
46
53
|
childName: child.firstName
|
|
47
54
|
}),
|
|
48
|
-
url: buildClassesUrl(
|
|
55
|
+
url: buildClassesUrl({
|
|
56
|
+
filters: "groups",
|
|
57
|
+
structure: structureId
|
|
58
|
+
}, (_a2 = child.classes) == null ? void 0 : _a2.map(({
|
|
49
59
|
id
|
|
50
60
|
}) => id))
|
|
51
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5-develop-b2school.20260908164713",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
"swiper": "10.1.0",
|
|
141
141
|
"ua-parser-js": "1.0.36",
|
|
142
142
|
"zustand": "4.5.7",
|
|
143
|
-
"@edifice.io/bootstrap": "2.6.
|
|
144
|
-
"@edifice.io/tiptap-extensions": "2.6.
|
|
145
|
-
"@edifice.io/utilities": "2.6.
|
|
143
|
+
"@edifice.io/bootstrap": "2.6.5-develop-b2school.20260908164713",
|
|
144
|
+
"@edifice.io/tiptap-extensions": "2.6.5-develop-b2school.20260908164713",
|
|
145
|
+
"@edifice.io/utilities": "2.6.5-develop-b2school.20260908164713"
|
|
146
146
|
},
|
|
147
147
|
"devDependencies": {
|
|
148
148
|
"@babel/plugin-transform-react-pure-annotations": "7.27.1",
|
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
"vite": "5.4.14",
|
|
174
174
|
"vite-plugin-dts": "4.5.4",
|
|
175
175
|
"vite-tsconfig-paths": "5.1.4",
|
|
176
|
-
"@edifice.io/client": "2.6.
|
|
177
|
-
"@edifice.io/config": "2.6.
|
|
176
|
+
"@edifice.io/client": "2.6.5-develop-b2school.20260908164713",
|
|
177
|
+
"@edifice.io/config": "2.6.5-develop-b2school.20260908164713"
|
|
178
178
|
},
|
|
179
179
|
"peerDependencies": {
|
|
180
180
|
"@react-spring/web": "9.7.5",
|