mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -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,
|
displayErrorForUpload,
|
||||||
getUploadMarkdown,
|
getUploadMarkdown,
|
||||||
validateUploadedFiles,
|
validateUploadedFiles,
|
||||||
|
authorizesOneOrMoreExtensions,
|
||||||
|
authorizesOneOrMoreImageExtensions,
|
||||||
formatUsername,
|
formatUsername,
|
||||||
clipboardData
|
clipboardData
|
||||||
} from 'discourse/lib/utilities';
|
} from 'discourse/lib/utilities';
|
||||||
@ -36,6 +38,12 @@ export default Ember.Component.extend({
|
|||||||
return `[${I18n.t('uploading')}]() `;
|
return `[${I18n.t('uploading')}]() `;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed()
|
||||||
|
replyPlaceholder() {
|
||||||
|
const key = authorizesOneOrMoreImageExtensions() ? "reply_placeholder" : "reply_placeholder_no_images";
|
||||||
|
return `composer.${key}`;
|
||||||
|
},
|
||||||
|
|
||||||
@observes('composer.uploadCancelled')
|
@observes('composer.uploadCancelled')
|
||||||
_cancelUpload() {
|
_cancelUpload() {
|
||||||
if (!this.get('composer.uploadCancelled')) { return; }
|
if (!this.get('composer.uploadCancelled')) { return; }
|
||||||
@ -662,13 +670,15 @@ export default Ember.Component.extend({
|
|||||||
unshift: true
|
unshift: true
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbar.addButton({
|
if (authorizesOneOrMoreExtensions()) {
|
||||||
id: 'upload',
|
toolbar.addButton({
|
||||||
group: 'insertions',
|
id: 'upload',
|
||||||
icon: 'upload',
|
group: 'insertions',
|
||||||
title: 'upload',
|
icon: 'upload',
|
||||||
sendAction: 'showUploadModal'
|
title: 'upload',
|
||||||
});
|
sendAction: 'showUploadModal'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toolbar.addButton({
|
toolbar.addButton({
|
||||||
id: 'options',
|
id: 'options',
|
||||||
|
@ -193,6 +193,8 @@ export function validateUploadedFiles(files, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function validateUploadedFile(file, opts) {
|
export function validateUploadedFile(file, opts) {
|
||||||
|
if (!authorizesOneOrMoreExtensions()) return false;
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
const name = file && file.name;
|
const name = file && file.name;
|
||||||
@ -277,6 +279,21 @@ export function authorizesAllExtensions() {
|
|||||||
return Discourse.SiteSettings.authorized_extensions.indexOf("*") >= 0;
|
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) {
|
export function isAnImage(path) {
|
||||||
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)$/i).test(path);
|
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)$/i).test(path);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{d-editor
|
{{d-editor
|
||||||
tabindex="4"
|
tabindex="4"
|
||||||
value=composer.reply
|
value=composer.reply
|
||||||
placeholder="composer.reply_placeholder"
|
placeholder=replyPlaceholder
|
||||||
previewUpdated="previewUpdated"
|
previewUpdated="previewUpdated"
|
||||||
markdownOptions=markdownOptions
|
markdownOptions=markdownOptions
|
||||||
extraButtons="extraButtons"
|
extraButtons="extraButtons"
|
||||||
|
@ -1247,6 +1247,7 @@ en:
|
|||||||
topic_featured_link_placeholder: "Enter link shown with title."
|
topic_featured_link_placeholder: "Enter link shown with title."
|
||||||
remove_featured_link: "Remove link from topic."
|
remove_featured_link: "Remove link from topic."
|
||||||
reply_placeholder: "Type here. Use Markdown, BBCode, or HTML to format. Drag or paste images."
|
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."
|
view_new_post: "View your new post."
|
||||||
saving: "Saving"
|
saving: "Saving"
|
||||||
saved: "Saved!"
|
saved: "Saved!"
|
||||||
|
Loading…
Reference in New Issue
Block a user