* WIP: Archive * WIP * Finishing up archive endpoints * WIP * Update docs * Flow * Stash * Add toast message confirmations * Redirect handling, fixed publishhing info for archived docs * Redirect to collection instead of home, remove unused pub info * Account for deleted parent * Trash -> Archive Allow reading of archived docs * Dont overload deletedAt * Fixes * 💚 * ParentDocumentId wipe for unarchived sub docs * Fix: CMD+S exits editing Fix: Duplicate user name on published but unedited docs * Improve jank on paginated lists * Prevent editing when archived * 💚 Separate lint / flow steps
37 lines
717 B
JavaScript
37 lines
717 B
JavaScript
// @flow
|
|
import { User } from '../models';
|
|
|
|
type Options = {
|
|
includeDetails?: boolean,
|
|
};
|
|
|
|
type UserPresentation = {
|
|
id: string,
|
|
name: string,
|
|
avatarUrl: ?string,
|
|
email?: string,
|
|
isAdmin: boolean,
|
|
isSuspended: boolean,
|
|
};
|
|
|
|
export default (
|
|
ctx: Object,
|
|
user: User,
|
|
options: Options = {}
|
|
): ?UserPresentation => {
|
|
const userData = {};
|
|
userData.id = user.id;
|
|
userData.createdAt = user.createdAt;
|
|
userData.name = user.name;
|
|
userData.isAdmin = user.isAdmin;
|
|
userData.isSuspended = user.isSuspended;
|
|
userData.avatarUrl =
|
|
user.avatarUrl || (user.slackData ? user.slackData.image_192 : null);
|
|
|
|
if (options.includeDetails) {
|
|
userData.email = user.email;
|
|
}
|
|
|
|
return userData;
|
|
};
|