FIX: hide custom avatar when image upload is disabled

This commit is contained in:
Régis Hanol 2015-04-07 11:54:35 +02:00
parent be27fca904
commit bdbcd21687
3 changed files with 35 additions and 24 deletions

View File

@ -14,6 +14,10 @@ export default DiscourseController.extend(ModalFunctionality, {
}
}.property('selected', 'system_avatar_upload_id', 'gravatar_avatar_upload_id', 'custom_avatar_upload_id'),
allowImageUpload: function() {
return Discourse.Utilities.allowsImages()
}.property(),
actions: {
useUploadedAvatar() { this.set("selected", "uploaded"); },
useGravatar() { this.set("selected", "gravatar"); },

View File

@ -256,7 +256,12 @@ Discourse.Utilities = {
@param {String} path The path
**/
isAnImage: function(path) {
return (/\.(png|jpg|jpeg|gif|bmp|tif|tiff|svg|webp)$/i).test(path);
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp)$/i).test(path);
},
allowsImages: function() {
return Discourse.Utilities.authorizesAllExtensions() ||
(/(png|jpe?g|gif|bmp|tiff?|svg|webp)/i).test(Discourse.Utilities.authorizedExtensions());
},
/**
@ -266,7 +271,7 @@ Discourse.Utilities = {
**/
allowsAttachments: function() {
return Discourse.Utilities.authorizesAllExtensions() ||
!(/((png|jpg|jpeg|gif|bmp|tif|tiff|svg|webp)(,\s)?)+$/i).test(Discourse.Utilities.authorizedExtensions());
!(/((png|jpe?g|gif|bmp|tiff?|svg|webp)(,\s)?)+$/i).test(Discourse.Utilities.authorizedExtensions());
},
displayErrorForUpload: function(data) {

View File

@ -9,6 +9,7 @@
<label class="radio" for="gravatar">{{bound-avatar controller "large" gravatar_avatar_upload_id}} {{{i18n 'user.change_avatar.gravatar'}}} {{email}}</label>
{{d-button action="refreshGravatar" title="user.change_avatar.refresh_gravatar_title" disabled=gravatarRefreshDisabled class="no-text" icon="refresh"}}
</div>
{{#if allowImageUpload}}
<div>
<input type="radio" id="uploaded_avatar" name="avatar" value="uploaded" {{action "useUploadedAvatar"}}>
<label class="radio" for="uploaded_avatar">
@ -28,6 +29,7 @@
uploading=uploading
done="useUploadedAvatar"}}
</div>
{{/if}}
</div>
</div>