add prop to enable / disable download option (Upload presentation dialog)

This commit is contained in:
KDSBrowne 2019-12-24 14:48:44 +00:00
parent aa26c1d512
commit 75a3f6ed7d
3 changed files with 28 additions and 12 deletions

View File

@ -521,7 +521,7 @@ class PresentationUploader extends Component {
renderPresentationItem(item) {
const { disableActions, oldCurrentId } = this.state;
const { intl } = this.props;
const { intl, allowDownloadable } = this.props;
const isActualCurrent = item.id === oldCurrentId;
const isUploading = !item.upload.done && item.upload.progress > 0;
@ -537,6 +537,10 @@ class PresentationUploader extends Component {
[styles.tableItemAnimated]: isProcessing,
};
const itemActions = {
[styles.notDownloadable]: !allowDownloadable,
};
const hideRemove = this.isDefault(item);
const formattedDownloadableLabel = item.isDownloadable
? intl.formatMessage(intlMessages.isDownloadable)
@ -573,16 +577,19 @@ class PresentationUploader extends Component {
{this.renderPresentationItemStatus(item)}
</td>
{hasError ? null : (
<td className={styles.tableItemActions}>
<Button
className={isDownloadableStyle}
label={formattedDownloadableLabel}
aria-label={formattedDownloadableAriaLabel}
hideLabel
size="sm"
icon={item.isDownloadable ? 'download' : 'download-off'}
onClick={() => this.toggleDownloadable(item)}
/>
<td className={cx(styles.tableItemActions, itemActions)}>
{allowDownloadable ? (
<Button
className={isDownloadableStyle}
label={formattedDownloadableLabel}
aria-label={formattedDownloadableAriaLabel}
hideLabel
size="sm"
icon={item.isDownloadable ? 'download' : 'download-off'}
onClick={() => this.toggleDownloadable(item)}
/>
) : null
}
<Checkbox
ariaLabel={`${intl.formatMessage(intlMessages.setAsCurrentPresentation)} ${item.filename}`}
checked={item.isCurrent}

View File

@ -11,7 +11,11 @@ const PresentationUploaderContainer = props => (
export default withTracker(() => {
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
const currentPresentations = Service.getPresentations();
const { dispatchDisableDownloadable, dispatchEnableDownloadable, dispatchTogglePresentationDownloadable } = Service;
const {
dispatchDisableDownloadable,
dispatchEnableDownloadable,
dispatchTogglePresentationDownloadable,
} = Service;
return {
presentations: currentPresentations,
@ -19,6 +23,7 @@ export default withTracker(() => {
fileSizeMin: PRESENTATION_CONFIG.uploadSizeMin,
fileSizeMax: PRESENTATION_CONFIG.uploadSizeMax,
fileValidMimeTypes: PRESENTATION_CONFIG.uploadValidMimeTypes,
allowDownloadable: PRESENTATION_CONFIG.allowDownloadable,
handleSave: presentations => Service.persistPresentationChanges(
currentPresentations,
presentations,

View File

@ -79,6 +79,10 @@
}
}
.notDownloadable {
min-width: 48px;
}
.tableItemIcon > i {
font-size: 1.35rem;
}