mirror of
https://github.com/outline/outline.git
synced 2026-03-13 16:19:12 -05:00
fix: Assorted fixes from group memberships branch (tom/document-group-permissions)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { CollectionIcon } from "outline-icons";
|
||||
import { CollectionIcon, PrivateCollectionIcon } from "outline-icons";
|
||||
import { getLuminance } from "polished";
|
||||
import * as React from "react";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
@@ -40,8 +40,11 @@ function ResolvedCollectionIcon({
|
||||
: "currentColor"
|
||||
: collectionColor);
|
||||
|
||||
const Component = collection.isPrivate
|
||||
? PrivateCollectionIcon
|
||||
: CollectionIcon;
|
||||
return (
|
||||
<CollectionIcon
|
||||
<Component
|
||||
color={color}
|
||||
expanded={expanded}
|
||||
size={size}
|
||||
|
||||
@@ -406,24 +406,29 @@ class User extends ParanoidModel<
|
||||
false;
|
||||
|
||||
/**
|
||||
* Returns the user's active group ids.
|
||||
* Returns the user's active groups.
|
||||
*
|
||||
* @param options Additional options to pass to the find
|
||||
* @returns An array of group ids
|
||||
* @returns An array of groups
|
||||
*/
|
||||
public groupIds = async (options: FindOptions<Group> = {}) => {
|
||||
const groupStubs = await Group.scope({
|
||||
public groups = (options: FindOptions<Group> = {}) =>
|
||||
Group.scope({
|
||||
method: ["withMembership", this.id],
|
||||
}).findAll({
|
||||
attributes: ["id"],
|
||||
where: {
|
||||
teamId: this.teamId,
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
return groupStubs.map((g) => g.id);
|
||||
};
|
||||
/**
|
||||
* Returns the user's active group ids.
|
||||
*
|
||||
* @param options Additional options to pass to the find
|
||||
* @returns An array of group ids
|
||||
*/
|
||||
public groupIds = async (options: FindOptions<Group> = {}) =>
|
||||
(await this.groups(options)).map((g) => g.id);
|
||||
|
||||
/**
|
||||
* Returns the user's active collection ids. This includes collections the user
|
||||
|
||||
@@ -61,6 +61,7 @@ router.post(
|
||||
pagination: ctx.state.pagination,
|
||||
data: {
|
||||
groups: await Promise.all(groups.map(presentGroup)),
|
||||
// TODO: Deprecated, will remove in the future as language conflicts with GroupMembership
|
||||
groupMemberships: (
|
||||
await Promise.all(
|
||||
groups.map((group) =>
|
||||
|
||||
@@ -83,6 +83,7 @@ router.post(
|
||||
const { user } = ctx.state.auth;
|
||||
const membership = await UserMembership.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
rejectOnEmpty: true,
|
||||
});
|
||||
authorize(user, "update", membership);
|
||||
|
||||
Reference in New Issue
Block a user