FIX: displays correct upload icon when only images are allowed

This commit is contained in:
Joffrey JAFFEUX 2018-06-18 11:16:34 +02:00 committed by GitHub
parent c18b86d9b2
commit 4b604b1e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View File

@ -816,11 +816,11 @@ export default Ember.Component.extend({
unshift: true
});
if (this.get("allowUpload")) {
if (this.get("allowUpload") && this.get("uploadIcon")) {
toolbar.addButton({
id: "upload",
group: "insertions",
icon: "upload",
icon: this.get("uploadIcon"),
title: "upload",
sendAction: "showUploadModal"
});

View File

@ -11,6 +11,7 @@ import InputValidation from "discourse/models/input-validation";
import { getOwner } from "discourse-common/lib/get-owner";
import {
escapeExpression,
uploadIcon,
authorizesOneOrMoreExtensions
} from "discourse/lib/utilities";
import { emojiUnescape } from "discourse/lib/text";
@ -88,6 +89,7 @@ export default Ember.Controller.extend({
lastValidatedAt: null,
isUploading: false,
allowUpload: false,
uploadIcon: "upload",
topic: null,
linkLookup: null,
showPreview: true,
@ -286,6 +288,8 @@ export default Ember.Controller.extend({
return authorizesOneOrMoreExtensions();
},
@computed() uploadIcon: () => uploadIcon(),
actions: {
cancelUpload() {
this.set("model.uploadCancelled", true);

View File

@ -6,7 +6,8 @@ import {
import {
allowsAttachments,
authorizesAllExtensions,
authorizedExtensions
authorizedExtensions,
uploadIcon
} from "discourse/lib/utilities";
function uploadTranslate(key) {
@ -24,7 +25,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
remote: Ember.computed.equal("selection", "remote"),
selection: "local",
@computed() uploadIcon: () => (allowsAttachments() ? "upload" : "picture-o"),
@computed() uploadIcon: () => uploadIcon(),
@computed() title: () => uploadTranslate("title"),

View File

@ -420,6 +420,10 @@ export function allowsAttachments() {
);
}
export function uploadIcon() {
return allowsAttachments() ? "upload" : "picture-o";
}
export function uploadLocation(url) {
if (Discourse.CDN) {
url = Discourse.getURLWithCDN(url);

View File

@ -84,6 +84,7 @@
draftStatus=model.draftStatus
isUploading=isUploading
allowUpload=allowUpload
uploadIcon=uploadIcon
isCancellable=isCancellable
uploadProgress=uploadProgress
groupsMentioned="groupsMentioned"