mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
FIX: improves UI state when no extensions are allowed for upload
This commit is contained in:
parent
56834dbd98
commit
3d595a52ca
@ -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"
|
||||
|
@ -1247,6 +1247,7 @@ en:
|
||||
topic_featured_link_placeholder: "Enter link shown with title."
|
||||
remove_featured_link: "Remove link from topic."
|
||||
reply_placeholder: "Type here. Use Markdown, BBCode, or HTML to format. Drag or paste images."
|
||||
reply_placeholder_no_images: "Type here. Use Markdown, BBCode, or HTML to format."
|
||||
view_new_post: "View your new post."
|
||||
saving: "Saving"
|
||||
saved: "Saved!"
|
||||
|
Loading…
Reference in New Issue
Block a user