Skip to content

Commit bace910

Browse files
authored
Feature: Schema Enhancements (#2178)
* fix: add dynamic spacing bellow end of list button * task: show placeholder when no values are available * task: change dropdown menu icon * task: add duplicate and delete buttons on model details tab * task: add last modified sorting * task: change label to display label * task: fontweight update
1 parent 3b64218 commit bace910

File tree

7 files changed

+82
-24
lines changed

7 files changed

+82
-24
lines changed

src/apps/media/src/app/components/Header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Stack,
1212
} from "@mui/material";
1313
import CloseIcon from "@mui/icons-material/Close";
14-
import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
14+
import MoreHorizRoundedIcon from "@mui/icons-material/MoreHorizRounded";
1515
import CreateNewFolderIcon from "@mui/icons-material/CreateNewFolder";
1616
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
1717
import DriveFileRenameOutlineIcon from "@mui/icons-material/DriveFileRenameOutline";
@@ -301,7 +301,7 @@ export const Header = ({
301301
sx={{ height: "fit-content" }}
302302
aria-label="Open folder menu"
303303
>
304-
<ArrowDropDownRoundedIcon fontSize="small" />
304+
<MoreHorizRoundedIcon fontSize="small" />
305305
</IconButton>
306306
) : null}
307307
<Menu anchorEl={anchorEl} open={open} onClose={closeMenu}>

src/apps/media/src/app/components/Sidebar/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const Sidebar = ({ lockedToGroupId, isSelectDialog }: Props) => {
3030
pb: 1,
3131
}}
3232
>
33-
<Typography variant="h4">
33+
<Typography variant="h4" fontWeight={600}>
3434
{isSelectDialog && "Insert from"} Media
3535
</Typography>
3636
<SearchBox />

