generate author thumbnail and pass to gui

This commit is contained in:
Ben Wheeler 2018-11-09 22:09:28 -05:00
parent 464d5f7c2d
commit c965fd15f9
2 changed files with 22 additions and 0 deletions

17
src/lib/user-thumbnail.js Normal file
View file

@ -0,0 +1,17 @@
/**
* @user-thumbnail
* Utility functions to return thumnail-related strings
*/
/**
* Generate a thumbnail url for a particular userid, with width and height.
* @param {string} userId userId for the user whose thumbnail we want
* @param {number} width desired thumbnail width; defaults to 32
* @param {number} height desired thumbnail height; defaults to width.
* @returns {string} thumbnail url string
*/
const thumbnailUrl = (userId, width, height) => (
`/get_image/user/${userId}_${width ? width : 32}x${height ? height : (width ? width : 32)}.png`
);
module.exports = thumbnailUrl;

View file

@ -13,6 +13,7 @@ const storage = require('../../lib/storage.js').default;
const log = require('../../lib/log'); const log = require('../../lib/log');
const EXTENSION_INFO = require('../../lib/extensions.js').default; const EXTENSION_INFO = require('../../lib/extensions.js').default;
const jar = require('../../lib/jar.js'); const jar = require('../../lib/jar.js');
const thumbnailUrl = require('../../lib/user-thumbnail');
const PreviewPresentation = require('./presentation.jsx'); const PreviewPresentation = require('./presentation.jsx');
const projectShape = require('./projectshape.jsx').projectShape; const projectShape = require('./projectshape.jsx').projectShape;
@ -453,11 +454,13 @@ class Preview extends React.Component {
hideIntro hideIntro
assetHost={this.props.assetHost} assetHost={this.props.assetHost}
authorId={this.props.authorId} authorId={this.props.authorId}
authorThumbnailUrl={this.props.authorThumbnailUrl}
authorUsername={this.props.authorUsername} authorUsername={this.props.authorUsername}
backpackOptions={this.props.backpackOptions} backpackOptions={this.props.backpackOptions}
basePath="/" basePath="/"
canCreateCopy={this.props.canCreateCopy} canCreateCopy={this.props.canCreateCopy}
canCreateNew={this.props.canCreateNew} canCreateNew={this.props.canCreateNew}
canEditTitle={this.props.isEditable}
canRemix={this.props.canRemix} canRemix={this.props.canRemix}
canSave={this.props.canSave} canSave={this.props.canSave}
canShare={this.props.canShare} canShare={this.props.canShare}
@ -488,6 +491,7 @@ class Preview extends React.Component {
Preview.propTypes = { Preview.propTypes = {
assetHost: PropTypes.string.isRequired, assetHost: PropTypes.string.isRequired,
authorId: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), authorId: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
authorThumbnailUrl: PropTypes.string,
authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
backpackOptions: PropTypes.shape({ backpackOptions: PropTypes.shape({
host: PropTypes.string, host: PropTypes.string,
@ -591,6 +595,7 @@ const mapStateToProps = state => {
return { return {
authorId: authorId, authorId: authorId,
authorThumbnailUrl: thumbnailUrl(authorId),
authorUsername: authorUsername, authorUsername: authorUsername,
canAddToStudio: userOwnsProject, canAddToStudio: userOwnsProject,
canCreateCopy: userOwnsProject && projectInfoPresent, canCreateCopy: userOwnsProject && projectInfoPresent,