slice-machine-ui 1.15.1-dev-next-release.1 → 1.15.1-dev-next-release.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/components/ChangesItems/ChangesItems.tsx +16 -25
  2. package/components/CustomTypeTable/changesPage.tsx +4 -6
  3. package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +3 -0
  4. package/lib/builders/CustomTypeBuilder/SliceZone/List.tsx +26 -32
  5. package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +1 -0
  6. package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +1 -0
  7. package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModalList.tsx +23 -76
  8. package/next.config.mjs +1 -0
  9. package/out/404.html +1 -1
  10. package/out/[lib]/[sliceName]/[variation]/screenshot.html +1 -1
  11. package/out/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  12. package/out/[lib]/[sliceName]/[variation].html +1 -1
  13. package/out/_next/static/chunks/14-90eaa126dcf1b635.js +1 -0
  14. package/out/_next/static/chunks/{377-3caacee3c3ffdc25.js → 377-467ca51a57342a23.js} +1 -1
  15. package/out/_next/static/chunks/{573-e92018662d1f6c26.js → 573-8678a91b09707f5d.js} +1 -1
  16. package/out/_next/static/chunks/590-d9046f10fcc34a4d.js +1 -0
  17. package/out/_next/static/chunks/840-d84a2655185995ce.js +1 -0
  18. package/out/_next/static/chunks/{97-f6188ebe22eb21da.js → 97-ee2fa6c3e6bf7b71.js} +1 -1
  19. package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]/{simulator-c608e0470a8f6099.js → simulator-47ba090193469e3f.js} +1 -1
  20. package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]-89838e684fcaaf5d.js +1 -0
  21. package/out/_next/static/chunks/pages/{_app-50e4bd906b82c68e.js → _app-f7e14ddd3e363991.js} +9 -9
  22. package/out/_next/static/chunks/pages/changes-c62c4ac5de9a1a09.js +1 -0
  23. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-9ba8a3f68a048222.js → [customTypeId]-1baa6af0ddf0ab6b.js} +1 -1
  24. package/out/_next/static/chunks/pages/custom-types-78e57821222c9603.js +1 -0
  25. package/out/_next/static/chunks/pages/index-d3da65c8b508c26e.js +1 -0
  26. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-3144fdf0c6f9af94.js → [pageTypeId]-708b782db680b804.js} +1 -1
  27. package/out/_next/static/chunks/pages/slices-15b69ac3611efbfe.js +1 -0
  28. package/out/_next/static/css/22d69420bda374a7.css +1 -0
  29. package/out/_next/static/css/{b6bfe1e0ef76c2b1.css → 9ddd0cb7fff63603.css} +1 -1
  30. package/out/_next/static/css/f585032018f6024b.css +1 -0
  31. package/out/_next/static/pA_sw-x2_QsAanOp1Lx0c/_buildManifest.js +1 -0
  32. package/out/changelog.html +1 -1
  33. package/out/changes.html +1 -1
  34. package/out/custom-types/[customTypeId].html +1 -1
  35. package/out/custom-types.html +1 -1
  36. package/out/index.html +1 -1
  37. package/out/page-types/[pageTypeId].html +1 -1
  38. package/out/slices.html +1 -1
  39. package/package.json +4 -4
  40. package/pages/_app.tsx +37 -5
  41. package/pages/index.tsx +8 -0
  42. package/pages/slices.tsx +25 -42
  43. package/src/domain/slice.ts +38 -0
  44. package/src/features/changes/StatusBadge.tsx +107 -0
  45. package/src/features/customTypes/PageTypeOnboarding.tsx +60 -0
  46. package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +2 -2
  47. package/src/features/slices/sliceCards/NonSharedSliceViewCard.tsx +39 -0
  48. package/src/features/slices/sliceCards/SharedSliceSelectionCard.tsx +80 -0
  49. package/src/features/slices/sliceCards/SharedSliceViewCard.tsx +147 -0
  50. package/src/hooks/useIsEmptyProject.ts +24 -0
  51. package/src/icons/BlankPageIcon.tsx +58 -0
  52. package/src/icons/SliceMachinePrinterIcon.tsx +69 -0
  53. package/src/modules/pushChangesSaga/trackPushChangesSuccess.ts +1 -1
  54. package/test/components/CreateCustomTypeModal.test.tsx +1 -0
  55. package/test/pages/custom-types.test.tsx +1 -1
  56. package/test/pages/slices.test.tsx +2 -2
  57. package/components/KebabMenuDropdown/KebabMenuList.tsx +0 -71
  58. package/components/KebabMenuDropdown/index.tsx +0 -64
  59. package/components/StatusBadge/index.tsx +0 -139
  60. package/lib/models/ui/Link.ts +0 -23
  61. package/lib/models/ui/Slice/LegacySliceTooltip.module.css +0 -10
  62. package/lib/models/ui/Slice/index.tsx +0 -424
  63. package/lib/models/ui/Slice/wrappers.tsx +0 -49
  64. package/lib/models/ui/Store.ts +0 -10
  65. package/out/_next/static/chunks/323-9843d325f7ff6913.js +0 -1
  66. package/out/_next/static/chunks/482-93d7a0d3a0353f59.js +0 -1
  67. package/out/_next/static/chunks/906-9224feb63b5e36f3.js +0 -1
  68. package/out/_next/static/chunks/pages/[lib]/[sliceName]/[variation]-36ba0bde8415ad8b.js +0 -1
  69. package/out/_next/static/chunks/pages/changes-8338c9d0723a7033.js +0 -1
  70. package/out/_next/static/chunks/pages/custom-types-abb8c8c92880120e.js +0 -1
  71. package/out/_next/static/chunks/pages/index-f382c8090bd21628.js +0 -1
  72. package/out/_next/static/chunks/pages/slices-afa4b34df8f8e1c3.js +0 -1
  73. package/out/_next/static/css/6b6c11ed1fffd3e0.css +0 -1
  74. package/out/_next/static/css/e855bef88bb5345b.css +0 -1
  75. package/out/_next/static/l5qzy_xQjzd7ei5tL_M1r/_buildManifest.js +0 -1
  76. package/src/icons/LightningIcon3D.tsx +0 -49
  77. package/src/models/ApiError.ts +0 -6
  78. package/src/models/SyncError.ts +0 -3
  79. package/src/utils/screenshots/missing.ts +0 -4
  80. package/test/src/utils/screenshots/missing.test.ts +0 -51
  81. /package/out/_next/static/{l5qzy_xQjzd7ei5tL_M1r → pA_sw-x2_QsAanOp1Lx0c}/_ssgManifest.js +0 -0
