UNPKG

metadata-based-explorer1

Version:
33 lines (25 loc) 848 B
// @flow import { PLACEHOLDER_USER, VERSION_DELETE_ACTION, VERSION_RESTORE_ACTION, VERSION_UPLOAD_ACTION, } from '../../../constants'; type VersionAction = typeof VERSION_DELETE_ACTION | typeof VERSION_RESTORE_ACTION | typeof VERSION_UPLOAD_ACTION; const getVersionAction = ({ restored_at, trashed_at, version_restored }: $Shape<BoxItemVersion>): VersionAction => { let action = VERSION_UPLOAD_ACTION; if (trashed_at) { action = VERSION_DELETE_ACTION; } if (restored_at || version_restored) { action = VERSION_RESTORE_ACTION; } return action; }; const getVersionUser = ({ modified_by, restored_by, trashed_by }: $Shape<BoxItemVersion>): User => { return restored_by || trashed_by || modified_by || PLACEHOLDER_USER; }; export default { getVersionAction, getVersionUser, };