mirror of
https://github.com/discourse/discourse.git
synced 2025-09-12 21:10:47 +08:00
FIX: improves UI state when no extensions are allowed for upload
This commit is contained in:
parent
56834dbd98
commit
3d595a52ca
4 changed files with 36 additions and 8 deletions
|
@ -13,6 +13,8 @@ import { tinyAvatar,
|
|||
displayErrorForUpload,
|
||||
getUploadMarkdown,
|
||||
validateUploadedFiles,
|
||||
authorizesOneOrMoreExtensions,
|
||||
authorizesOneOrMoreImageExtensions,
|
||||
formatUsername,
|
||||
clipboardData
|
||||
} from 'discourse/lib/utilities';
|
||||
|
@ -36,6 +38,12 @@ export default Ember.Component.extend({
|
|||
return `[${I18n.t('uploading')}]() `;
|
||||
},
|
||||
|
||||
@computed()
|
||||
replyPlaceholder() {
|
||||
const key = authorizesOneOrMoreImageExtensions() ? "reply_placeholder" : "reply_placeholder_no_images";
|
||||
return `composer.${key}`;
|
||||
},
|
||||
|
||||
@observes('composer.uploadCancelled')
|
||||
_cancelUpload() {
|
||||
if (!this.get('composer.uploadCancelled')) { return; }
|
||||
|
@ -662,13 +670,15 @@ export default Ember.Component.extend({
|
|||
unshift: true
|
||||
});
|
||||
|
||||
toolbar.addButton({
|
||||
id: 'upload',
|
||||
group: 'insertions',
|
||||
icon: 'upload',
|
||||
title: 'upload',
|
||||
sendAction: 'showUploadModal'
|
||||
});
|
||||
if (authorizesOneOrMoreExtensions()) {
|
||||
toolbar.addButton({
|
||||
id: 'upload',
|
||||
group: 'insertions',
|
||||
icon: 'upload',
|
||||
title: 'upload',
|
||||
sendAction: 'showUploadModal'
|
||||
});
|
||||
}
|
||||
|
||||
toolbar.addButton({
|
||||
id: 'options',
|
||||
|
|
|
@ -193,6 +193,8 @@ export function validateUploadedFiles(files, opts) {
|
|||
}
|
||||
|
||||
export function validateUploadedFile(file, opts) {
|
||||
if (!authorizesOneOrMoreExtensions()) return false;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
const name = file && file.name;
|
||||
|
@ -277,6 +279,21 @@ export function authorizesAllExtensions() {
|
|||
return Discourse.SiteSettings.authorized_extensions.indexOf("*") >= 0;
|
||||
}
|
||||
|
||||
export function authorizesOneOrMoreExtensions() {
|
||||
if (authorizesAllExtensions()) return true;
|
||||
|
||||
return Discourse.SiteSettings.authorized_extensions
|
||||
.split("|")
|
||||
.filter(ext => ext)
|
||||
.length > 0;
|
||||
}
|
||||
|
||||
export function authorizesOneOrMoreImageExtensions() {
|
||||
if (authorizesAllExtensions()) return true;
|
||||
|
||||
return imagesExtensions().length > 0;
|
||||
}
|
||||
|
||||
export function isAnImage(path) {
|
||||
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)$/i).test(path);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{d-editor
|
||||
tabindex="4"
|
||||
value=composer.reply
|
||||
placeholder="composer.reply_placeholder"
|
||||
placeholder=replyPlaceholder
|
||||
previewUpdated="previewUpdated"
|
||||
markdownOptions=markdownOptions
|
||||
extraButtons="extraButtons"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue