@firecms/user_management 3.0.0-3.0.0-beta.4.pre.1.0
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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/UserManagementProvider.d.ts +7 -0
- package/dist/admin_views.d.ts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/roles/RoleChip.d.ts +5 -0
- package/dist/components/roles/RolesDetailsForm.d.ts +20 -0
- package/dist/components/roles/RolesTable.d.ts +5 -0
- package/dist/components/roles/RolesView.d.ts +4 -0
- package/dist/components/roles/default_roles.d.ts +2 -0
- package/dist/components/roles/index.d.ts +4 -0
- package/dist/components/users/UserDetailsForm.d.ts +20 -0
- package/dist/components/users/UsersTable.d.ts +4 -0
- package/dist/components/users/UsersView.d.ts +4 -0
- package/dist/components/users/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useBuildFirestoreUserManagement.d.ts +44 -0
- package/dist/hooks/useUserManagement.d.ts +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +1263 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/firecms_user.d.ts +7 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/user_management.d.ts +39 -0
- package/dist/useUserManagementPlugin.d.ts +5 -0
- package/dist/utils/colors.d.ts +2 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/local_storage.d.ts +3 -0
- package/dist/utils/permissions.d.ts +9 -0
- package/dist/utils/useTraceUpdate.d.ts +1 -0
- package/package.json +76 -0
- package/src/UserManagementProvider.tsx +19 -0
- package/src/admin_views.tsx +19 -0
- package/src/components/index.ts +2 -0
- package/src/components/roles/RoleChip.tsx +28 -0
- package/src/components/roles/RolesDetailsForm.tsx +402 -0
- package/src/components/roles/RolesTable.tsx +139 -0
- package/src/components/roles/RolesView.tsx +63 -0
- package/src/components/roles/default_roles.tsx +36 -0
- package/src/components/roles/index.ts +4 -0
- package/src/components/users/UserDetailsForm.tsx +230 -0
- package/src/components/users/UsersTable.tsx +178 -0
- package/src/components/users/UsersView.tsx +59 -0
- package/src/components/users/index.ts +3 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useBuildFirestoreUserManagement.tsx +241 -0
- package/src/hooks/useUserManagement.tsx +5 -0
- package/src/index.ts +7 -0
- package/src/types/firecms_user.ts +8 -0
- package/src/types/index.ts +3 -0
- package/src/types/roles.ts +41 -0
- package/src/types/user_management.tsx +50 -0
- package/src/useUserManagementPlugin.tsx +18 -0
- package/src/utils/colors.ts +52 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/local_storage.ts +53 -0
- package/src/utils/permissions.ts +83 -0
- package/src/utils/useTraceUpdate.tsx +23 -0
- package/tailwind.config.js +68 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 FireCMS
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://firecms.co">
|
3
|
+
<img src="https://firecms.co/img/logo_small.png" width="240px" alt="FireCMS logo" />
|
4
|
+
</a>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<h1 align="center">FireCMS</h1>
|
8
|
+
<h3 align="center">Awesome Firebase/Firestore-based headless CMS</h3>
|
9
|
+
<p align="center"><a href="https://demo.firecms.co">Live demo</a></p>
|
10
|
+
|
11
|
+
<br />
|
12
|
+
|
13
|
+
|
14
|
+
[](https://www.npmjs.com/package/firecms) [](https://opensource.org/licenses/MIT)
|
15
|
+
|
16
|
+
FireCMS is a headless CMS and admin panel
|
17
|
+
that seamlessly integrates with **Firebase and Firestore** by default, but is
|
18
|
+
also compatible with any backend.
|
19
|
+
|
20
|
+
Effortlessly generate **CRUD views** based on your configuration. FireCMS is
|
21
|
+
simple to set up for standard cases and easy to extend and customize for more specific
|
22
|
+
needs.
|
23
|
+
|
24
|
+
Built to produce collection and form views that naturally align with the
|
25
|
+
collection/document model, FireCMS covers a wide range of basic and advanced use
|
26
|
+
cases. With extensibility in mind, it's easy to create your own views or modify
|
27
|
+
existing ones.
|
28
|
+
|
29
|
+
FireCMS does **not impose any data structure** restrictions, ensuring a smooth,
|
30
|
+
out-of-the-box experience for any project.
|
31
|
+
|
32
|
+
### Core technologies
|
33
|
+
|
34
|
+
FireCMS is based on this great technologies:
|
35
|
+
|
36
|
+
- Typescript
|
37
|
+
- Tailwind CSS
|
38
|
+
- Firebase SDK 10
|
39
|
+
- React + React Router 6
|
40
|
+
|
41
|
+
### Demo
|
42
|
+
|
43
|
+
Check the demo with all the core functionalities.
|
44
|
+
|
45
|
+
https://demo.firecms.co
|
46
|
+
|
47
|
+
> You can modify the data, but it gets periodically restored.
|
48
|
+
|
49
|
+
### Getting started
|
50
|
+
|
51
|
+
The easies way to get started is through [FireCMS Cloud](https://app.firecms.co/).
|
52
|
+
Bring your project or create a new one in seconds.
|
53
|
+
|
54
|
+
It will allow you to get started without writing a single line of code. Create collections
|
55
|
+
and entities, and start editing your data.
|
56
|
+
|
57
|
+
Later on, if you need to customize the CMS, you can build and compile your own views, form fields
|
58
|
+
and other components, and upload them to your project.
|
59
|
+
|
60
|
+
## Features
|
61
|
+
|
62
|
+
FireCMS has been meticulously crafted to make it incredibly easy for developers
|
63
|
+
to build a CMS/admin tool while offering an excellent data editing experience
|
64
|
+
and a user-friendly interface for marketers and content managers.
|
65
|
+
|
66
|
+
### 🏓 Exceptional Spreadsheet View
|
67
|
+
|
68
|
+
We've developed a highly efficient windowed **spreadsheet view** for
|
69
|
+
collections, allowing inline editing for most common fields, as well as popup
|
70
|
+
views for other cases and your custom field implementations.
|
71
|
+
|
72
|
+
Featuring **real-time** support, FireCMS is perfect for apps that require
|
73
|
+
constant updates. It also supports **text search** (through an external provider
|
74
|
+
like Algolia, if using Firestore), **filtering and sorting**, and **exporting**
|
75
|
+
data.
|
76
|
+
|
77
|
+
### 📥📤 Data import and export
|
78
|
+
|
79
|
+
FireCMS supports importing and exporting data in CSV format as well as JSON.
|
80
|
+
Bring your data from other sources or export it to use it in other systems.
|
81
|
+
|
82
|
+
We offer a robust and flexible system for defining the import and export
|
83
|
+
configuration, allowing you to define the fields to be imported/exported, the
|
84
|
+
format, and the mapping between the fields in the file and the fields in the
|
85
|
+
collection.
|
86
|
+
|
87
|
+
### ✨ Robust Forms
|
88
|
+
|
89
|
+

|
90
|
+
|
91
|
+
When editing an entity, FireCMS offers a nested system of side dialogs for
|
92
|
+
navigating through **subcollections** and accessing custom views (such as custom
|
93
|
+
forms or blog previews). This functionality can also be accessed
|
94
|
+
programmatically using the `useSideEntityController` hook.
|
95
|
+
|
96
|
+
FireCMS includes **over 15 built-in fields** with numerous customization and
|
97
|
+
validation options. The components have been carefully designed for an
|
98
|
+
outstanding user experience, including advanced features like **references** to
|
99
|
+
other collections, **markdown**, and **array reordering**.
|
100
|
+
|
101
|
+
For unsupported use cases, create your own **custom field** as a React
|
102
|
+
component.
|
103
|
+
|
104
|
+
FireCMS also supports **conditional fields** in forms, allowing you to define
|
105
|
+
rules for active fields based on your logic.
|
106
|
+
|
107
|
+
### 👮 Authentication, Permissions, and Role System
|
108
|
+
|
109
|
+
Define which navigation views users can see and the operations (create, edit,
|
110
|
+
delete) they can perform based on your role system. You can even configure this
|
111
|
+
on a per-entity or collection level.
|
112
|
+
|
113
|
+
By default, FireCMS supports all Firebase authorization mechanisms, but you can
|
114
|
+
implement your own.
|
115
|
+
|
116
|
+
### 🏹 Relational Support
|
117
|
+
|
118
|
+
Define references to entities in other collections and benefit from the
|
119
|
+
integrated reference fields and shortcuts.
|
120
|
+
|
121
|
+
You can also define subcollections at the entity level for nesting data in a
|
122
|
+
collection/document/collection model.
|
123
|
+
|
124
|
+
### 🆒 Real-Time Data
|
125
|
+
|
126
|
+
Every view in the CMS supports real-time data, making it suitable for displaying
|
127
|
+
constantly updated information.
|
128
|
+
|
129
|
+
Forms also support this feature, with any modified value in the database being
|
130
|
+
updated in any open form view as long as it hasn't been touched by the user.
|
131
|
+
This enables advanced cases where a Cloud Function is triggered after saving an
|
132
|
+
entity, modifying some values, and requiring real-time updates.
|
133
|
+
|
134
|
+
### 🗂️ File Storage
|
135
|
+
|
136
|
+
FireCMS supports uploading files to Firebase Storage out of the box and provides
|
137
|
+
specific fields for handling single and multiple file uploads, as well as
|
138
|
+
reordering.
|
139
|
+
|
140
|
+
You can replace the Firebase Storage implementation with your own.
|
141
|
+
|
142
|
+
## Contact and support
|
143
|
+
|
144
|
+
If you need general support, you can open a [GitHub issue](https://github.com/firecmsco/firecms/issues) or join
|
145
|
+
our [Discord channel](https://discord.gg/fxy7xsQm3m).
|
146
|
+
|
147
|
+
Do you need consulting setting up your Firestore-based CMS in no time? We are
|
148
|
+
happy to help!
|
149
|
+
`hello@firecms.co`
|
150
|
+
|
151
|
+
## Changelog
|
152
|
+
|
153
|
+
https://firecms.co/docs/changelog
|
154
|
+
|
155
|
+
## License
|
156
|
+
|
157
|
+
MIT © [FireCMS](https://github.com/FireCMSco)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
2
|
+
import { UserManagement, UserWithRoles } from "./types";
|
3
|
+
export declare const UserManagementContext: React.Context<UserManagement<any>>;
|
4
|
+
export interface UserManagementProviderProps<U extends UserWithRoles = UserWithRoles> {
|
5
|
+
userManagement: UserManagement<U>;
|
6
|
+
}
|
7
|
+
export declare function UserManagementProvider<U extends UserWithRoles = UserWithRoles>({ children, userManagement }: PropsWithChildren<UserManagementProviderProps<U>>): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import * as Yup from "yup";
|
2
|
+
import { EntityCollection } from "@firecms/core";
|
3
|
+
import { Role } from "../../types";
|
4
|
+
export declare const RoleYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
5
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
6
|
+
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
7
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
8
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
9
|
+
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
10
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
11
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
12
|
+
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
13
|
+
}>>>;
|
14
|
+
export declare function RolesDetailsForm({ open, role, editable, handleClose, collections }: {
|
15
|
+
open: boolean;
|
16
|
+
editable?: boolean;
|
17
|
+
role?: Role;
|
18
|
+
handleClose: () => void;
|
19
|
+
collections?: EntityCollection[];
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import * as Yup from "yup";
|
2
|
+
import { UserWithRoles } from "../../types";
|
3
|
+
export declare const UserYupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
4
|
+
displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
5
|
+
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
6
|
+
roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
|
7
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
8
|
+
displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
9
|
+
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
10
|
+
roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
|
11
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
12
|
+
displayName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
13
|
+
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
14
|
+
roles: import("yup/lib/array").OptionalArraySchema<Yup.AnySchema, import("yup/lib/types").AnyObject, any[] | undefined>;
|
15
|
+
}>>>;
|
16
|
+
export declare function UserDetailsForm({ open, user: userProp, handleClose }: {
|
17
|
+
open: boolean;
|
18
|
+
user?: UserWithRoles;
|
19
|
+
handleClose: () => void;
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { FirebaseApp } from "firebase/app";
|
2
|
+
import { UserManagement } from "../types";
|
3
|
+
import { AuthController } from "@firecms/core";
|
4
|
+
export interface UserManagementParams {
|
5
|
+
/**
|
6
|
+
* The Firebase app to use for the user management. The config will be saved in the Firestore
|
7
|
+
* collection indicated by `configPath`.
|
8
|
+
*/
|
9
|
+
firebaseApp?: FirebaseApp;
|
10
|
+
/**
|
11
|
+
* Path where the plugin users configuration is stored.
|
12
|
+
* Default: __FIRECMS/config/users
|
13
|
+
* You can specify a different path if you want to store the user management configuration in a different place.
|
14
|
+
* Please keep in mind that the FireCMS users are not necessarily the same as the Firebase users (but they can be).
|
15
|
+
* The path should be relative to the root of the Firestore database, and should always have an odd number of segments.
|
16
|
+
*/
|
17
|
+
usersPath?: string;
|
18
|
+
/**
|
19
|
+
* Path where the plugin roles configuration is stored.
|
20
|
+
* Default: __FIRECMS/config/roles
|
21
|
+
*/
|
22
|
+
rolesPath?: string;
|
23
|
+
usersLimit?: number;
|
24
|
+
canEditRoles?: boolean;
|
25
|
+
authController: AuthController;
|
26
|
+
/**
|
27
|
+
* If there are no roles in the database, provide a button to create the default roles.
|
28
|
+
*/
|
29
|
+
allowDefaultRolesCreation?: boolean;
|
30
|
+
/**
|
31
|
+
* Include the collection config permissions in the user management system.
|
32
|
+
*/
|
33
|
+
includeCollectionConfigPermissions?: boolean;
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* This hook is used to build a user management object that can be used to
|
37
|
+
* manage users and roles in a Firestore backend.
|
38
|
+
* @param backendFirebaseApp
|
39
|
+
* @param usersPath
|
40
|
+
* @param rolesPath
|
41
|
+
* @param usersLimit
|
42
|
+
* @param canEditRoles
|
43
|
+
*/
|
44
|
+
export declare function useBuildFirestoreUserManagement({ firebaseApp, usersPath, rolesPath, usersLimit, canEditRoles, authController, allowDefaultRolesCreation, includeCollectionConfigPermissions }: UserManagementParams): UserManagement;
|