@@ -0,0 +1,147 @@
1
+ import {
2
+ Box,
3
+ Button,
4
+ DropdownMenu,
5
+ DropdownMenuContent,
6
+ DropdownMenuItem,
7
+ DropdownMenuTrigger,
8
+ Icon,
9
+ IconButton,
10
+ Text,
11
+ tokens,
12
+ } from "@prismicio/editor-ui";
13
+ import Link from "next/link";
14
+ import type { FC } from "react";
15
+
16
+ import { ComponentUI } from "@lib/models/common/ComponentUI";
17
+ import { Card, CardFooter, CardMedia, CardStatus } from "@src/components/Card";
18
+ import {
19
+ countMissingScreenshots,
20
+ getScreenshotUrl,
21
+ getSharedSliceLibraryName,
22
+ } from "@src/domain/slice";
23
+ import {
24
+ StatusBadge,
25
+ type StatusBadgeProps,
26
+ } from "@src/features/changes/StatusBadge";
27
+ import { SLICES_CONFIG } from "@src/features/slices/slicesConfig";
28
+ import { AddPhotoAlternateIcon } from "@src/icons/AddPhotoAlternateIcon";
29
+
30
+ type SharedSliceViewCardProps = {
31
+ action:
32
+ | { type: "menu"; onRemove: () => void; onRename: () => void }
33
+ | { type: "remove"; onRemove: () => void }
34
+ | ({ type: "status" } & Omit<StatusBadgeProps, "modelType">);
35
+ isDeletedSlice: boolean;
36
+ onUpdateScreenshot: (() => void) | undefined;
37
+ slice: ComponentUI;
38
+ };
39
+
40
+ export const SharedSliceViewCard: FC<SharedSliceViewCardProps> = ({
41
+ action,
42
+ isDeletedSlice,
43
+ onUpdateScreenshot,
44
+ slice,
45
+ }) => {
46
+ const defaultVariation = ComponentUI.variation(slice);
47
+ if (!defaultVariation) return null;
48
+ const href = SLICES_CONFIG.getBuilderPagePathname({
49
+ libraryName: slice.href,
50
+ sliceName: slice.model.name,
51
+ variationId: defaultVariation.id,
52
+ });
53
+ const src = getScreenshotUrl(slice, defaultVariation);
54
+ const canUpdateScreenshot = !!onUpdateScreenshot && !isDeletedSlice;
55
+ return (
56
+ <Card
57
+ {...(href !== undefined && !isDeletedSlice
58
+ ? { component: Link, href, interactive: true }
59
+ : { interactive: false })}
60
+ >
61
+ {src !== undefined ? (
62
+ <CardMedia
63
+ overlay={
64
+ canUpdateScreenshot ? (
65
+ <Box alignItems="center" justifyContent="center">
66
+ <UpdateScreenshotButton onClick={onUpdateScreenshot} />
67
+ </Box>
68
+ ) : undefined
69
+ }
70
+ src={src}
71
+ />
72
+ ) : (
73
+ <CardMedia component="div">
74
+ <Box
75
+ alignItems="center"
76
+ flexDirection="column"
77
+ gap={8}
78
+ justifyContent="center"
79
+ >
80
+ <Text color="grey11" component="span">
81
+ No screenshot available
82
+ </Text>
83
+ {canUpdateScreenshot ? (
84
+ <UpdateScreenshotButton onClick={onUpdateScreenshot} />
85
+ ) : undefined}
86
+ </Box>
87
+ </CardMedia>
88
+ )}
89
+ <CardFooter
90
+ action={
91
+ action.type === "menu" ? (
92
+ <DropdownMenu modal>
93
+ <DropdownMenuTrigger>
94
+ <IconButton icon="moreVert" />
95
+ </DropdownMenuTrigger>
96
+ <DropdownMenuContent align="end">
97
+ <DropdownMenuItem
98
+ onSelect={action.onRename}
99
+ startIcon={<Icon name="edit" />}
100
+ >
101
+ Rename
102
+ </DropdownMenuItem>
103
+ <DropdownMenuItem
104
+ color="tomato"
105
+ onSelect={action.onRemove}
106
+ startIcon={<Icon name="delete" />}
107
+ >
108
+ Delete
109
+ </DropdownMenuItem>
110
+ </DropdownMenuContent>
111
+ </DropdownMenu>
112
+ ) : action.type === "remove" ? (
113
+ <IconButton icon="close" onClick={action.onRemove} />
114
+ ) : (
115
+ <StatusBadge
116
+ authStatus={action.authStatus}
117
+ isOnline={action.isOnline}
118
+ modelStatus={action.modelStatus}
119
+ modelType="Slice"
120
+ />
121
+ )
122
+ }
123
+ subtitle={getSharedSliceLibraryName(slice)}
124
+ title={slice.model.name}
125
+ />
126
+ {canUpdateScreenshot && countMissingScreenshots(slice) > 0 ? (
127
+ <CardStatus>Missing screenshot</CardStatus>
128
+ ) : undefined}
129
+ </Card>
130
+ );
131
+ };
132
+
133
+ type UpdateScreenshotButtonProps = {
134
+ onClick: () => void;
135
+ };
136
+
137
+ const UpdateScreenshotButton: FC<UpdateScreenshotButtonProps> = (props) => (
138
+ <Button
139
+ onClick={props.onClick}
140
+ renderStartIcon={() => (
141
+ <AddPhotoAlternateIcon color={tokens.color.greyLight11} />
142
+ )}
143
+ variant="secondary"
144
+ >
145
+ Update screenshot
146
+ </Button>
147
+ );
@@ -0,0 +1,24 @@
1
+ import { useRequest } from "@prismicio/editor-support/Suspense";
2
+
3
+ import { managerClient } from "@src/managerClient";
4
+
5
+ async function getIsEmptyProject() {
6
+ const [
7
+ { errors: customTypesErrors, models: customTypes },
8
+ { errors: slicesErrors, models: slices },
9
+ ] = await Promise.all([
10
+ managerClient.customTypes.readAllCustomTypes(undefined),
11
+ managerClient.slices.readAllSlices(),
12
+ ]);
13
+
14
+ if (customTypesErrors.length > 0 || slicesErrors.length > 0) {
15
+ throw [...customTypesErrors, ...slicesErrors];
16
+ }
17
+
18
+ return customTypes?.length === 0 && slices?.length === 0;
19
+ }
20
+
21
+ export function useIsEmptyProject() {
22
+ const isEmptyProject = useRequest(getIsEmptyProject, []);
23
+ return isEmptyProject;
24
+ }
@@ -0,0 +1,58 @@
1
+ import type { FC, SVGProps } from "react";
2
+
3
+ export const BlankPageIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
4
+ <svg
5
+ width="127"
6
+ height="101"
7
+ viewBox="0 0 127 101"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <line
13
+ x1="0.353553"
14
+ y1="35.9863"
15
+ x2="15.5467"
16
+ y2="51.1794"
17
+ stroke="#C8C7CB"
18
+ />
19
+ <line
20
+ x1="42.1959"
21
+ y1="0.87059"
22
+ x2="47.7569"
23
+ y2="21.6248"
24
+ stroke="#C8C7CB"
25
+ />
26
+ <line
27
+ x1="99.5522"
28
+ y1="8.40984"
29
+ x2="87.2281"
30
+ y2="26.0104"
31
+ stroke="#C8C7CB"
32
+ />
33
+ <line
34
+ x1="126.408"
35
+ y1="41.0854"
36
+ x2="108.807"
37
+ y2="53.4094"
38
+ stroke="#C8C7CB"
39
+ />
40
+ <path d="M93.5 93L76 81.9883L93.5 87V93Z" fill="#6F6E77" />
41
+ <path
42
+ d="M92 100.488H36C34.8954 100.488 34 99.5929 34 98.4883V37.9883C34 36.8837 34.8954 35.9883 36 35.9883H92C93.1046 35.9883 94 36.8837 94 37.9883V98.4883C94 99.5929 93.1046 100.488 92 100.488Z"
43
+ stroke="#1A1523"
44
+ />
45
+ <path
46
+ d="M74.4297 58.7688C71.569 63.3138 63.3588 74.9883 54.5 74.9883L93.8417 86.9402C93.9471 86.9722 94.0473 87.0119 94.1481 87.0563C95.014 87.4377 99.5549 89.2156 104.5 86.9883C106.535 86.0718 109.03 82.7182 110.424 80.6551C111.04 79.7445 110.743 78.5257 109.805 77.9526L77.2788 58.0753C76.3086 57.4824 75.0354 57.8065 74.4297 58.7688Z"
47
+ fill="#5842C3"
48
+ />
49
+ <path
50
+ d="M34 47.9883C34 47.9883 42.3922 74.9883 54.5 74.9883M54.5 74.9883C63.3588 74.9883 71.569 63.3138 74.4297 58.7688C75.0354 57.8065 76.3086 57.4824 77.2788 58.0753L109.805 77.9526C110.743 78.5257 111.04 79.7445 110.424 80.6551C109.03 82.7182 106.535 86.0718 104.5 86.9883C99.5549 89.2156 95.014 87.4377 94.1481 87.0563C94.0473 87.0119 93.9471 86.9722 93.8417 86.9402L54.5 74.9883Z"
51
+ stroke="#1A1523"
52
+ />
53
+ <path d="M34 48.4883H94" stroke="#1A1523" />
54
+ <circle cx="40" cy="41.9883" r="1.5" stroke="#1A1523" />
55
+ <circle cx="46" cy="41.9883" r="1.5" stroke="#1A1523" />
56
+ <circle cx="52" cy="41.9883" r="1.5" stroke="#1A1523" />
57
+ </svg>
58
+ );
@@ -0,0 +1,69 @@
1
+ import type { FC, SVGProps } from "react";
2
+
3
+ export const SliceMachinePrinterIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
4
+ <svg
5
+ width="127"
6
+ height="98"
7
+ viewBox="0 0 127 98"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <path d="M73.5 44.5H85" stroke="#17151F" strokeLinecap="round" />
13
+ <path
14
+ d="M35 68.5H40.5H92C93.1046 68.5 94 67.6046 94 66.5V39C94 37.8954 93.1046 37 92 37H35C33.8954 37 33 37.8954 33 39V66.5C33 67.6046 33.8954 68.5 35 68.5Z"
15
+ fill="#F4F2F4"
16
+ stroke="#17151F"
17
+ />
18
+ <path
19
+ d="M38 60.5H41.0381H89C89.5523 60.5 90 60.0523 90 59.5V52C90 51.4477 89.5523 51 89 51H38C37.4477 51 37 51.4477 37 52V59.5C37 60.0523 37.4477 60.5 38 60.5Z"
20
+ fill="#6E56CF"
21
+ stroke="#17151F"
22
+ />
23
+ <circle cx="89.5" cy="44.5" r="0.5" fill="#17151F" />
24
+ <path d="M40.5 97.5V56H86V97.5H40.5Z" fill="#F9F8F9" stroke="#17151F" />
25
+ <rect x="47" y="75" width="33" height="16" fill="#E4E2E4" />
26
+ <path
27
+ d="M48 57H52V70C52 71.1046 51.1046 72 50 72V72C48.8954 72 48 71.1046 48 70V57Z"
28
+ fill="#E4E2E4"
29
+ />
30
+ <path
31
+ d="M55 57H59V70C59 71.1046 58.1046 72 57 72V72C55.8954 72 55 71.1046 55 70V57Z"
32
+ fill="#E4E2E4"
33
+ />
34
+ <path
35
+ d="M62 57H66V70C66 71.1046 65.1046 72 64 72V72C62.8954 72 62 71.1046 62 70V57Z"
36
+ fill="#E4E2E4"
37
+ />
38
+ <line
39
+ x1="0.353553"
40
+ y1="35.9856"
41
+ x2="15.5467"
42
+ y2="51.1787"
43
+ stroke="#C8C7CB"
44
+ />
45
+ <line
46
+ x1="42.1959"
47
+ y1="0.87059"
48
+ x2="47.7569"
49
+ y2="21.6248"
50
+ stroke="#C8C7CB"
51
+ />
52
+ <line x1="99.5522" y1="8.4091" x2="87.2281" y2="26.0097" stroke="#C8C7CB" />
53
+ <line
54
+ x1="126.408"
55
+ y1="41.0849"
56
+ x2="108.807"
57
+ y2="53.4089"
58
+ stroke="#C8C7CB"
59
+ />
60
+ <path
61
+ d="M39.8713 47C38.7657 47 38.0627 46.4554 38.0033 45.6337L38 45.5875H38.8251L38.8284 45.6205C38.868 46.0198 39.2937 46.2838 39.8977 46.2838C40.4719 46.2838 40.8746 46 40.8746 45.5908V45.5875C40.8746 45.2442 40.6271 45.0363 40.0132 44.9043L39.5017 44.7987C38.5281 44.5941 38.1056 44.1386 38.1056 43.429V43.4257C38.1056 42.5743 38.8383 42 39.868 42C40.9241 42 41.5809 42.5776 41.6403 43.3432L41.6436 43.3861H40.8284L40.8218 43.3465C40.7624 42.9769 40.4092 42.7129 39.8647 42.7162C39.3366 42.7162 38.9604 42.9637 38.9604 43.3696V43.3729C38.9604 43.7096 39.2013 43.9208 39.7954 44.0462L40.3069 44.1551C41.3102 44.3663 41.7294 44.769 41.7294 45.4884V45.4917C41.7294 46.4191 41.0132 47 39.8713 47Z"
62
+ fill="black"
63
+ />
64
+ <path
65
+ d="M42.6865 46.8812V42.1188H43.6634L45.0957 45.7822H45.1518L46.5809 42.1188H47.5578V46.8812H46.7921V43.495H46.7327L45.4125 46.8812H44.8317L43.5116 43.495H43.4554V46.8812H42.6865Z"
66
+ fill="black"
67
+ />
68
+ </svg>
69
+ );
@@ -1,6 +1,6 @@
1
1
  import { ChangesPushSagaPayload } from ".";
