2015-10-08 12:27:09 -04:00
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-09-21 17:34:13 -07:00
// See License.txt for license information.
2015-11-19 21:12:56 -05:00
import * as Client from '../../utils/client.jsx' ;
import * as AsyncClient from '../../utils/async_client.jsx' ;
import crypto from 'crypto' ;
2015-09-21 17:34:13 -07:00
2016-01-27 15:49:26 -03:00
import { injectIntl , intlShape , defineMessages , FormattedMessage } from 'mm-intl' ;
const holders = defineMessages ( {
storeDisabled : {
id : 'admin.image.storeDisabled' ,
defaultMessage : 'Disable File Storage'
} ,
storeLocal : {
id : 'admin.image.storeLocal' ,
defaultMessage : 'Local File System'
} ,
storeAmazonS3 : {
id : 'admin.image.storeAmazonS3' ,
defaultMessage : 'Amazon S3'
} ,
localExample : {
id : 'admin.image.localExample' ,
defaultMessage : 'Ex "./data/"'
} ,
amazonS3IdExample : {
id : 'admin.image.amazonS3IdExample' ,
defaultMessage : 'Ex "AKIADTOVBGERKLCBV"'
} ,
amazonS3SecretExample : {
id : 'admin.image.amazonS3SecretExample' ,
defaultMessage : 'Ex "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"'
} ,
amazonS3BucketExample : {
id : 'admin.image.amazonS3BucketExample' ,
defaultMessage : 'Ex "mattermost-media"'
} ,
amazonS3RegionExample : {
id : 'admin.image.amazonS3RegionExample' ,
defaultMessage : 'Ex "us-east-1"'
} ,
thumbWidthExample : {
id : 'admin.image.thumbWidthExample' ,
defaultMessage : 'Ex "120"'
} ,
thumbHeightExample : {
id : 'admin.image.thumbHeightExample' ,
defaultMessage : 'Ex "100"'
} ,
previewWidthExample : {
id : 'admin.image.previewWidthExample' ,
defaultMessage : 'Ex "1024"'
} ,
previewHeightExample : {
id : 'admin.image.previewHeightExample' ,
defaultMessage : 'Ex "0"'
} ,
profileWidthExample : {
id : 'admin.image.profileWidthExample' ,
defaultMessage : 'Ex "1024"'
} ,
profileHeightExample : {
id : 'admin.image.profileHeightExample' ,
defaultMessage : 'Ex "0"'
} ,
publicLinkExample : {
id : 'admin.image.publicLinkExample' ,
defaultMessage : 'Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"'
} ,
saving : {
id : 'admin.image.saving' ,
defaultMessage : 'Saving Config...'
}
} ) ;
class FileSettings extends React . Component {
2015-09-21 17:34:13 -07:00
constructor ( props ) {
super ( props ) ;
this . handleChange = this . handleChange . bind ( this ) ;
this . handleSubmit = this . handleSubmit . bind ( this ) ;
2015-09-22 12:12:50 -07:00
this . handleGenerate = this . handleGenerate . bind ( this ) ;
2015-09-21 17:34:13 -07:00
this . state = {
saveNeeded : false ,
serverError : null ,
2015-09-23 13:47:10 -07:00
DriverName : this . props . config . FileSettings . DriverName
2015-09-21 17:34:13 -07:00
} ;
}
handleChange ( action ) {
var s = { saveNeeded : true , serverError : this . state . serverError } ;
if ( action === 'DriverName' ) {
2015-10-15 12:07:06 -04:00
s . DriverName = ReactDOM . findDOMNode ( this . refs . DriverName ) . value ;
2015-09-21 17:34:13 -07:00
}
this . setState ( s ) ;
}
2015-09-22 12:12:50 -07:00
handleGenerate ( e ) {
e . preventDefault ( ) ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . PublicLinkSalt ) . value = crypto . randomBytes ( 256 ) . toString ( 'base64' ) . substring ( 0 , 32 ) ;
2015-09-22 12:12:50 -07:00
var s = { saveNeeded : true , serverError : this . state . serverError } ;
this . setState ( s ) ;
}
2015-09-21 17:34:13 -07:00
handleSubmit ( e ) {
e . preventDefault ( ) ;
$ ( '#save-button' ) . button ( 'loading' ) ;
var config = this . props . config ;
2015-10-15 12:07:06 -04:00
config . FileSettings . DriverName = ReactDOM . findDOMNode ( this . refs . DriverName ) . value ;
config . FileSettings . Directory = ReactDOM . findDOMNode ( this . refs . Directory ) . value ;
config . FileSettings . AmazonS3AccessKeyId = ReactDOM . findDOMNode ( this . refs . AmazonS3AccessKeyId ) . value ;
config . FileSettings . AmazonS3SecretAccessKey = ReactDOM . findDOMNode ( this . refs . AmazonS3SecretAccessKey ) . value ;
config . FileSettings . AmazonS3Bucket = ReactDOM . findDOMNode ( this . refs . AmazonS3Bucket ) . value ;
config . FileSettings . AmazonS3Region = ReactDOM . findDOMNode ( this . refs . AmazonS3Region ) . value ;
config . FileSettings . EnablePublicLink = ReactDOM . findDOMNode ( this . refs . EnablePublicLink ) . checked ;
2015-09-23 13:47:10 -07:00
2015-10-15 12:07:06 -04:00
config . FileSettings . PublicLinkSalt = ReactDOM . findDOMNode ( this . refs . PublicLinkSalt ) . value . trim ( ) ;
2015-09-23 13:47:10 -07:00
if ( config . FileSettings . PublicLinkSalt === '' ) {
config . FileSettings . PublicLinkSalt = crypto . randomBytes ( 256 ) . toString ( 'base64' ) . substring ( 0 , 32 ) ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . PublicLinkSalt ) . value = config . FileSettings . PublicLinkSalt ;
2015-09-22 12:12:50 -07:00
}
2015-09-21 17:34:13 -07:00
var thumbnailWidth = 120 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . ThumbnailWidth ) . value , 10 ) ) ) {
thumbnailWidth = parseInt ( ReactDOM . findDOMNode ( this . refs . ThumbnailWidth ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . ThumbnailWidth = thumbnailWidth ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . ThumbnailWidth ) . value = thumbnailWidth ;
2015-09-21 17:34:13 -07:00
var thumbnailHeight = 100 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . ThumbnailHeight ) . value , 10 ) ) ) {
thumbnailHeight = parseInt ( ReactDOM . findDOMNode ( this . refs . ThumbnailHeight ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . ThumbnailHeight = thumbnailHeight ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . ThumbnailHeight ) . value = thumbnailHeight ;
2015-09-21 17:34:13 -07:00
var previewWidth = 1024 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . PreviewWidth ) . value , 10 ) ) ) {
previewWidth = parseInt ( ReactDOM . findDOMNode ( this . refs . PreviewWidth ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . PreviewWidth = previewWidth ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . PreviewWidth ) . value = previewWidth ;
2015-09-21 17:34:13 -07:00
var previewHeight = 0 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . PreviewHeight ) . value , 10 ) ) ) {
previewHeight = parseInt ( ReactDOM . findDOMNode ( this . refs . PreviewHeight ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . PreviewHeight = previewHeight ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . PreviewHeight ) . value = previewHeight ;
2015-09-21 17:34:13 -07:00
var profileWidth = 128 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . ProfileWidth ) . value , 10 ) ) ) {
profileWidth = parseInt ( ReactDOM . findDOMNode ( this . refs . ProfileWidth ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . ProfileWidth = profileWidth ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . ProfileWidth ) . value = profileWidth ;
2015-09-21 17:34:13 -07:00
var profileHeight = 128 ;
2015-10-15 12:07:06 -04:00
if ( ! isNaN ( parseInt ( ReactDOM . findDOMNode ( this . refs . ProfileHeight ) . value , 10 ) ) ) {
profileHeight = parseInt ( ReactDOM . findDOMNode ( this . refs . ProfileHeight ) . value , 10 ) ;
2015-09-21 17:34:13 -07:00
}
2015-09-23 13:47:10 -07:00
config . FileSettings . ProfileHeight = profileHeight ;
2015-10-15 12:07:06 -04:00
ReactDOM . findDOMNode ( this . refs . ProfileHeight ) . value = profileHeight ;
2015-09-21 17:34:13 -07:00
Client . saveConfig (
config ,
( ) => {
AsyncClient . getConfig ( ) ;
this . setState ( {
serverError : null ,
saveNeeded : false
} ) ;
$ ( '#save-button' ) . button ( 'reset' ) ;
} ,
( err ) => {
this . setState ( {
serverError : err . message ,
saveNeeded : true
} ) ;
$ ( '#save-button' ) . button ( 'reset' ) ;
}
) ;
}
render ( ) {
2016-01-27 15:49:26 -03:00
const { formatMessage } = this . props . intl ;
2015-09-21 17:34:13 -07:00
var serverError = '' ;
if ( this . state . serverError ) {
serverError = < div className = 'form-group has-error' > < label className = 'control-label' > { this . state . serverError } < / label > < / div > ;
}
var saveClass = 'btn' ;
if ( this . state . saveNeeded ) {
saveClass = 'btn btn-primary' ;
}
var enableFile = false ;
var enableS3 = false ;
if ( this . state . DriverName === 'local' ) {
enableFile = true ;
}
if ( this . state . DriverName === 'amazons3' ) {
enableS3 = true ;
}
return (
< div className = 'wrapper--fixed' >
2016-01-27 15:49:26 -03:00
< h3 >
< FormattedMessage
id = 'admin.image.fileSettings'
defaultMessage = 'File Settings'
/ >
< / h3 >
2015-09-21 17:34:13 -07:00
< form
className = 'form-horizontal'
role = 'form'
>
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'DriverName'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.storeTitle'
defaultMessage = 'Store Files In:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< select
className = 'form-control'
id = 'DriverName'
ref = 'DriverName'
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . DriverName }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange . bind ( this , 'DriverName' ) }
>
2016-01-27 15:49:26 -03:00
< option value = '' > { formatMessage ( holders . storeDisabled ) } < / option >
< option value = 'local' > { formatMessage ( holders . storeLocal ) } < / option >
< option value = 'amazons3' > { formatMessage ( holders . storeAmazonS3 ) } < / option >
2015-09-21 17:34:13 -07:00
< / select >
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'Directory'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.localTitle'
defaultMessage = 'Local Directory Location:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'Directory'
ref = 'Directory'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . localExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . Directory }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
disabled = { ! enableFile }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.localDescription'
defaultMessage = 'Directory to which image files are written. If blank, will be set to ./data/.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'AmazonS3AccessKeyId'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.amazonS3IdTitle'
defaultMessage = 'Amazon S3 Access Key Id:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'AmazonS3AccessKeyId'
ref = 'AmazonS3AccessKeyId'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . amazonS3IdExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . AmazonS3AccessKeyId }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
disabled = { ! enableS3 }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.amazonS3IdDescription'
defaultMessage = 'Obtain this credential from your Amazon EC2 administrator.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'AmazonS3SecretAccessKey'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.amazonS3SecretTitle'
defaultMessage = 'Amazon S3 Secret Access Key:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'AmazonS3SecretAccessKey'
ref = 'AmazonS3SecretAccessKey'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . amazonS3SecretExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . AmazonS3SecretAccessKey }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
disabled = { ! enableS3 }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.amazonS3SecretDescription'
defaultMessage = 'Obtain this credential from your Amazon EC2 administrator.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'AmazonS3Bucket'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.amazonS3BucketTitle'
defaultMessage = 'Amazon S3 Bucket:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'AmazonS3Bucket'
ref = 'AmazonS3Bucket'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . amazonS3BucketExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . AmazonS3Bucket }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
disabled = { ! enableS3 }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.amazonS3BucketDescription'
defaultMessage = 'Name you selected for your S3 bucket in AWS.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'AmazonS3Region'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.amazonS3RegionTitle'
defaultMessage = 'Amazon S3 Region:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'AmazonS3Region'
ref = 'AmazonS3Region'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . amazonS3RegionExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . AmazonS3Region }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
disabled = { ! enableS3 }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.amazonS3RegionDescription'
defaultMessage = 'AWS region you selected for creating your S3 bucket.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'ThumbnailWidth'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.thumbWidthTitle'
defaultMessage = 'Thumbnail Width:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'ThumbnailWidth'
ref = 'ThumbnailWidth'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . thumbWidthExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . ThumbnailWidth }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.thumbWidthDescription'
defaultMessage = 'Width of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'ThumbnailHeight'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.thumbHeightTitle'
defaultMessage = 'Thumbnail Height:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'ThumbnailHeight'
ref = 'ThumbnailHeight'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . thumbHeightExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . ThumbnailHeight }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.thumbHeightDescription'
defaultMessage = 'Height of thumbnails generated from uploaded images. Updating this value changes how thumbnail images render in future, but does not change images created in the past.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'PreviewWidth'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.previewWidthTitle'
defaultMessage = 'Preview Width:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'PreviewWidth'
ref = 'PreviewWidth'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . previewWidthExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . PreviewWidth }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.previewWidthDescription'
defaultMessage = 'Maximum width of preview image. Updating this value changes how preview images render in future, but does not change images created in the past.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'PreviewHeight'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.previewHeightTitle'
defaultMessage = 'Preview Height:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'PreviewHeight'
ref = 'PreviewHeight'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . previewHeightExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . PreviewHeight }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.previewHeightDescription'
defaultMessage = 'Maximum height of preview image ("0": Sets to auto-size). Updating this value changes how preview images render in future, but does not change images created in the past.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'ProfileWidth'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.profileWidthTitle'
defaultMessage = 'Profile Width:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'ProfileWidth'
ref = 'ProfileWidth'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . profileWidthExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . ProfileWidth }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.profileWidthDescription'
defaultMessage = 'Width of profile picture.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'ProfileHeight'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.profileHeightTitle'
defaultMessage = 'Profile Height:'
/ >
2015-09-21 17:34:13 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'ProfileHeight'
ref = 'ProfileHeight'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . profileHeightExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . ProfileHeight }
2015-09-21 17:34:13 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.profileHeightDescription'
defaultMessage = 'Height of profile picture.'
/ >
< / p >
2015-09-21 17:34:13 -07:00
< / div >
< / div >
2015-09-22 01:15:41 -07:00
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'EnablePublicLink'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.shareTitle'
defaultMessage = 'Share Public File Link: '
/ >
2015-09-22 01:15:41 -07:00
< / label >
< div className = 'col-sm-8' >
< label className = 'radio-inline' >
< input
type = 'radio'
name = 'EnablePublicLink'
value = 'true'
ref = 'EnablePublicLink'
2015-09-23 13:47:10 -07:00
defaultChecked = { this . props . config . FileSettings . EnablePublicLink }
2015-09-22 01:15:41 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.true'
defaultMessage = 'true'
/ >
2015-09-22 01:15:41 -07:00
< / label >
< label className = 'radio-inline' >
< input
type = 'radio'
name = 'EnablePublicLink'
value = 'false'
2015-09-23 13:47:10 -07:00
defaultChecked = { ! this . props . config . FileSettings . EnablePublicLink }
2015-09-22 01:15:41 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.false'
defaultMessage = 'false'
/ >
2015-09-22 01:15:41 -07:00
< / label >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.shareDescription'
defaultMessage = 'Allow users to share public links to files and images.'
/ >
< / p >
2015-09-22 01:15:41 -07:00
< / div >
< / div >
2015-09-22 12:12:50 -07:00
< div className = 'form-group' >
< label
className = 'control-label col-sm-4'
htmlFor = 'PublicLinkSalt'
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.publicLinkTitle'
defaultMessage = 'Public Link Salt:'
/ >
2015-09-22 12:12:50 -07:00
< / label >
< div className = 'col-sm-8' >
< input
type = 'text'
className = 'form-control'
id = 'PublicLinkSalt'
ref = 'PublicLinkSalt'
2016-01-27 15:49:26 -03:00
placeholder = { formatMessage ( holders . publicLinkExample ) }
2015-09-23 13:47:10 -07:00
defaultValue = { this . props . config . FileSettings . PublicLinkSalt }
2015-09-22 12:12:50 -07:00
onChange = { this . handleChange }
/ >
2016-01-27 15:49:26 -03:00
< p className = 'help-text' >
< FormattedMessage
id = 'admin.image.publicLinkDescription'
defaultMessage = '32-character salt added to signing of public image links. Randomly generated on install. Click "Re-Generate" to create new salt.'
/ >
< / p >
2015-09-22 12:12:50 -07:00
< div className = 'help-text' >
< button
2015-10-06 19:14:35 +05:00
className = 'btn btn-default'
2015-09-22 12:12:50 -07:00
onClick = { this . handleGenerate }
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.regenerate'
defaultMessage = 'Re-Generate'
/ >
2015-09-22 12:12:50 -07:00
< / button >
< / div >
< / div >
< / div >
2015-09-21 17:34:13 -07:00
< div className = 'form-group' >
< div className = 'col-sm-12' >
{ serverError }
< button
disabled = { ! this . state . saveNeeded }
type = 'submit'
className = { saveClass }
onClick = { this . handleSubmit }
id = 'save-button'
2016-01-27 15:49:26 -03:00
data - loading - text = { '<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> ' + formatMessage ( holders . saving ) }
2015-09-21 17:34:13 -07:00
>
2016-01-27 15:49:26 -03:00
< FormattedMessage
id = 'admin.image.save'
defaultMessage = 'Save'
/ >
2015-09-21 17:34:13 -07:00
< / button >
< / div >
< / div >
< / form >
< / div >
) ;
}
}
2015-09-23 13:47:10 -07:00
FileSettings . propTypes = {
2016-01-27 15:49:26 -03:00
intl : intlShape . isRequired ,
2015-09-21 17:34:13 -07:00
config : React . PropTypes . object
} ;
2016-01-27 15:49:26 -03:00
export default injectIntl ( FileSettings ) ;