Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.33",
"mui-color-input": "^9.0.0",
"openstack-uicore-foundation": "5.0.47",
"openstack-uicore-foundation": "5.0.50-beta.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@santipalenque Hold the merge on OpenStackweb/openstack-uicore-foundation#319: 5.0.50-beta.1's CustomDialog wraps children in its own DialogContent (src/components/mui/CustomDialog/index.js:77 there), so PreviewModal, UploadDialog and TextPreviewModal currently render DialogContent > DialogContent + DialogActions (footer buttons inside the scrollable body, PreviewModal's p: 0 defeated), while TextValueDialog has no DialogContent of its own. The locally installed 5.0.50-beta.0 does not wrap children, which is why it did not show during development. Once #319 lands, bump to the release and align the four dialogs to whichever contract shipped — one of the two groups needs a small change either way, the bump alone does not cover it.

"p-limit": "^6.1.0",
"path-browserify": "^1.0.1",
"postcss-loader": "^6.2.1",
Expand Down
57 changes: 57 additions & 0 deletions src/actions/sponsor-mu-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,60 @@ export const removeFileForSponsorMU =
dispatch(stopLoading());
});
};

export const uploadTextForSponsorMU =
(pageId, moduleId, text) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const { entity: sponsor } = currentSponsorState;
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());

const params = {
access_token: accessToken
};

return putRequest(
null,
createAction("DUMMY_ACTION"),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsor.id}/available-pages/${pageId}/modules/${moduleId}/text`,
{ value: text },
snackbarErrorHandler
)(params)(dispatch)
.then(({ response }) => {
dispatch(
createAction(SPONSOR_MEDIA_UPLOAD_FILE_UPLOADED)({
...response,
moduleId
})
);
})
.finally(() => {
dispatch(stopLoading());
});
};

export const removeTextForSponsorMU =
(pageId, moduleId) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const { entity: sponsor } = currentSponsorState;
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());

const params = {
access_token: accessToken
};

return deleteRequest(
null,
createAction(SPONSOR_MEDIA_UPLOAD_FILE_DELETED)({ moduleId }),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsor.id}/available-pages/${pageId}/modules/${moduleId}/text`,
null,
snackbarErrorHandler
)(params)(dispatch).finally(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@santipalenque removeTextForSponsorMU is dispatched fire-and-forget from handleDelete and nothing chains off it, so a failed DELETE (deleteRequest rejects on non-2xx after calling snackbarErrorHandler) becomes an unhandled rejection at every call site. For the fire-and-forget shape, skills/react-frontend.md § "Handling Rejections from openstack-uicore-foundation Requests" puts a single .catch(() => {}) inside the action, appended to the existing chain, so every current and future caller is covered:

)(params)(dispatch)
  .catch(() => {})
  .finally(() => {
    dispatch(stopLoading());
  });

removeFileForSponsorMU has the same shape and predates this PR — fine to leave it, but the new thunk should not copy the gap.

dispatch(stopLoading());
});
};
38 changes: 4 additions & 34 deletions src/components/mui/PreviewModal/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import T from "i18n-react/dist/i18n-react";
import {
Dialog,
DialogTitle,
DialogContent,
Box,
Typography,
IconButton
} from "@mui/material";
import CloseIcon from "@mui/icons-material/Close";
import { Box, DialogContent, Typography } from "@mui/material";
import CustomDialog from "openstack-uicore-foundation/lib/components/mui/custom-dialog";
import BrokenImageOutlinedIcon from "@mui/icons-material/BrokenImageOutlined";
import { formatDate } from "../../../utils/methods";

Expand All @@ -35,30 +28,7 @@ const PreviewModal = ({ title, open, onClose, url, filename, uploadDate }) => {
}, [open]);

return (
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
<DialogTitle
sx={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
pb: 1
}}
>
<Typography variant="h6">{title}</Typography>
</DialogTitle>
<IconButton
aria-label="close"
onClick={onClose}
size="small"
sx={(theme) => ({
position: "absolute",
right: 12,
top: 12,
color: theme.palette.grey[500]
})}
>
<CloseIcon fontSize="large" />
</IconButton>
<CustomDialog title={title} open={open} onClose={onClose}>
<DialogContent sx={{ p: 0 }}>
<Box
sx={{
Expand Down Expand Up @@ -115,7 +85,7 @@ const PreviewModal = ({ title, open, onClose, url, filename, uploadDate }) => {
)}
</Box>
</DialogContent>
</Dialog>
</CustomDialog>
);
};

Expand Down
30 changes: 8 additions & 22 deletions src/components/upload-dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ import React, { useState } from "react";
import {
Box,
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Divider,
IconButton,
Typography
} from "@mui/material";
import PropTypes from "prop-types";
import UploadInputV3 from "openstack-uicore-foundation/lib/components/inputs/upload-input-v3";
import CustomDialog from "openstack-uicore-foundation/lib/components/mui/custom-dialog";
import T from "i18n-react/dist/i18n-react";
import CloseIcon from "@mui/icons-material/Close";
import NoteAddIcon from "@mui/icons-material/NoteAdd";
import DeleteIcon from "@mui/icons-material/Delete";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import DialogActions from "@mui/material/DialogActions";

const MAX_PAGE_MODULE_UPLOAD_QTY = 1;

Expand Down Expand Up @@ -108,23 +106,11 @@ const UploadDialog = ({
const canAddMore = () => (value?.length || 0) < maxFiles;

return (
<Dialog open={open} onClose={handleClose} maxWidth="sm" fullWidth>
<DialogTitle>
{T.translate("edit_sponsor.mu_tab.upload_input.upload_file")}
</DialogTitle>
<IconButton
aria-label="close"
onClick={handleClose}
sx={(theme) => ({
position: "absolute",
right: 8,
top: 8,
color: theme.palette.grey[500]
})}
>
<CloseIcon />
</IconButton>
<Divider />
<CustomDialog
title={T.translate("edit_sponsor.mu_tab.upload_input.upload_file")}
open={open}
onClose={handleClose}
>
<DialogContent>
<Typography variant="body1" sx={{ mb: 2 }}>
{fileMeta.name}
Expand Down Expand Up @@ -163,7 +149,7 @@ const UploadDialog = ({
{T.translate("edit_sponsor.mu_tab.upload_input.upload_file")}
</Button>
</DialogActions>
</Dialog>
</CustomDialog>
);
};

Expand Down
5 changes: 4 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2721,14 +2721,17 @@
"media_upload": "media upload",
"sponsor_request": "Sponsor Specific Request",
"general_request": "General Media Request",
"type": "Type",
"add_on": "Add-on",
"max_size": "Max Size",
"format": "Format",
"deadline": "Deadline",
"status": "Status",
"upload_input": {
"complete": "Complete",
"upload_file": "Upload file"
"upload_file": "Upload file",
"enter_text": "Enter text",
"save_answer": "Save Answer"
}
},
"placeholders": {
Expand Down
Loading
Loading