2
2
  import { telemetry } from "@src/apiClient";
3
- import { countMissingScreenshots } from "@src/utils/screenshots/missing";
3
+ import { countMissingScreenshots } from "@src/domain/slice";
4
4
  import { ModelStatus } from "@lib/models/common/ModelStatus";
5
5
 
6
6
  type trackingParameters = ChangesPushSagaPayload & { startTime: number };
@@ -64,6 +64,7 @@ describe("CreateCustomTypeModal", () => {
64
64
  format: "custom",
65
65
  type: "repeatable",
66
66
  nodeVersion: process.versions.node,
67
+ origin: "table",
67
68
  },
68
69
  }),
69
70
  expect.any(Function)
@@ -302,7 +302,7 @@ describe("Custom Type Builder", () => {
302
302
  const user = userEvent.setup();
303
303
  await user.click(screen.getByText("Select existing"));
304
304
 
305
- const slicesToSelect = screen.getAllByTestId("slicezone-modal-item");
305
+ const slicesToSelect = screen.getAllByTestId("shared-slice-selection-card");
306
306
 
307
307
  for (const elem of slicesToSelect) {
308
308
  // eslint-disable-next-line @typescript-eslint/await-thenable
@@ -31,7 +31,7 @@ describe("slices", () => {
31
31
  mockRouter.setCurrentUrl("/slices");
32
32
  });
33
33
 
34
- test("When user creates a slice it should send a tracking event", async (ctx) => {
34
+ test.skip("When user creates a slice it should send a tracking event", async (ctx) => {
35
35
  const adapter = createTestPlugin({
36
36
  setup: ({ hook }) => {
37
37
  hook("slice:create", () => void 0);
@@ -206,7 +206,7 @@ describe("slices", () => {
206
206
  );
207
207
  });
208
208
 
209
- test("if creation fails it sohuld not send the tracking event", async (ctx) => {
209
+ test.skip("if creation fails it sohuld not send the tracking event", async (ctx) => {
210
210
  const adapter = createTestPlugin({
211
211
  setup: ({ hook }) => {
212
212
  hook("slice:create", () => {
@@ -1,71 +0,0 @@
1
- import React from "react";
2
- import { Box, Flex } from "theme-ui";
3
- import { MenuOption } from ".";
4
-
5
- const MenuItem: React.FunctionComponent<MenuOption> = ({
6
- displayName,
7
- onClick,
8
- dataCy,
9
- }) => {
10
- return (
11
- <Box
12
- sx={{
13
- py: 2,
14
- px: 3,
15
- cursor: "pointer",
16
- fontSize: "14px",
17
- borderRadius: 0,
18
- ":hover": {
19
- bg: "hoverBackground",
20
- },
21
- }}
22
- onClick={onClick}
23
- data-cy={dataCy}
24
- >
25
- {displayName}
26
- </Box>
27
- );
28
- };
29
-
30
- export const KebabMenuList: React.FunctionComponent<{
31
- menuOptions: MenuOption[];
32
- closeMenu: () => void;
33
- dataCy?: string;
34
- }> = ({ menuOptions, closeMenu, dataCy }) => {
35
- return (
36
- <Box
37
- data-cy={dataCy}
38
- sx={{
39
- py: 1,
40
- flexDirection: "column",
41
- backgroundColor: "headSection",
42
- overflow: "auto",
43
- display: "flex",
44
- borderRadius: "6px",
45
- border: (t) => `1px solid ${String(t.colors?.darkBorder)}`,
46
- boxShadow: "0 10px 10px rgba(0, 0, 0, 0.05)",
47
- maxHeight: 340,
48
- minWidth: 120,
49
- maxWidth: 350,
50
- color: "text",
51
- }}
52
- >
53
- <Flex sx={{ p: 0, flexDirection: "column" }}>
54
- {menuOptions.map((option) => {
55
- return (
56
- <MenuItem
57
- key={option.displayName}
58
- displayName={option.displayName}
59
- onClick={(event) => {
60
- closeMenu();
61
- event.preventDefault();
62
- option.onClick(event);
63
- }}
64
- dataCy={option.dataCy}
65
- />
66
- );
67
- })}
68
- </Flex>
69
- </Box>
70
- );
71
- };
@@ -1,64 +0,0 @@
1
- import { useState } from "react";
2
- import { BsThreeDotsVertical } from "react-icons/bs";
3
- import { Popover } from "react-tiny-popover";
4
- import { Box, Button, useThemeUI } from "theme-ui";
5
- import { KebabMenuList } from "./KebabMenuList";
6
-
7
- export type MenuOption = {
8
- displayName: string;
9
- onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
10
- dataCy?: string;
11
- };
12
-
13
- type KebabMenuDropdownProps = {
14
- menuOptions: MenuOption[];
15
- dataCy?: string;
16
- };
17
-
18
- export const KebabMenuDropdown: React.FC<KebabMenuDropdownProps> = ({
19
- menuOptions,
20
- dataCy,
21
- }) => {
22
- const [isOpen, setIsOpen] = useState(false);
23
-
24
- const { theme } = useThemeUI();
25
-
26
- return (
27
- <Box>
28
- <Popover
29
- align="end"
30
- isOpen={isOpen}
31
- onClickOutside={() => setIsOpen(false)}
32
- positions={["bottom", "top"]}
33
- padding={2}
34
- content={() => (
35
- <KebabMenuList
36
- menuOptions={menuOptions}
37
- closeMenu={() => setIsOpen(false)}
38
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
39
- dataCy={dataCy && `${dataCy}-dropdown`}
40
- />
41
- )}
42
- >
43
- <Button
44
- variant="dropDownButton"
45
- sx={{
46
- p: "5px",
47
- backgroundColor: "white",
48
- boxShadow: "0px 1px 0px rgba(0, 0, 0, 0.04)",
49
- }}
50
- onClick={(event) => {
51
- event.preventDefault();
52
- setIsOpen(!isOpen);
53
- }}
54
- data-cy={dataCy}
55
- >
56
- <BsThreeDotsVertical
57
- color={theme.colors?.greyIcon as string}
58
- size={16}
59
- />
60
- </Button>
61
- </Popover>
62
- </Box>
63
- );
64
- };
@@ -1,139 +0,0 @@
1
- import ReactTooltip from "react-tooltip";
2
- import { Badge, Box, Flex, Text } from "theme-ui";
3
- import { ReactTooltipPortal } from "@components/ReactTooltipPortal";
4
- import { ModelStatus } from "@lib/models/common/ModelStatus";
5
- import { AuthStatus } from "@src/modules/userContext/types";
6
-
7
- interface StatusBadgeProps {
8
- modelType: "Slice" | "Custom Type";
9
- modelId: string;
10
- status: ModelStatus;
11
- authStatus: AuthStatus;
12
- isOnline: boolean;
13
- }
14
-
15
- export const StatusBadge: React.FC<StatusBadgeProps> = ({
16
- modelType,
17
- modelId,
18
- status,
19
- authStatus,
20
- isOnline,
21
- }) => {
22
- // Getting information to display depending on status
23
- const { displayName, tooltipText } = statusDisplayInformation(
24
- modelType,
25
- status,
26
- authStatus,
27
- isOnline
28
- );
29
-
30
- return (
31
- <Box sx={{ height: 28, display: "flex", alignItems: "center" }}>
32
- <Text
33
- data-for={`${modelId}-tooltip`}
34
- data-tip
35
- sx={{
36
- display: "flex",
37
- height: 24,
38
- }}
39
- >
40
- <Badge
41
- variant={status}
42
- sx={{
43
- padding: "4px 8px;",
44
- borderRadius: "6px;",
45
- lineHeight: "16px",
46
- }}
47
- >
48
- {displayName}
49
- </Badge>
50
- </Text>
51
- <ReactTooltipPortal>
52
- <ReactTooltip
53
- id={`${modelId}-tooltip`}
54
- type="dark"
55
- multiline
56
- border
57
- borderColor="black"
58
- place="bottom"
59
- effect="solid"
60
- >
61
- <Flex
62
- sx={{
63
- maxWidth: "196px",
64
- textAlign: "center",
65
- margin: "0 -13px",
66
- }}
67
- >
68
- {tooltipText}
69
- </Flex>
70
- </ReactTooltip>
71
- </ReactTooltipPortal>
72
- </Box>
73
- );
74
- };
75
-
76
- function statusDisplayInformation(
77
- modelType: StatusBadgeProps["modelType"],
78
- status: ModelStatus,
79
- authStatus: AuthStatus,
80
- isOnline: boolean
81
- ): { displayName: string; tooltipText: string } {
82
- switch (status) {
83
- case ModelStatus.New:
84
- return {
85
- displayName: "New",
86
- tooltipText: `This ${modelType} exists only locally. Upon sync, it will be pushed to your remote repository.`,
87
- };
88
-
89
- case ModelStatus.Modified:
90
- return {
91
- displayName: "Modified",
92
- tooltipText: `This ${modelType} has been modified locally. Upon sync, changes will be pushed to your remote repository.`,
93
- };
94
-
95
- case ModelStatus.Synced:
96
- return {
97
- displayName: "Synced",
98
- tooltipText: `This ${modelType} is in sync with the remote repository.`,
99
- };
100
-
101
- case ModelStatus.Deleted:
102
- return {
103
- displayName: "Deleted",
104
- tooltipText: `This ${modelType} has been deleted locally.`,
105
- };
106
-
107
- case ModelStatus.Unknown:
108
- if (!isOnline) {
109
- return {
110
- displayName: "Unknown",
111
- tooltipText:
112
- "Data from the remote repository could not be fetched (no internet connection).",
113
- };
114
- }
115
-
116
- if (authStatus === AuthStatus.UNAUTHORIZED) {
117
- return {
118
- displayName: "Unknown",
119
- tooltipText:
120
- "Data from the remote repository could not be fetched (not connected to Prismic).",
121
- };
122
- }
123
-
124
- if (authStatus === AuthStatus.FORBIDDEN) {
125
- return {
126
- displayName: "Unknown",
127
- tooltipText:
128
- "Data from the remote repository could not be fetched (you don't have access to the repository).",
129
- };
130
- }
131
-
132
- default:
133
- return {
134
- displayName: "Unknown",
135
- tooltipText:
136
- "Data from the remote repository could not be fetched (unknown error).",
137
- };
138
- }
139
- }
@@ -1,23 +0,0 @@
1
- export const Link = {
2
- variation(
3
- lib: string,
4
- sliceName: string,
5
- variationId: string,
6
- options: object = {}
7
- ): {
8
- href: string;
9
- as: string;
10
- options: object;
11
- all: [string, string, object];
12
- } {
13
- const href = "/[lib]/[sliceName]/[variation]";
14
- const as = `/${lib}/${sliceName}/${variationId}`;
15
-
16
- return {
17
- href,
18
- as,
19
- options,
20
- all: [href, as, options],
21
- };
22
- },
23
- };
@@ -1,10 +0,0 @@
1
- div.legacySliceTooltipContainer {
2
- border-radius: 6px;
3
- width: 230px;
4
- text-align: center;
5
- padding: 8px;
6
- }
7
-
8
- div.legacySliceTooltipContainer > a {
9
- color: white;
10
- }