mirror of
https://github.com/outline/outline.git
synced 2026-04-24 11:20:11 -05:00
617504d8bb
* Add admin role to GroupUser This change adds an admin role to GroupUser that allows group admins to: 1. Administer other users in the group 2. Change the group name Changes include: - Database migration to add isAdmin field to group_users table - Updated GroupUser model to include isAdmin field - Added isGroupAdmin policy utility function - Updated group policy to allow group admins to update groups - Added API endpoints for managing admin status - Updated GroupUsersStore to handle admin functionality - Added tests for the new functionality * Replace isAdmin with role-based approach for GroupUser - Added role field to GroupUser model using UserRole.Admin and UserRole.Member - Created migration to convert isAdmin boolean to role enum - Updated policies to be synchronous and require pre-loaded relationships - Updated API endpoints to support both role and legacy isAdmin parameters - Updated GroupUsersStore to handle role-based functionality - Updated tests to use role instead of isAdmin - Maintained backward compatibility with isAdmin in presenters * Remove isAdmin logic from GroupUser implementation - Removed isAdmin parameter from GroupUsersStore methods - Removed isAdmin field from presenter output - Removed isAdmin from API schemas - Removed isAdmin parameter handling in API endpoints - Updated tests to use role instead of isAdmin - Simplified role handling throughout the codebase * lint * tests * role -> permission * fe * test * Change permission label from 'Admin' to 'Manage' --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
78 lines
1.4 KiB
TypeScript
78 lines
1.4 KiB
TypeScript
import { InferAttributes, InferCreationAttributes } from "sequelize";
|
|
import {
|
|
DefaultScope,
|
|
BelongsTo,
|
|
ForeignKey,
|
|
Column,
|
|
Table,
|
|
DataType,
|
|
Scopes,
|
|
} from "sequelize-typescript";
|
|
import { GroupPermission } from "@shared/types";
|
|
import Group from "./Group";
|
|
import User from "./User";
|
|
import Model from "./base/Model";
|
|
import Fix from "./decorators/Fix";
|
|
|
|
@DefaultScope(() => ({
|
|
include: [
|
|
{
|
|
association: "user",
|
|
},
|
|
],
|
|
}))
|
|
@Scopes(() => ({
|
|
withGroup: {
|
|
include: [
|
|
{
|
|
association: "group",
|
|
},
|
|
],
|
|
},
|
|
withUser: {
|
|
include: [
|
|
{
|
|
association: "user",
|
|
},
|
|
],
|
|
},
|
|
}))
|
|
@Table({ tableName: "group_users", modelName: "group_user" })
|
|
@Fix
|
|
class GroupUser extends Model<
|
|
InferAttributes<GroupUser>,
|
|
Partial<InferCreationAttributes<GroupUser>>
|
|
> {
|
|
static eventNamespace = "groups";
|
|
|
|
@BelongsTo(() => User, "userId")
|
|
user: User;
|
|
|
|
@ForeignKey(() => User)
|
|
@Column(DataType.UUID)
|
|
userId: string;
|
|
|
|
@BelongsTo(() => Group, "groupId")
|
|
group: Group;
|
|
|
|
@ForeignKey(() => Group)
|
|
@Column(DataType.UUID)
|
|
groupId: string;
|
|
|
|
@BelongsTo(() => User, "createdById")
|
|
createdBy: User;
|
|
|
|
@ForeignKey(() => User)
|
|
@Column(DataType.UUID)
|
|
createdById: string;
|
|
|
|
@Column(DataType.ENUM(...Object.values(GroupPermission)))
|
|
permission: GroupPermission;
|
|
|
|
get modelId() {
|
|
return this.groupId;
|
|
}
|
|
}
|
|
|
|
export default GroupUser;
|