Skip to content

Commit

Permalink
update uicore, add constants
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Nov 6, 2024
1 parent 9a54756 commit a92e0d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.33",
"node-sass": "^7.0.1",
"openstack-uicore-foundation": "4.1.91-beta.5",
"p-limit": "^6.1.0",
"openstack-uicore-foundation": "4.1.91-beta.6",
"path-browserify": "^1.0.1",
"postcss-loader": "^6.2.1",
"process": "^0.11.10",
Expand Down
21 changes: 14 additions & 7 deletions src/components/forms/event-material-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import {
shallowEqual,
hasErrors
} from "../../utils/methods";
import { KB } from "../../utils/constants";
import {
ALLOWED_SLIDES_FORMATS,
KB,
MAX_MEDIA_UPLOAD_SIZE,
MAX_SLIDE_UPLOAD_SIZE
} from "../../utils/constants";

const MATERIAL_TYPE = {
PRESENTATION_LINK: "PresentationLink",
Expand Down Expand Up @@ -80,7 +85,7 @@ class EventMaterialForm extends React.Component {
}
}

async handleChange(ev) {
handleChange(ev) {
const entity = { ...this.state.entity };
const errors = { ...this.state.errors };
let { value, id } = ev.target;
Expand Down Expand Up @@ -146,7 +151,11 @@ class EventMaterialForm extends React.Component {
const { entity, errors } = this.state;

// on admin we upload one per time
const media_type = { ...entity.media_upload_type, max_uploads_qty: 1 };
const media_type = {
...entity.media_upload_type,
max_size: entity.media_upload_type.max_size || MAX_MEDIA_UPLOAD_SIZE,
max_uploads_qty: 1
};
const mediaInputValue = entity.filename ? [entity] : [];

const event_materials_ddl = [
Expand All @@ -165,13 +174,11 @@ class EventMaterialForm extends React.Component {
const disableInputs =
entity.class_name === MATERIAL_TYPE.PRESENTATION_MEDIA_UPLOAD;

const MULTIPLIER = 500;

const slideMediaType = {
id: "slide",
max_size: MULTIPLIER * KB,
max_size: MAX_SLIDE_UPLOAD_SIZE,
type: {
allowed_extensions: ["jpg", "jpeg", "ppt", "pptx", "pdf"]
allowed_extensions: ALLOWED_SLIDES_FORMATS
}
};

Expand Down
6 changes: 6 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,9 @@ export const MARKETING_SETTING_TYPE_TEXTAREA = "TEXTAREA";
export const MARKETING_SETTING_TYPE_FILE = "FILE";
export const MARKETING_SETTING_TYPE_HEX_COLOR = "HEX_COLOR";
export const KB = 1024;
// 500 * 1024kb
export const MAX_MEDIA_UPLOAD_SIZE = 512000;
// 500 * 1024kb
export const MAX_SLIDE_UPLOAD_SIZE = 512000;

export const ALLOWED_SLIDES_FORMATS = ["jpg", "jpeg", "ppt", "pptx", "pdf"];

0 comments on commit a92e0d1

Please sign in to comment.