mirror of
https://github.com/outline/outline.git
synced 2026-11-30 17:10:36 +03:00
* Add description column to groups
- Add database migration to add description column to groups table
- Update server-side Group model with description field and validation
- Update group presenter to include description in API responses
- Update API schemas to validate description field in create/update operations
- Update client-side Group model with description field and search integration
- Update unfurl types and presenter to include description for hover cards
- Update HoverPreviewGroup component to display description in UI
The description field is optional with a 2000 character limit and is included
in group search functionality.
* Fix TypeScript error: Add missing description prop to HoverPreviewGroup
The HoverPreviewGroup component expects a description prop but it wasn't being passed from HoverPreview.tsx. This was causing the types check to fail with:
error TS2741: Property 'description' is missing in type '{ ref: MutableRefObject<HTMLDivElement | null>; name: any; memberCount: any; users: any; }' but required in type 'Props'.
Fixed by adding the description prop from data.description which is available in the UnfurlResponse[UnfurlResourceType.Group] type.
* Move 2000 char validation to shared constant
- Add GroupValidation.maxDescriptionLength constant to shared/validations.ts
- Update server Group model to use GroupValidation.maxDescriptionLength
- Update API schemas to use the shared constant instead of hardcoded value
- Ensures consistent validation across the entire application
* Add description field to CreateGroupDialog and EditGroupDialog
- Add description textarea input to both create and edit group dialogs
- Import GroupValidation constant for consistent character limit validation
- Set maxLength to GroupValidation.maxDescriptionLength (2000 chars)
- Include description in form submission for both create and update operations
- Add placeholder text for better UX
- Maintain backward compatibility with optional description field
* Add description column to GroupsTable
- Add description column between name and members columns
- Display group description with fallback to em dash (—) for empty descriptions
- Use secondary text styling for consistent visual hierarchy
- Set column width to 2fr for adequate space
- Maintain sortable functionality through accessor
* tweaks
* animation
---------
Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
127 lines
3.6 KiB
TypeScript
127 lines
3.6 KiB
TypeScript
import { z } from "zod";
|
|
import { GroupPermission } from "@shared/types";
|
|
import { GroupValidation } from "@shared/validations";
|
|
import { Group } from "@server/models";
|
|
|
|
const BaseIdSchema = z.object({
|
|
/** Group Id */
|
|
id: z.string().uuid(),
|
|
});
|
|
|
|
export const GroupsListSchema = z.object({
|
|
body: z.object({
|
|
/** Groups sorting direction */
|
|
direction: z
|
|
.string()
|
|
.optional()
|
|
.transform((val) => (val !== "ASC" ? "DESC" : val)),
|
|
/** Groups sorting column */
|
|
sort: z
|
|
.string()
|
|
.refine((val) => Object.keys(Group.getAttributes()).includes(val), {
|
|
message: "Invalid sort parameter",
|
|
})
|
|
.default("updatedAt"),
|
|
/** Only list groups where this user is a member */
|
|
userId: z.string().uuid().optional(),
|
|
/** Find group matching externalId */
|
|
externalId: z.string().optional(),
|
|
/** @deprecated Find group with matching name */
|
|
name: z.string().optional(),
|
|
/** Find group matching query */
|
|
query: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
export type GroupsListReq = z.infer<typeof GroupsListSchema>;
|
|
|
|
export const GroupsInfoSchema = z.object({
|
|
body: z.object({
|
|
/** Group Id */
|
|
id: z.string().uuid().optional(),
|
|
/** External source. */
|
|
externalId: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
export type GroupsInfoReq = z.infer<typeof GroupsInfoSchema>;
|
|
|
|
export const GroupsCreateSchema = z.object({
|
|
body: z.object({
|
|
/** Group name */
|
|
name: z.string(),
|
|
/** Group description */
|
|
description: z.string().max(GroupValidation.maxDescriptionLength).optional(),
|
|
/** Optionally link this group to an external source. */
|
|
externalId: z.string().optional(),
|
|
/** Whether mentions are disabled for this group */
|
|
disableMentions: z.boolean().optional().default(false),
|
|
}),
|
|
});
|
|
|
|
export type GroupsCreateReq = z.infer<typeof GroupsCreateSchema>;
|
|
|
|
export const GroupsUpdateSchema = z.object({
|
|
body: BaseIdSchema.extend({
|
|
/** Group name */
|
|
name: z.string().optional(),
|
|
/** Group description */
|
|
description: z.string().max(GroupValidation.maxDescriptionLength).optional(),
|
|
/** Optionally link this group to an external source. */
|
|
externalId: z.string().optional(),
|
|
/** Whether mentions are disabled for this group */
|
|
disableMentions: z.boolean().optional(),
|
|
}),
|
|
});
|
|
|
|
export type GroupsUpdateReq = z.infer<typeof GroupsUpdateSchema>;
|
|
|
|
export const GroupsDeleteSchema = z.object({
|
|
body: BaseIdSchema,
|
|
});
|
|
|
|
export type GroupsDeleteReq = z.infer<typeof GroupsDeleteSchema>;
|
|
|
|
export const GroupsMembershipsSchema = z.object({
|
|
body: BaseIdSchema.extend({
|
|
/** Group name search query */
|
|
query: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
export type GroupsMembershipsReq = z.infer<typeof GroupsMembershipsSchema>;
|
|
|
|
export const GroupsAddUserSchema = z.object({
|
|
body: BaseIdSchema.extend({
|
|
/** User Id */
|
|
userId: z.string().uuid(),
|
|
/** The permission of the user in the group */
|
|
permission: z
|
|
.nativeEnum(GroupPermission)
|
|
.optional()
|
|
.default(GroupPermission.Member),
|
|
}),
|
|
});
|
|
|
|
export type GroupsAddUserReq = z.infer<typeof GroupsAddUserSchema>;
|
|
|
|
export const GroupsRemoveUserSchema = z.object({
|
|
body: BaseIdSchema.extend({
|
|
/** User Id */
|
|
userId: z.string().uuid(),
|
|
}),
|
|
});
|
|
|
|
export type GroupsRemoveUserReq = z.infer<typeof GroupsRemoveUserSchema>;
|
|
|
|
export const GroupsUpdateUserSchema = z.object({
|
|
body: BaseIdSchema.extend({
|
|
/** User Id */
|
|
userId: z.string().uuid(),
|
|
/** The permission of the user in the group */
|
|
permission: z.nativeEnum(GroupPermission),
|
|
}),
|
|
});
|
|
|
|
export type GroupsUpdateUserReq = z.infer<typeof GroupsUpdateUserSchema>;
|