diff --git a/src/actions/page-template-actions.js b/src/actions/page-template-actions.js index 1fa0f7fab..63edee4a4 100644 --- a/src/actions/page-template-actions.js +++ b/src/actions/page-template-actions.js @@ -29,6 +29,7 @@ import { DEFAULT_CURRENT_PAGE, DEFAULT_ORDER_DIR, DEFAULT_PER_PAGE, + PAGE_MODULES_DOWNLOAD, PAGES_MODULE_KINDS } from "../utils/constants"; import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions"; @@ -48,7 +49,7 @@ export const PAGE_TEMPLATE_UNARCHIVED = "PAGE_TEMPLATE_UNARCHIVED"; export const getPageTemplates = ( - term = null, + term = "", page = DEFAULT_CURRENT_PAGE, perPage = DEFAULT_PER_PAGE, order = "id", @@ -106,7 +107,7 @@ export const getPageTemplate = (formTemplateId) => async (dispatch) => { const params = { access_token: accessToken, - expand: "materials,meta_fields,meta_fields.values" + expand: "modules" }; return getRequest( @@ -160,8 +161,14 @@ const normalizeEntity = (entity) => { module.file_type_id?.value || module.file_type_id; } - if (module.kind === PAGES_MODULE_KINDS.DOCUMENT && module.file) { - normalizedModule.file = module.file[0] || null; + if (module.kind === PAGES_MODULE_KINDS.DOCUMENT) { + if (module.type === PAGE_MODULES_DOWNLOAD.FILE) { + normalizedModule.file = module.file[0] || null; + delete normalizedModule.external_url; + } else { + delete normalizedModule.file; + delete normalizedModule.file_id; + } } delete normalizedModule._tempId; diff --git a/src/components/forms/media-upload-form.js b/src/components/forms/media-upload-form.js index 4210e4018..1c9890cc9 100644 --- a/src/components/forms/media-upload-form.js +++ b/src/components/forms/media-upload-form.js @@ -14,7 +14,7 @@ import React from "react"; import T from "i18n-react/dist/i18n-react"; import "awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"; -import { Input, Dropdown } from "openstack-uicore-foundation/lib/components"; +import { Dropdown, Input } from "openstack-uicore-foundation/lib/components"; import TextEditorV3 from "openstack-uicore-foundation/lib/components/inputs/editor-input-v3"; import { isEmpty, scrollToError, shallowEqual } from "../../utils/methods"; @@ -103,6 +103,11 @@ class MediaUploadForm extends React.Component { .filter((t) => t.class_name === "PresentationType") .map((t) => ({ value: t.id, label: t.name })); + const mediaFileTypesDDL = mediaFileTypes.map((mft) => ({ + value: mft.id, + label: mft.name + })); + return (