Skip to content

Commit

Permalink
add image proxy config page and use message_source for editing when (m…
Browse files Browse the repository at this point in the history
…attermost#649)

available
  • Loading branch information
ccbrown authored Jan 23, 2018
1 parent 27dfa03 commit b7cd96a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
67 changes: 66 additions & 1 deletion components/admin_console/storage_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default class StorageSettings extends AdminSettings {
config.FileSettings.AmazonS3SSE = this.state.amazonS3SSE;
config.FileSettings.AmazonS3Trace = this.state.amazonS3Trace;

config.ServiceSettings.ImageProxyType = this.state.imageProxyType;
config.ServiceSettings.ImageProxyOptions = this.state.imageProxyOptions;
config.ServiceSettings.ImageProxyURL = this.state.imageProxyURL;
return config;
}

Expand All @@ -58,7 +61,11 @@ export default class StorageSettings extends AdminSettings {
amazonS3Endpoint: config.FileSettings.AmazonS3Endpoint,
amazonS3SSL: config.FileSettings.AmazonS3SSL,
amazonS3SSE: config.FileSettings.AmazonS3SSE,
amazonS3Trace: config.FileSettings.AmazonS3Trace
amazonS3Trace: config.FileSettings.AmazonS3Trace,

imageProxyType: config.ServiceSettings.ImageProxyType,
imageProxyOptions: config.ServiceSettings.ImageProxyOptions,
imageProxyURL: config.ServiceSettings.ImageProxyURL
};
}

Expand Down Expand Up @@ -355,6 +362,64 @@ export default class StorageSettings extends AdminSettings {
onChange={this.handleChange}
disabled={!this.state.enableFileAttachments}
/>
<DropdownSetting
id='imageProxyType'
values={[
{value: '', text: Utils.localizeMessage('admin.image.proxyTypeNone', 'None')},
{value: 'atmos/camo', text: 'atmos/camo'},
{value: 'willnorris/imageproxy', text: 'willnorris/imageproxy'}
]}
label={
<FormattedMessage
id='admin.image.proxyType'
defaultMessage='Image Proxy Type:'
/>
}
helpText={
<FormattedHTMLMessage
id='admin.image.proxyTypeDescription'
defaultMessage='Configure an image proxy to load all Markdown images through a proxy. The image proxy prevents users from making insecure image requests, provides caching for increased performance, and automates image adjustments such as resizing. See <a href="https://about.mattermost.com/default-image-proxy-documentation">documentation</a> to learn more.'
/>
}
value={this.state.imageProxyType}
onChange={this.handleChange}
/>
<TextSetting
id='imageProxyURL'
label={
<FormattedMessage
id='admin.image.proxyURL'
defaultMessage='Image Proxy URL:'
/>
}
helpText={
<FormattedMessage
id='admin.image.proxyURLDescription'
defaultMessage='URL of your image proxy server.'
/>
}
value={this.state.imageProxyURL}
onChange={this.handleChange}
disabled={!this.state.imageProxyType}
/>
<TextSetting
id='imageProxyOptions'
label={
<FormattedMessage
id='admin.image.proxyOptions'
defaultMessage='Image Proxy Options:'
/>
}
helpText={
<FormattedMessage
id='admin.image.proxyOptionsDescription'
defaultMessage='Additional options for basic image adjustments such as resizing, cropping, and rotation. Refer to your image proxy documentation to learn more about what options are supported.'
/>
}
value={this.state.imageProxyOptions}
onChange={this.handleChange}
disabled={!this.state.imageProxyType}
/>
</SettingsGroup>
);
}
Expand Down
4 changes: 2 additions & 2 deletions components/edit_post_modal/edit_post_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class EditPostModal extends React.PureComponent {
return;
}

if (updatedPost.message === editingPost.post.message) {
if (updatedPost.message === (editingPost.post.message_source || editingPost.post.message)) {
// no changes so just close the modal
this.handleHide();
return;
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class EditPostModal extends React.PureComponent {

handleEnter = () => {
this.setState({
editText: this.props.editingPost.post.message
editText: this.props.editingPost.post.message_source || this.props.editingPost.post.message
});
}

Expand Down
7 changes: 7 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@
"admin.image.maxFileSizeDescription": "Maximum file size for message attachments in megabytes. Caution: Verify server memory can support your setting choice. Large file sizes increase the risk of server crashes and failed uploads due to network interruptions.",
"admin.image.maxFileSizeExample": "50",
"admin.image.maxFileSizeTitle": "Maximum File Size:",
"admin.image.proxyOptions": "Image Proxy Options:",
"admin.image.proxyOptionsDescription": "Additional options for basic image adjustments such as resizing, cropping, and rotation. Refer to your image proxy documentation to learn more about what options are supported.",
"admin.image.proxyType": "Image Proxy Type:",
"admin.image.proxyTypeNone": "None",
"admin.image.proxyTypeDescription": "Configure an image proxy to load all Markdown images through a proxy. The image proxy prevents users from making insecure image requests, provides caching for increased performance, and automates image adjustments such as resizing. See <a href=\"https://about.mattermost.com/default-image-proxy-documentation\">documentation</a> to learn more.",
"admin.image.proxyURL": "Image Proxy URL:",
"admin.image.proxyURLDescription": "URL of your image proxy server.",
"admin.image.publicLinkDescription": "32-character salt added to signing of public image links. Randomly generated on install. Click \"Regenerate\" to create new salt.",
"admin.image.publicLinkExample": "E.g.: \"gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6\"",
"admin.image.publicLinkTitle": "Public Link Salt:",
Expand Down

0 comments on commit b7cd96a

Please sign in to comment.