Skip to content

Commit

Permalink
Merge branch 'dev' into feature/2132-workflow-status
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin committed Feb 19, 2025
2 parents 40c5d17 + 1edccf4 commit 282ef78
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 51 deletions.
10 changes: 3 additions & 7 deletions cypress/e2e/schema/field.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ describe("Schema: Fields", () => {
it("Creates a One-to-one relationship field", () => {
cy.intercept("**/fields?showDeleted=true").as("getFields");

const fieldLabel = `One to One ${timestamp}`;
const fieldName = `one_to_one_${timestamp}`;

// Open the add field modal
cy.getBySelector(SELECTORS.ADD_FIELD_BTN)
.should("exist")
Expand All @@ -320,9 +317,6 @@ describe("Schema: Fields", () => {
// Select one-to-one relationship field
cy.getBySelector(SELECTORS.FIELD_SELECT_ONE_TO_ONE).should("exist").click();

// Fill up fields
cy.getBySelector(SELECTORS.INPUT_LABEL).should("exist").type(fieldLabel);

// Select a related model
cy.getBySelector(SELECTORS.AUTOCOMPLETE_MODEL_ZUID)
.should("exist")
Expand Down Expand Up @@ -359,7 +353,9 @@ describe("Schema: Fields", () => {
cy.wait("@getFields");

// Check if field exists
cy.getBySelector(`Field_${fieldName}`).should("exist");
cy.getBySelector(
"Field_cypress_test__group_with_visible_fields_in_list_"
).should("exist");
});

it("Creates a currency field", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const DialogContentItem = ({ item }: DialogContentItemProps) => {
backgroundColor: "grey.100",
width: 40,
height: 40,
minWidth: 40,
minHeight: 40,
alignItems: "center",
justifyContent: "center",
overflow: "hidden",
Expand Down
2 changes: 1 addition & 1 deletion src/apps/content-editor/src/app/views/ItemList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const ItemList = () => {
CONFIG.SERVICE_MEDIA_RESOLVER
}/resolve/${
value?.split(",")[0]
}/getimage/?w=${68}&h=${58}&type=fit`
}/getimage/?w=${68}&h=auto&type=fit`
: value?.split(",")?.[0];
break;
case "internal_link":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ export const FieldForm = ({
?.sort((a, b) => a.label.localeCompare(b.label));
}, [allModels]);
const fieldsOptions: DropdownOptions[] = useMemo(() => {
return selectedModelFields?.map((field) => ({
label: field.label,
value: field.ZUID,
}));
return selectedModelFields
?.filter((field) => !field.deletedAt)
?.map((field) => ({
label: field.label,
value: field.ZUID,
}));
}, [selectedModelFields]);
const [
deleteContentModelField,
Expand Down Expand Up @@ -698,30 +700,35 @@ export const FieldForm = ({
inputName: string;
value: FormValue;
}) => {
const isAutoPopulateName = inputName === "label" && !isUpdateField;
const modelName =
inputName === "relatedModelZUID" && !!value
? allModels?.find((model) => model.ZUID === value)?.label
: "";

// Form data update
setFormData((prevData) => ({
...prevData,
[inputName]:
inputName === "name" ? convertLabelValue(value as string) : value,
}));

// Auto populate "name" when "label" field changes
if (isAutoPopulateName) {
setFormData((prevData) => ({
...prevData,
name: convertLabelValue(value as string),
}));
}
// Auto populate "name" when "label" field changes
...(inputName === "label" &&
!isUpdateField && {
name: convertLabelValue(value as string),
}),

// Reset relatedFieldZUID when model zuid changes
if (inputName === "relatedModelZUID") {
setFormData((prevData) => ({
...prevData,
// Reset relatedFieldZUID when model zuid changes
...(inputName === "relatedModelZUID" && {
relatedFieldZUID: "",
}));
}
}),

// Auto populate "name" and "label" when relatedModelZUID changes
...(inputName === "relatedModelZUID" &&
!isUpdateField && {
name: convertLabelValue(modelName),
label: modelName,
}),
}));
};

const handleAddAnotherField = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import {
DialogContent,
DialogTitle,
Expand All @@ -23,6 +23,12 @@ interface Props {
onFieldClick: (fieldType: string, fieldName: string) => void;
onModalClose: () => void;
}

const FIELD_CATEGORIES: Record<string, string> = {
dateandtime: "Date & Time",
options: "Advanced",
};

export const FieldSelection = ({ onFieldClick, onModalClose }: Props) => {
const user: User = useSelector((state: AppState) => state.user);
const [fieldTypes, setFieldTypes] = useState(FIELD_COPY_CONFIG);
Expand Down Expand Up @@ -137,7 +143,7 @@ export const FieldSelection = ({ onFieldClick, onModalClose }: Props) => {
mb={1.5}
color="text.secondary"
>
{fieldKey === "dateandtime" ? "Date & Time" : fieldKey}
{FIELD_CATEGORIES?.[fieldKey] || fieldKey}
</Typography>
<Box
display="grid"
Expand Down
5 changes: 3 additions & 2 deletions src/apps/schema/src/app/components/DeleteModelDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const DeleteModelDialogue = ({ onClose, model }: Props) => {
useEffect(() => {
if (isSuccess) {
onClose();
history.push("/schema");
const targetPath = `/${history?.location?.pathname.split("/")[1]}`;
history.push(targetPath);
}
}, [isSuccess]);
}, [isSuccess, history]);

useEffect(() => {
// @ts-ignore
Expand Down
7 changes: 6 additions & 1 deletion src/apps/schema/src/app/components/ModelMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export const ModelMenu: FC<Props> = ({ anchorEl, onClose, modelZUID }) => {

return (
<ThemeProvider theme={theme}>
<Menu anchorEl={anchorEl} open={!!anchorEl} onClose={onClose}>
<Menu
anchorEl={anchorEl}
open={!!anchorEl}
onClose={onClose}
container={() => document.getElementById(modelZUID)!}
>
<MenuItem
onClick={() => {
setShowDialogue("rename");
Expand Down
7 changes: 7 additions & 0 deletions src/shell/components/FieldTypeTinyMCE/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ export const FieldTypeTinyMCE = React.memo(function FieldTypeTinyMCE({

// Customize editor buttons and actions
setup: (editor: any) => {
editor.on("init", function () {
editor.addShortcut("meta+p", "", () => {
window.dispatchEvent(
new KeyboardEvent("keydown", { key: "p", metaKey: true })
);
});
});
editor.on("SkinLoaded", () => {
setIsSkinLoaded(true);
});
Expand Down
18 changes: 2 additions & 16 deletions src/shell/components/NavTree/components/NavTreeItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, HTMLAttributes } from "react";
import React, { FC } from "react";
import { TreeItem } from "@mui/x-tree-view";
import { Stack, Box, Typography, Tooltip, alpha } from "@mui/material";

Expand All @@ -15,8 +15,6 @@ interface Props {
nodeData?: any;
onItemDrop?: (draggedItem: any, targetItem: any) => void;
dragAndDrop?: boolean;
hoveredItemId?: string;
setHoveredItemId?: (id: string) => void;
}
export const NavTreeItem: FC<Props> = React.memo(
({
Expand All @@ -30,12 +28,9 @@ export const NavTreeItem: FC<Props> = React.memo(
nodeData,
onItemDrop,
dragAndDrop = false,
hoveredItemId = "",
setHoveredItemId = () => {},
}) => {
const currentDepth = depth + 1;
const depthPadding = currentDepth * 1;
const itemId = `${nodeId}-${currentDepth}`;

return (
<TreeItem
Expand Down Expand Up @@ -98,10 +93,6 @@ export const NavTreeItem: FC<Props> = React.memo(
py: 0.5,
pl: 1,
borderRadius: 0,
"&.is-hovered": {
backgroundColor: (theme) =>
alpha(theme.palette.primary.main, 0.07),
},
".MuiTreeItem-iconContainer": {
width: 20,
height: 20,
Expand Down Expand Up @@ -144,10 +135,7 @@ export const NavTreeItem: FC<Props> = React.memo(
},
}}
ContentProps={{
className: itemId === hoveredItemId ? "is-hovered" : "",
onMouseEnter: (event: any) => {
setHoveredItemId(itemId);
},
id: nodeId.split("/").pop(),
onDragOver: (event: any) => {
if (dragAndDrop) {
event.preventDefault();
Expand Down Expand Up @@ -189,8 +177,6 @@ export const NavTreeItem: FC<Props> = React.memo(
actions={item.actions ?? []}
onItemDrop={onItemDrop}
dragAndDrop={dragAndDrop}
hoveredItemId={hoveredItemId}
setHoveredItemId={setHoveredItemId}
/>
);
})}
Expand Down
3 changes: 0 additions & 3 deletions src/shell/components/NavTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const NavTree: FC<Readonly<Props>> = ({
dragAndDrop = false,
}) => {
const history = useHistory();
const [hoveredItemId, setHoveredItemId] = React.useState<string>("");

return (
<>
Expand Down Expand Up @@ -89,8 +88,6 @@ export const NavTree: FC<Readonly<Props>> = ({
nodeData={item.nodeData}
onItemDrop={onItemDrop}
dragAndDrop={dragAndDrop}
hoveredItemId={hoveredItemId}
setHoveredItemId={setHoveredItemId}
/>
);
})}
Expand Down

0 comments on commit 282ef78

Please sign in to comment.