Skip to content

feat: Global: Notification Alert Revamp #2555

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

Merged
merged 18 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"lodash": "^4.17.20",
"moment-timezone": "^0.5.33",
"monaco-editor": "^0.25.2",
"notistack": "^3.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

How much file size does this add to our bundle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

24.3 kB minified, 8.4kb minified + gzipped

"react": "^17.0.2",
"react-chartjs-2": "^4.3.1",
"react-codemirror2": "^7.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const ItemCreate = () => {

dispatch(
notify({
message: `Created new ${model.label} item`,
message: `Created Item: ${model.label}`,
kind: "success",
})
);
Expand Down
13 changes: 5 additions & 8 deletions src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,8 @@ export default function ItemEdit() {

dispatch(
notify({
message: `You are missing data in ${res.missingRequired.map(
(f) => f.label + " "
)}`,
heading: `Cannot Save: ${item.web.metaTitle}`,
message: "Missing Data in Required Fields",
kind: "error",
})
);
Expand All @@ -262,7 +261,7 @@ export default function ItemEdit() {
if (res.status === 400) {
dispatch(
notify({
message: `Failed to save new version: ${res.error}`,
message: `Cannot Save: ${item.web.metaTitle}`,
kind: "error",
})
);
Expand All @@ -271,11 +270,9 @@ export default function ItemEdit() {

dispatch(
notify({
message: `Saved a new ${
message: `Item Saved: ${
item && item.web.metaLinkText ? item.web.metaLinkText : ""
} (${
languages.find((lang) => lang.ID === item.meta.langID)?.code
}) version`,
}`,
kind: "save",
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const ItemSettings = memo(
{web.pathPart !== "zesty_home" && (
<Fragment>
<ItemParent
metaTitle={web.metaTitle}
itemZUID={meta.ZUID}
modelZUID={props.modelZUID}
parentZUID={web.parentZUID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,25 @@ export const ItemParent = connect((state) => {
props.dispatch(
notify({
kind: "warn",
message: `Parent item not found ${res.status}`,
heading: `Cannot Save: ${props.metaTitle}`,
messsage: "Set page parent in SEO Tab",
})
);
}
} else {
props.dispatch(
notify({
kind: "warn",
message: `API failed to return data ${res.status}`,
message: `API failed to return data. Try Again.`,
})
);
}
} else {
props.dispatch(
notify({
kind: "warn",
message: `API failed to return response when searching for ${parentZUID}`,
heading: `"Cannot Save: ${props.metaTitle}`,
message: `Page's Parent does not exist or has been deleted`,
})
);
}
Expand Down
11 changes: 6 additions & 5 deletions src/apps/content-editor/src/app/views/LinkCreate/LinkCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,20 @@ export function LinkCreate() {
if (res.error) {
let message = "";
if (/metaTitle/.test(res.error)) {
message = "Missing Link title";
message = "Please add a Link Title";
} else if (
/internal links must target a content item/.test(res.error)
) {
message = "Missing Link target";
message = "Please add a Link Target";
} else if (
/external links must target an external site/.test(res.error)
) {
message = "Missing Link protocol";
message = "Please add a Link Protocol";
}
dispatch(
notify({
message: `Failure creating link: ${message}`,
heading: "Unable to Create Link",
message,
kind: "error",
})
);
Expand All @@ -107,7 +108,7 @@ export function LinkCreate() {
dispatch(instanceApi.util.invalidateTags(["ContentNav"]));
dispatch(
notify({
message: "Successfully created link",
message: `Link Created: ${state.metaTitle}`,
kind: "save",
})
);
Expand Down
27 changes: 21 additions & 6 deletions src/apps/content-editor/src/app/views/LinkEdit/LinkEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,35 @@ export default function LinkEdit() {
setState({ ...state, saving: false });
let message = "";
if (/metaTitle/.test(res.error)) {
message = "Missing Link title";
message = "Please add a Link Title";
} else if (
/internal links must target a content item/.test(res.error)
) {
message = "Missing Link target";
message = "Please add a Link Target";
} else if (
/external links must target an external site/.test(res.error)
) {
message = "Missing Link protocol";
message = "Please add a Link Protocol";
}
dispatch(
notify({
message: `Error saving link: ${message}`,
heading: `Cannot Save: ${
params.metaTitle.trim() === ""
? "Empty Title"
: params.metaTitle
}`,
message,
kind: "error",
})
);
} else {
setState({ ...state, saving: false });
dispatch(notify({ message: "Saved link", kind: "save" }));
dispatch(
notify({
message: `Link Saved: ${params.metaTitle}`,
kind: "save",
})
);
dispatch(instanceApi.util.invalidateTags(["ContentNav"]));
}
})
Expand All @@ -218,7 +228,12 @@ export default function LinkEdit() {
dispatch({
type: "REMOVE_LINK",
});
dispatch(notify({ message: "Deleted Link", kind: "save" }));
dispatch(
notify({
message: `Link Deleted: ${state.metaTitle}`,
kind: "deleted",
})
);
dispatch(unpinTab({ pathname: `/content/link/${linkZUID}`, search: "" }));
dispatch(instanceApi.util.invalidateTags(["ContentNav"]));
});
Expand Down
18 changes: 15 additions & 3 deletions src/apps/schema/src/app/components/CreateModelDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,23 @@ export const CreateModelDialogue = ({ onClose, modelType = "" }: Props) => {

useEffect(() => {
if (error) {
// @ts-ignore
let message = error?.data?.error || "Failed to create model",
heading = "";
// @ts-ignore
if (error?.data?.error.includes("label cannot be blank")) {
message = "Please Add Display Name";
heading = "Cannot Create Model";
// @ts-ignore
} else if (error?.data?.error.includes("name is already in use")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of this. Would prefer BE messaging changes. But approving

message = "Display name is already in use";
heading = "Cannot Create Model";
}
dispatch(
notify({
// @ts-ignore
message: error?.data?.error || "Failed to create model",
kind: "warn",
message,
heading,
kind: "error",
})
);
}
Expand Down
12 changes: 9 additions & 3 deletions src/apps/schema/src/app/components/DeleteModelDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ export const DeleteModelDialogue = ({ onClose, model }: Props) => {
}, [isSuccess]);

useEffect(() => {
// @ts-ignore
let message = error?.data?.error || "Failed to delete model";
// @ts-ignore
if (error?.data?.error.includes("Failed to Delete Model")) {
message = `Cannot Delete Model: ${model.label}`;
}

if (error) {
dispatch(
notify({
// @ts-ignore
message: error?.data?.error || "Failed to delete model",
kind: "warn",
message,
kind: "error",
})
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/schema/src/app/components/Field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ export const Field = ({
let message = "";

if (isFieldDeleted) {
message = `\"${field?.label}\" field is deactivated`;
message = `Field Deactivated: ${field?.label}`;
}

if (isFieldUndeleted) {
message = `\"${field?.label}\" field is reactivated`;
message = `Field Reactivated: ${field?.label}`;
}

dispatch(
Expand Down
Loading