src/apps/schema/src/app/components/FieldList.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export const FieldList = ({ onNewFieldModalClick }: Props) => {
215215
borderBottom="1px solid"
216216
borderColor="grey.200"
217217
>
218-
<Typography variant="h6" mb={1}>
218+
<Typography variant="h6" mb={1} fontWeight={600}>
219219
System Fields
220220
</Typography>
221221
<Typography variant="body2" color="text.secondary">
@@ -309,7 +309,7 @@ export const FieldList = ({ onNewFieldModalClick }: Props) => {
309309
</Box>
310310
);
311311
})}
312-
<Box pl={3}>
312+
<Box pl={3} mb={!!deactivatedFields?.length ? 2 : 4}>
313313
<Button
314314
data-cy="EndOfListAddFieldBtn"
315315
sx={{
@@ -350,13 +350,7 @@ export const FieldList = ({ onNewFieldModalClick }: Props) => {
350350

351351
{/* INACTIVE FIELDS ARE PRESENT */}
352352
{Boolean(deactivatedFields?.length) && !search && (
353-
<Box
354-
mb={2}
355-
mt={1.5}
356-
display="flex"
357-
flexDirection="column"
358-
gap={1.5}
359-
>
353+
<Box mb={2} display="flex" flexDirection="column" gap={1.5}>
360354
<Box pl={3}>
361355
<Typography variant="h6" mb={1}>
362356
Deactivated Fields

src/apps/schema/src/app/components/ModelHeader.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ import {
2020
useGetWebViewsQuery,
2121
} from "../../../../../shell/services/instance";
2222
import AddRoundedIcon from "@mui/icons-material/AddRounded";
23-
import PostAddRoundedIcon from "@mui/icons-material/PostAddRounded";
2423
import moment from "moment";
2524
import SplitscreenRoundedIcon from "@mui/icons-material/SplitscreenRounded";
2625
import InfoRoundedIcon from "@mui/icons-material/InfoRounded";
2726
import CodeRoundedIcon from "@mui/icons-material/CodeRounded";
28-
import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
27+
import MoreHorizRoundedIcon from "@mui/icons-material/MoreHorizRounded";
2928
import DeleteRoundedIcon from "@mui/icons-material/DeleteRounded";
3029
import DriveFileRenameOutlineRoundedIcon from "@mui/icons-material/DriveFileRenameOutlineRounded";
3130
import ContentCopyRoundedIcon from "@mui/icons-material/ContentCopyRounded";
@@ -114,7 +113,7 @@ export const ModelHeader = ({ onNewFieldModalClick }: Props) => {
114113
sx={{ height: "fit-content" }}
115114
data-cy="model-header-menu"
116115
>
117-
<ArrowDropDownRoundedIcon fontSize="small" />
116+
<MoreHorizRoundedIcon fontSize="small" />
118117
</IconButton>
119118
<Menu
120119
anchorEl={anchorEl}

src/apps/schema/src/app/components/ModelInfo/ModelDetails.tsx

+53-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Box, Tooltip, Typography, Button } from "@mui/material";
22
import InfoRoundedIcon from "@mui/icons-material/InfoRounded";
3+
import ContentCopyRoundedIcon from "@mui/icons-material/ContentCopyRounded";
4+
import DeleteRoundedIcon from "@mui/icons-material/DeleteRounded";
5+
36
import {
47
useGetContentModelsQuery,
58
useGetContentNavItemsQuery,
@@ -9,6 +12,8 @@ import { useState } from "react";
912
import { RenameModelDialogue } from "../RenameModelDialogue";
1013
import { UpdateDescriptionModelDialogue } from "../UpdateDescriptionModelDialogue";
1114
import { UpdateParentModelDialogue } from "../UpdateParentModelDialogue";
15+
import { DeleteModelDialogue } from "../DeleteModelDialogue";
16+
import { DuplicateModelDialogue } from "../DuplicateModelDialogue";
1217

1318
type Params = {
1419
id: string;
@@ -27,7 +32,12 @@ export const ModelDetails = () => {
2732
(navItem) => navItem.ZUID === model?.parentZUID
2833
);
2934
const [showDialogue, setShowDialogue] = useState<
30-
"rename" | "updateDescription" | "updateParent" | null
35+
| "rename"
36+
| "updateDescription"
37+
| "updateParent"
38+
| "duplicate"
39+
| "delete"
40+
| null
3141
>(null);
3242
const [isCopied, setIsCopied] = useState("");
3343

@@ -114,7 +124,11 @@ export const ModelDetails = () => {
114124
</Tooltip>
115125
</Box>
116126
<Box flex={1} py={2}>
117-
<Typography>{model?.description}</Typography>
127+
{!!model?.description ? (
128+
<Typography>{model.description}</Typography>
129+
) : (
130+
<Typography color="text.disabled">None</Typography>
131+
)}
118132
</Box>
119133
<Box py={1.5}>
120134
<Button
@@ -197,7 +211,11 @@ export const ModelDetails = () => {
197211
</Tooltip>
198212
</Box>
199213
<Box flex={1} py={2}>
200-
<Typography>{parentModel?.label}</Typography>
214+
{!!parentModel?.label ? (
215+
<Typography>{parentModel.label}</Typography>
216+
) : (
217+
<Typography color="text.disabled">None</Typography>
218+
)}
201219
</Box>
202220
<Box display="flex" py={1.5}>
203221
<Button
@@ -258,6 +276,26 @@ export const ModelDetails = () => {
258276
</Button>
259277
</Box>
260278
</Box>
279+
<Box display="flex" alignItems="center" pt={2} gap={2}>
280+
<Button
281+
size="large"
282+
color="inherit"
283+
variant="outlined"
284+
startIcon={<ContentCopyRoundedIcon color="action" />}
285+
onClick={() => setShowDialogue("duplicate")}
286+
>
287+
Duplicate Model
288+
</Button>
289+
<Button
290+
size="large"
291+
color="error"
292+
variant="outlined"
293+
startIcon={<DeleteRoundedIcon />}
294+
onClick={() => setShowDialogue("delete")}
295+
>
296+
Delete Model
297+
</Button>
298+
</Box>
261299
</Box>
262300
{showDialogue === "rename" && (
263301
<RenameModelDialogue
@@ -277,6 +315,18 @@ export const ModelDetails = () => {
277315
model={model}
278316
/>
279317
)}
318+
{showDialogue === "duplicate" && (
319+
<DuplicateModelDialogue
320+
model={model}
321+
onClose={() => setShowDialogue(null)}
322+
/>
323+
)}
324+
{showDialogue === "delete" && (
325+
<DeleteModelDialogue
326+
model={model}
327+
onClose={() => setShowDialogue(null)}
328+
/>
329+
)}
280330
</>
281331
);
282332
};

src/apps/schema/src/app/components/Sidebar/ModelList.tsx

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
} from "@mui/material";
1212
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
1313
import AddIcon from "@mui/icons-material/Add";
14+
import moment from "moment";
15+
1416
import { ContentModel } from "../../../../../../shell/services/types";
1517
import { useHistory, useLocation } from "react-router";
1618
import { useMemo, useState } from "react";
@@ -45,10 +47,15 @@ export const ModelList = ({ title, models, type }: Props) => {
4547
const sortedModels = useMemo(() => {
4648
if (!sort) return [...models].reverse();
4749
return [...models].sort((a, b) => {
48-
if (sort === "asc") {
49-
return a.label.localeCompare(b.label);
50-
} else {
51-
return b.label.localeCompare(a.label);
50+
switch (sort) {
51+
case "asc":
52+
return a.label.localeCompare(b.label);
53+
54+
case "desc":
55+
return b.label.localeCompare(a.label);
56+
57+
case "modified":
58+
return moment(b.updatedAt).diff(moment(a.updatedAt));
5259
}
5360
});
5461
}, [sort, models]);
@@ -147,6 +154,14 @@ export const ModelList = ({ title, models, type }: Props) => {
147154
>
148155
Last Created
149156
</MenuItem>
157+
<MenuItem
158+
onClick={() => {
159+
handleClose();
160+
setSort("modified");
161+
}}
162+
>
163+
Last Modified
164+
</MenuItem>
150165
</Menu>
151166
</Box>
152167
{showCreateModelDialogue && (

src/apps/schema/src/app/components/configs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const FIELD_COPY_CONFIG: { [key: string]: FieldListData[] } = {
216216
type: "datetime",
217217
name: "Date & Time",
218218
shortDescription: "Track dates along with specific times",
219-
description: `This field is for when you want the input to be a data and time. You can customize whether a user can enter a time, day, month, or year or all 4.
219+
description: `This field is for when you want the input to be a data and time. You can customize whether a user can enter a time, day, month, or year or all 4.
220220
221221
Zesty automatically tracks dates and times for date created, date published, and date modified so no additional fields need to be created for these.`,
222222
commonUses: [
@@ -334,7 +334,7 @@ const COMMON_FIELDS: InputField[] = [
334334
{
335335
name: "label",
336336
type: "input",
337-
label: "Label",
337+
label: "Display Label",
338338
required: true,
339339
fullWidth: true,
340340
maxLength: 200,

0 commit comments

Comments
 (0)