Skip to content

Commit

Permalink
Stage Release (#2786)
Browse files Browse the repository at this point in the history
  • Loading branch information
agalin920 authored Jul 10, 2024
2 parents 62c7b3c + fe85588 commit 6fb1752
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 94 deletions.
117 changes: 63 additions & 54 deletions src/apps/content-editor/src/app/views/ItemList/UpdateListActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ import { SchedulePublishesModal } from "./SchedulePublishesDialog";
import { ConfirmDeletesDialog } from "./ConfirmDeletesDialog";
import { notify } from "../../../../../../shell/store/notifications";
import { useDispatch } from "react-redux";
import { usePermission } from "../../../../../../shell/hooks/use-permissions";

export const UpdateListActions = () => {
const { modelZUID } = useRouterParams<{ modelZUID: string }>();
const [params, setParams] = useParams();
const canPublish = usePermission("PUBLISH");
const canDelete = usePermission("DELETE");
const canUpdate = usePermission("UPDATE");
const dispatch = useDispatch();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>(null);
const langCode = params.get("lang");
Expand Down Expand Up @@ -71,6 +75,7 @@ export const UpdateListActions = () => {
});

const publishShortcut = useMetaKey("p", () => {
if (!canPublish) return;
if (hasStagedChanges) {
handleSaveAndPublish();
} else {
Expand Down Expand Up @@ -176,7 +181,7 @@ export const UpdateListActions = () => {
</Typography>
</Box>
<Box display="flex" gap={1} alignItems="center">
{hasStagedChanges ? (
{hasStagedChanges && canUpdate ? (
<Tooltip
enterDelay={1000}
enterNextDelay={1000}
Expand All @@ -198,7 +203,7 @@ export const UpdateListActions = () => {
Save
</LoadingButton>
</Tooltip>
) : (
) : canDelete ? (
<LoadingButton
loading={isDeleting}
onClick={() => {
Expand All @@ -211,64 +216,68 @@ export const UpdateListActions = () => {
>
Delete
</LoadingButton>
)}
<ButtonGroup
variant="contained"
color="success"
size="small"
sx={{
"& .MuiButtonGroup-grouped:not(:last-of-type)": {
borderColor: "green.600",
},
}}
>
<Tooltip
enterDelay={1000}
enterNextDelay={1000}
title={
<div>
{hasStagedChanges ? "Save & Publish Items" : "Publish Items"}{" "}
<br />
{publishShortcut}
</div>
}
) : null}
{canPublish && canUpdate && (
<ButtonGroup
variant="contained"
color="success"
size="small"
sx={{
"& .MuiButtonGroup-grouped:not(:last-of-type)": {
borderColor: "green.600",
},
}}
>
<LoadingButton
startIcon={<CloudUploadRounded />}
<Tooltip
enterDelay={1000}
enterNextDelay={1000}
title={
<div>
{hasStagedChanges
? "Save & Publish Items"
: "Publish Items"}{" "}
<br />
{publishShortcut}
</div>
}
>
<LoadingButton
startIcon={<CloudUploadRounded />}
sx={{
color: "common.white",
whiteSpace: "nowrap",
}}
onClick={() => {
if (hasStagedChanges) {
handleSaveAndPublish();
} else {
setItemsToPublish(selectedItems);
}
}}
loading={isPublishing || isSaving}
color="success"
variant="contained"
data-cy="MultiPageTablePublish"
>
{hasStagedChanges ? "Save & Publish" : "Publish"}
</LoadingButton>
</Tooltip>
<Button
sx={{
color: "common.white",
whiteSpace: "nowrap",
width: 32,
// Override MUI default minWidth of 40px one-off
minWidth: "unset !important",
}}
onClick={() => {
if (hasStagedChanges) {
handleSaveAndPublish();
} else {
setItemsToPublish(selectedItems);
}
onClick={(event) => {
setAnchorEl(event.currentTarget);
}}
loading={isPublishing || isSaving}
color="success"
variant="contained"
data-cy="MultiPageTablePublish"
disabled={isPublishing || isSaving}
>
{hasStagedChanges ? "Save & Publish" : "Publish"}
</LoadingButton>
</Tooltip>
<Button
sx={{
color: "common.white",
width: 32,
// Override MUI default minWidth of 40px one-off
minWidth: "unset !important",
}}
onClick={(event) => {
setAnchorEl(event.currentTarget);
}}
disabled={isPublishing || isSaving}
>
<ArrowDropDownRounded fontSize="small" />
</Button>
</ButtonGroup>
<ArrowDropDownRounded fontSize="small" />
</Button>
</ButtonGroup>
)}
<Menu
onClose={() => setAnchorEl(null)}
anchorOrigin={{
Expand Down
117 changes: 77 additions & 40 deletions src/shell/components/global-notifications/GlobalNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,55 +213,92 @@ export const CustomNotification = forwardRef(({ id, ...props }, ref) => {
closeSnackbar(id);
}, [id, closeSnackbar]);

return (
<SnackbarContent ref={ref}>
<Alert
data-cy="toast"
key={id}
variant="filled"
severity={props.severity}
icon={props.icon}
action={
<Stack direction="row">
<IconButton onClick={handleDismiss}>
<CloseIcon sx={{ width: 20, height: 20, color: "white" }} />
</IconButton>
</Stack>
}
sx={{
width: 540,
height: props.heading ? "auto" : 44,
}}
>
<Stack>
<Typography
variant="body2"
noWrap={props.severity === "success"}
sx={{
maxWidth: "540px",
overflow: "hidden",
textOverflow: "ellipsis",
fontWeight: props.heading ? 700 : "normal",
}}
>
{props.heading ? props.heading : props.message}
const parseStrToBold = (str, isHeading = false) => {
const styles = {
variant: "body2",
fontWeight: 700,
component: "span",
};
if (str.indexOf(":") !== -1) {
return (
<>
<Typography {...styles}>
{str.substring(0, str.indexOf(":") + 1)}
</Typography>
{str.substring(str.indexOf(":") + 1)}
</>
);
} else if (str.indexOf(":") === -1 && isHeading)
return <Typography {...styles}>{str}</Typography>;
else if (str.indexOf(":") === -1 && [undefined, ""].includes(props.heading))
return <Typography {...styles}>{str}</Typography>;
else return str;
};

{props.heading && (
const typograpySX = {
maxWidth: "540px",
overflow: "hidden",
textOverflow: "ellipsis",
// this will only show 1 or 2 lines to prevent exceeding on the expected height
// depending what type of notification will be displayed.
display: props.severity === "success" ? "block" : "-webkit-box",
"-webkit-line-clamp": props.heading && props.message ? "1" : "2",
"-webkit-box-orient": "vertical",
};

return (
<SnackbarContent ref={ref}>
{typeof props.message === "object" ? (
""
) : (
<Alert
data-cy="toast"
key={id}
variant="filled"
severity={props.severity}
icon={props.icon}
action={
<Stack direction="row">
<IconButton onClick={handleDismiss}>
<CloseIcon sx={{ width: 20, height: 20, color: "white" }} />
</IconButton>
</Stack>
}
sx={{
width: 540,
padding:
!(props.heading && props.message) || props.severity === "success"
? "4px 8px"
: "0px 8px",
}}
>
<Stack>
<Typography
variant="body2"
noWrap={props.severity === "success"}
sx={{
maxWidth: "540px",
overflow: "hidden",
textOverflow: "ellipsis",
...typograpySX,
}}
>
{props.message}
{props.heading
? props.heading && parseStrToBold(props.heading, true)
: props.message && parseStrToBold(props.message)}
</Typography>
)}
</Stack>
</Alert>

{props.heading && (
<Typography
variant="body2"
noWrap={props.severity === "success"}
sx={{
...typograpySX,
}}
>
{parseStrToBold(props.message)}
</Typography>
)}
</Stack>
</Alert>
)}
</SnackbarContent>
);
});

0 comments on commit 6fb1752

Please sign in to comment.