-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove download links from user-uploaded attachments without thumbnai…
…ls (#2262) * Add upload attachment renderer * Check thumbnail * Update PR number * Fix propTypes * Fix render error for text attachment * Update non-photo upload PNGs
- Loading branch information
Showing
8 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.33 KB
(120%)
...ome-docker/upload-js-upload-a-picture-with-custom-thumbnail-disabled-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-329 Bytes
(98%)
__tests__/__image_snapshots__/chrome-docker/upload-js-upload-a-zip-file-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { css } from 'glamor'; | ||
import { format } from 'bytes'; | ||
import classNames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import connectToWebChat from '../connectToWebChat'; | ||
import { localize } from '../Localization/Localize'; | ||
|
||
const ROOT_CSS = css({ | ||
display: 'flex', | ||
flexDirection: 'column' | ||
}); | ||
|
||
const UploadAttachment = ({ | ||
activity: { attachments = [], channelData: { attachmentSizes = [] } = {} } = {}, | ||
attachment, | ||
language, | ||
styleSet | ||
}) => { | ||
const attachmentIndex = attachments.indexOf(attachment); | ||
const size = attachmentSizes[attachmentIndex]; | ||
const formattedSize = typeof size === 'number' && format(size); | ||
const uploadFileWithFileSizeLabel = localize('UploadFileWithFileSize', language, attachment.name, formattedSize); | ||
return ( | ||
<React.Fragment> | ||
{/* Because of differences in browser implementations, <span aria-label> is used to make the screen reader perform the same on different browsers in Edge v44 */} | ||
<span aria-label={uploadFileWithFileSizeLabel} /> | ||
<div aria-hidden={true} className={classNames(ROOT_CSS + '', styleSet.uploadAttachment + '')}> | ||
<div className="name">{attachment.name}</div> | ||
<div className="size">{formattedSize}</div> | ||
</div> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
UploadAttachment.propTypes = { | ||
activity: PropTypes.shape({ | ||
attachment: PropTypes.array, | ||
channelData: PropTypes.shape({ | ||
attachmentSizes: PropTypes.arrayOf(PropTypes.number) | ||
}) | ||
}).isRequired, | ||
attachment: PropTypes.shape({ | ||
name: PropTypes.string.isRequired | ||
}).isRequired, | ||
language: PropTypes.string.isRequired, | ||
styleSet: PropTypes.shape({ | ||
downloadAttachment: PropTypes.any.isRequired | ||
}).isRequired | ||
}; | ||
|
||
export default connectToWebChat(({ language, styleSet }) => ({ language, styleSet }))(UploadAttachment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/component/src/Styles/StyleSet/UploadAttachment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default function createUploadAttachmentStyle({ accent, bubbleTextColor, paddingRegular, primaryFont }) { | ||
return { | ||
color: bubbleTextColor, | ||
fontFamily: primaryFont, | ||
padding: paddingRegular, | ||
textDecoration: 'none', | ||
|
||
'& > .name': { | ||
color: accent | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters