@firecms/user_management 3.0.0-canary.85 → 3.0.0-canary.86
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/hooks/useBuildUserManagement.d.ts +2 -0
- package/dist/index.es.js +17 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +18 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/hooks/useBuildUserManagement.tsx +28 -20
package/dist/index.umd.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
(function(global, factory) {
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@firecms/ui"), require("yup"), require("@firecms/core"), require("@firecms/formex"), require("date-fns"), require("date-fns/locale")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@firecms/ui", "yup", "@firecms/core", "@firecms/formex", "date-fns", "date-fns/locale"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.FireCMS = {}, global.React, global.jsxRuntime, global.ui, global.Yup, global.core, global.formex, global.dateFns, global.locales));
|
3
|
-
})(this, function(exports2, React, jsxRuntime, ui, Yup, core, formex, dateFns, locales) {
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react-fast-compare"), require("react/jsx-runtime"), require("@firecms/ui"), require("yup"), require("@firecms/core"), require("@firecms/formex"), require("date-fns"), require("date-fns/locale")) : typeof define === "function" && define.amd ? define(["exports", "react", "react-fast-compare", "react/jsx-runtime", "@firecms/ui", "yup", "@firecms/core", "@firecms/formex", "date-fns", "date-fns/locale"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.FireCMS = {}, global.React, global.equal, global.jsxRuntime, global.ui, global.Yup, global.core, global.formex, global.dateFns, global.locales));
|
3
|
+
})(this, function(exports2, React, equal, jsxRuntime, ui, Yup, core, formex, dateFns, locales) {
|
4
4
|
"use strict";
|
5
5
|
function _interopNamespaceDefault(e) {
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
@@ -175,13 +175,15 @@
|
|
175
175
|
const loading = rolesLoading || usersLoading;
|
176
176
|
React.useEffect(() => {
|
177
177
|
if (!dataSourceDelegate || !rolesPath) return;
|
178
|
-
dataSourceDelegate.
|
178
|
+
if (dataSourceDelegate.initialised !== void 0 && !dataSourceDelegate.initialised) return;
|
179
|
+
return dataSourceDelegate.listenCollection?.({
|
179
180
|
path: rolesPath,
|
180
181
|
onUpdate(entities) {
|
181
182
|
setRolesError(void 0);
|
182
183
|
try {
|
183
184
|
const newRoles = entityToRoles(entities);
|
184
|
-
|
185
|
+
if (!equal(newRoles, roles))
|
186
|
+
setRoles(newRoles);
|
185
187
|
} catch (e) {
|
186
188
|
console.error("Error loading roles", e);
|
187
189
|
setRolesError(e);
|
@@ -197,13 +199,15 @@
|
|
197
199
|
}, [dataSourceDelegate, rolesPath]);
|
198
200
|
React.useEffect(() => {
|
199
201
|
if (!dataSourceDelegate || !usersPath) return;
|
200
|
-
dataSourceDelegate.
|
202
|
+
if (dataSourceDelegate.initialised !== void 0 && !dataSourceDelegate.initialised) return;
|
203
|
+
return dataSourceDelegate.listenCollection?.({
|
201
204
|
path: usersPath,
|
202
205
|
onUpdate(entities) {
|
203
206
|
setUsersError(void 0);
|
204
207
|
try {
|
205
208
|
const newUsers = entitiesToUsers(entities);
|
206
|
-
|
209
|
+
if (!equal(newUsers, usersWithRoleIds))
|
210
|
+
setUsersWithRoleIds(newUsers);
|
207
211
|
} catch (e) {
|
208
212
|
console.error("Error loading users", e);
|
209
213
|
setUsersError(e);
|
@@ -218,8 +222,8 @@
|
|
218
222
|
});
|
219
223
|
}, [dataSourceDelegate, usersPath]);
|
220
224
|
const saveUser = React.useCallback(async (user) => {
|
221
|
-
if (!dataSourceDelegate) throw Error("
|
222
|
-
if (!usersPath) throw Error("
|
225
|
+
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
226
|
+
if (!usersPath) throw Error("useBuildUserManagement Firestore not initialised");
|
223
227
|
console.debug("Persisting user", user);
|
224
228
|
const roleIds = user.roles?.map((r) => r.id);
|
225
229
|
const {
|
@@ -246,8 +250,8 @@
|
|
246
250
|
}
|
247
251
|
}, [usersPath, dataSourceDelegate]);
|
248
252
|
const saveRole = React.useCallback((role) => {
|
249
|
-
if (!dataSourceDelegate) throw Error("
|
250
|
-
if (!rolesPath) throw Error("
|
253
|
+
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
254
|
+
if (!rolesPath) throw Error("useBuildUserManagement Firestore not initialised");
|
251
255
|
console.debug("Persisting role", role);
|
252
256
|
const {
|
253
257
|
id,
|
@@ -263,8 +267,8 @@
|
|
263
267
|
});
|
264
268
|
}, [rolesPath, dataSourceDelegate]);
|
265
269
|
const deleteUser = React.useCallback(async (user) => {
|
266
|
-
if (!dataSourceDelegate) throw Error("
|
267
|
-
if (!usersPath) throw Error("
|
270
|
+
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
271
|
+
if (!usersPath) throw Error("useBuildUserManagement Firestore not initialised");
|
268
272
|
console.debug("Deleting", user);
|
269
273
|
const { uid } = user;
|
270
274
|
const entity = {
|
@@ -275,8 +279,8 @@
|
|
275
279
|
await dataSourceDelegate.deleteEntity({ entity });
|
276
280
|
}, [usersPath, dataSourceDelegate]);
|
277
281
|
const deleteRole = React.useCallback(async (role) => {
|
278
|
-
if (!dataSourceDelegate) throw Error("
|
279
|
-
if (!rolesPath) throw Error("
|
282
|
+
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
283
|
+
if (!rolesPath) throw Error("useBuildUserManagement Firestore not initialised");
|
280
284
|
console.debug("Deleting", role);
|
281
285
|
const { id } = role;
|
282
286
|
const entity = {
|