-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Collection admins (#5273 #5273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
allow(User, "delete", Collection, (user, collection) => { | ||
allow( | ||
User, | ||
["updateDocument", "createDocument", "deleteDocument"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: All these new policies, separated from "read", "update" of collection itself.
@@ -148,6 +148,21 @@ router.post("collections.info", auth(), async (ctx: APIContext) => { | |||
}; | |||
}); | |||
|
|||
router.post("collections.documents", auth(), async (ctx: APIContext) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New endpoint for getting the collection structure, it will no longer be returned from collections.info
and requires the "readDocument" permission which admins do not have by default.
@@ -8,7 +8,9 @@ const DocumentsSortParamsSchema = z.object({ | |||
/** Specifies the attributes by which documents will be sorted in the list */ | |||
sort: z | |||
.string() | |||
.refine((val) => ["createdAt", "updatedAt", "index", "title"].includes(val)) | |||
.refine((val) => | |||
["createdAt", "updatedAt", "publishedAt", "index", "title"].includes(val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated bug I found, publishedAt
is a valid sort option that was missing
@@ -293,6 +293,10 @@ class WebsocketProvider extends React.Component<Props> { | |||
collections.add(event); | |||
}); | |||
|
|||
this.socket.on("collections.update", (event: PartialWithId<Collection>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collections.update
now includes the entire model
children: React.ReactNode; | ||
}; | ||
|
||
function DocumentsLoader({ collection, enabled, children }: Props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to suspense if we ever get to React 18 🤷
return ( | ||
this.documents.length === 0 && | ||
this.store.rootStore.documents.inCollection(this.id).length === 0 | ||
); | ||
} | ||
|
||
8000 | @computed | |
get documentIds(): string[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed
} | ||
|
||
return undefined; | ||
return CollectionUser.findOrCreate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a collection now always adds yourself with admin permissions
This PR separates the permission for creating and editing documents in a collection from the ability to manage the collection (manage users/groups, change title, change sort order etc). As part of this it also separates viewing the collection's details from it's contents… this has a couple of really nice benefits:
A follow up here will be to create UI for admins to view and manage collections in settings.
closes #3454
related #835