10000 feat: Collection admins (#5273 by tommoor · Pull Request #5273 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 18 commits into from
Apr 30, 2023
Merged

feat: Collection admins (#5273 #5273

merged 18 commits into from
Apr 30, 2023

Conversation

tommoor
Copy link
Member
@tommoor tommoor commented Apr 28, 2023

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:

  • Give users access to write documents without the ability to change collection permissions
  • We no longer download the structure of all collections as part of bootstrapping the app when opening a new tab, making loading the app sidebar much faster.
  • Similarly this data is no longer downloaded when collection updates are made such as editing the title
  • This allows for a future admin UI that can list all collections in the instance without also exposing their content, admins can manage permissions and add themselves as a member to view content.

A follow up here will be to create UI for admins to view and manage collections in settings.

closes #3454
related #835

@tommoor tommoor marked this pull request as ready for review April 29, 2023 02:56
allow(User, "delete", Collection, (user, collection) => {
allow(
User,
["updateDocument", "createDocument", "deleteDocument"],
Copy link
Member Author

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) => {
Copy link
Member Author

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)
Copy link
Member Author

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>) => {
Copy link
Member Author

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) {
Copy link
Member Author

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 🤷

8000
return (
this.documents.length === 0 &&
this.store.rootStore.documents.inCollection(this.id).length === 0
);
}

@computed
get documentIds(): string[] {
Copy link
Member Author

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({
Copy link
Member Author

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

@tommoor tommoor changed the title feat: Collection admins feat: Collection admins (#5273 Apr 30, 2023
@tommoor tommoor merged commit d8b4fef into main Apr 30, 2023
@tommoor tommoor deleted the tom/split-collection-policy branch April 30, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes private collections are visible to admins
1 participant
0