Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where it was impossible to upload any icons in page settings. #3865

Merged
merged 10 commits into from
Jun 28, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,56 @@ export default class Browse extends Component {
sf.get("GetFolderDescendants", { parentId }, this.addChildFolders.bind(this, parentId), this.handleError.bind(this));
}

getExtensions(fileFormats) {
let result = "";

const extensions = {
"text/html": "htm,html",
"text/css": "css",
"text/xml": "xml",
"image/gif": "gif",
"image/jpeg": "jpeg,jpg",
"application/x-javascript": "js",
"text/plain": "txt",
"image/png": "png",
"image/tiff": "tif,tiff",
"image/x-icon": "ico",
"image/x-ms-bmp": "bmp",
"image/svg+xml": "svg",
"image/webp": "webp",
"application/msword": "doc",
"application/pdf": "pdf",
"application/rtf": "rtf",
"application/vnd.ms-excel": "xls",
"application.vnd.ms-powerpoint": "ppt",
"application/x-shockwave-flash": "swf",
"appliation/zip": "zip",
"audio/mpeg": "mp3",
"audio/ogg": "ogg",
"video/3gpp": "3gpp,3gp",
"video/mpeg": "mpeg,mpg",
"video/quicktime": "mov",
"video/x-flv": "flv",
"video/x-ms-wmv": "wmv",
"video/x-msvideo": "avi",
"video/mp4": "m4v,mp4",
};

fileFormats.map(fileFormat => {
if (extensions[fileFormat]) {
result += extensions[fileFormat] + ",";
}
else {
result += fileFormat.split("/")[1] + ",";
}
});
return result;
}

getFiles() {
const sf = this.getServiceFramework();
let parentId = this.state.selectedFolder ? this.state.selectedFolder.key : null;
const extensions = this.props.fileFormats.map(format => format.split("/")[1]).join(",");
const extensions = this.getExtensions(this.props.fileFormats);
if (parentId) {
sf.get("GetFiles", { parentId, filter: extensions }, this.setFiles.bind(this), this.handleError.bind(this));
} else if (this.state.selectedFolder) {
Expand All @@ -111,7 +157,7 @@ export default class Browse extends Component {

setFolderId(result) {
const selectedFolder = result.Tree.children[0].data;
const extensions = this.props.fileFormats.map(format => format.split("/")[1]).join(",");
const extensions = this.getExtensions(this.props.fileFormats);
const sf = this.getServiceFramework();
sf.get("GetFiles", { parentId: selectedFolder.key, filter: extensions }, this.setFiles.bind(this), this.handleError.bind(this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ FileUpload.propTypes = {
//---REQUIRED PROPS---
utils: PropTypes.object.isRequired,
onSelectFile: PropTypes.func.isRequired,
validationCode: PropTypes.string.isRequired,

//---OPTIONAL PROPS---
selectedFile: PropTypes.object,
Expand Down Expand Up @@ -466,7 +467,6 @@ FileUpload.defaultProps = {
cropImagePreview: false,
portalId: -1,
fileFormats: [],

browseButtonText: "Browse Filesystem",
uploadButtonText: "Upload a File",
linkButtonText: "Enter URL Link",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ class PageDetail extends Component {

render() {
const DetailComponent = this.getDetail(this.props.page.pageType);


return (
<div>
<DetailComponent onChangeField={this.props.onChangeField} errors={this.props.errors} onSelectParentPageId={this.props.onSelectParentPageId}/>
<PageIcons components={this.props.components} onChangeField={this.props.onChangeField} errors={this.props.errors} page={this.props.page} />
<PageIcons components={this.props.components} onChangeField={this.props.onChangeField} errors={this.props.errors} page={this.props.page} validationCode={this.props.page.validationCode} />
<PageDetailsFooter components={this.props.components} onChangeField={this.props.onChangeField} errors={this.props.errors} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class PageIcons extends Component {
selectedFile={props.page.iconFile}
folderName={props.page.iconFile ? props.page.iconFile.folderName: null}
fileFormats={["image/png", "image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/svg+xml"]}
validationCode={props.validationCode}
browseActionText={Localization.get("BrowseAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
browseButtonText={Localization.get("BrowseButton")} // Browse Filesystem
defaultText={Localization.get("DragOver")} // Drag and Drop a File
Expand Down Expand Up @@ -63,6 +64,7 @@ export default class PageIcons extends Component {
selectedFile={props.page.iconFileLarge}
folderName={props.page.iconFileLarge ? props.page.iconFileLarge.folderName : null}
fileFormats={["image/png", "image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/svg+xml"]}
validationCode={props.validationCode}
browseActionText={Localization.get("BrowseAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
browseButtonText={Localization.get("BrowseButton")} // Browse Filesystem
defaultText={Localization.get("DragOver")} // Drag and Drop a File
Expand Down Expand Up @@ -91,6 +93,7 @@ export default class PageIcons extends Component {

PageIcons.propTypes = {
page: PropTypes.object.isRequired,
validationCode: PropTypes.string.isRequired,
errors: PropTypes.object.isRequired,
onChangeField: PropTypes.func.isRequired,
components: PropTypes.array.isRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ const PageService = function () {
});
};

const toFrontEndPage = function (page) {
const toFrontEndPage = function (pageResult) {
return {
...page,
schedulingEnabled: page.startDate || page.endDate
...pageResult.page,
schedulingEnabled: pageResult.page.startDate || pageResult.page.endDate,
validationCode: pageResult.ValidationCode,
};
};

Expand Down
Loading