slice-machine-ui 1.23.2-beta.1 → 1.23.2-beta.10

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 (122) hide show
  1. package/.depcheckrc +3 -0
  2. package/components/DeleteSliceModal/index.tsx +34 -24
  3. package/components/DeleteVariationModal/index.tsx +1 -0
  4. package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +61 -38
  5. package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +2 -2
  6. package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +33 -21
  7. package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +0 -1
  8. package/components/ModalFormCard/index.tsx +0 -1
  9. package/components/Navigation/ChangesListItem.tsx +14 -32
  10. package/components/Navigation/index.tsx +29 -12
  11. package/components/ReviewModal/ReviewForm.tsx +0 -1
  12. package/lib/builders/common/EditModal/Form.jsx +0 -1
  13. package/lib/builders/common/Zone/Card/components/NewField.tsx +0 -1
  14. package/lib/models/common/widgets/StructuredText/index.ts +1 -1
  15. package/out/404.html +1 -1
  16. package/out/_next/static/Dz7wwTNVdXvoAjySXz7mE/_buildManifest.js +1 -0
  17. package/out/_next/static/chunks/18539003-5f78714a35fde4a1.js +97 -0
  18. package/out/_next/static/chunks/25-01f422cea8066349.js +1 -0
  19. package/out/_next/static/chunks/318-99b5914b60bf1d17.js +1 -0
  20. package/out/_next/static/chunks/727-f8fefdd3e50cab2a.js +1 -0
  21. package/out/_next/static/chunks/777-8c5507e3b119b5dc.js +8 -0
  22. package/out/_next/static/chunks/799-b616401fe0dafdeb.js +1 -0
  23. package/out/_next/static/chunks/904-4653b7a849f4db94.js +1 -0
  24. package/out/_next/static/chunks/pages/_app-5ec41fc53c1f6405.js +434 -0
  25. package/out/_next/static/chunks/pages/{changelog-afd18276fe018b24.js → changelog-02cd80dad6f40878.js} +1 -1
  26. package/out/_next/static/chunks/pages/changes-8e9da8fbb809aad3.js +1 -0
  27. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3f862ad6111a1fc0.js → [customTypeId]-97ab3b90b85d645d.js} +1 -1
  28. package/out/_next/static/chunks/pages/{custom-types-94b8f8dbf7727412.js → custom-types-3c8e721ec6802127.js} +1 -1
  29. package/out/_next/static/chunks/pages/index-cf93d16e9c63b6db.js +1 -0
  30. package/out/_next/static/chunks/pages/{labs-ee206005948f8e87.js → labs-39b50541a4c370bf.js} +1 -1
  31. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
  32. package/out/_next/static/chunks/pages/settings-879686e3a8759dc3.js +1 -0
  33. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-897ca93c114a1435.js → simulator-c498e9c80cae8cce.js} +1 -1
  34. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-9b893c62b2f2fe4a.js +1 -0
  35. package/out/_next/static/chunks/pages/slices-4522d604117d8c66.js +1 -0
  36. package/out/_next/static/css/3c26dbbbd8f4be12.css +1 -0
  37. package/out/_next/static/css/{37153180c3b0dd66.css → 838fd8bb5a7c32b0.css} +1 -1
  38. package/out/_next/static/css/ca32882a5d2d8d88.css +1 -0
  39. package/out/changelog.html +1 -1
  40. package/out/changes.html +1 -1
  41. package/out/custom-types/[customTypeId].html +1 -1
  42. package/out/custom-types.html +1 -1
  43. package/out/index.html +1 -1
  44. package/out/labs.html +1 -1
  45. package/out/page-types/[pageTypeId].html +1 -1
  46. package/out/settings.html +1 -0
  47. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  48. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  49. package/out/slices.html +1 -1
  50. package/package.json +9 -6
  51. package/pages/settings.tsx +1 -0
  52. package/pages/slices.tsx +20 -8
  53. package/postcss.config.js +10 -0
  54. package/src/apiClient.ts +1 -22
  55. package/src/components/FieldSet/FieldSet.stories.tsx +20 -11
  56. package/src/components/RelativeTime/RelativeTime.stories.tsx +25 -0
  57. package/src/components/RelativeTime/RelativeTime.tsx +40 -0
  58. package/src/components/RelativeTime/index.ts +1 -0
  59. package/src/domain/__tests__/customType.test.ts +205 -19
  60. package/src/domain/customType.ts +132 -7
  61. package/src/domain/slice.ts +38 -0
  62. package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
  63. package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
  64. package/src/features/customTypes/actions/createCustomType.ts +69 -0
  65. package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
  66. package/src/features/customTypes/actions/renameCustomType.ts +10 -4
  67. package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +3 -1
  68. package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
  69. package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
  70. package/src/features/environments/actions/setEnvironment.ts +2 -2
  71. package/src/features/settings/SettingsPage.tsx +47 -0
  72. package/src/features/settings/git/ConnectGitRepository.tsx +126 -0
  73. package/src/features/settings/git/ConnectGitRepositoryBlankSlate.tsx +33 -0
  74. package/src/features/settings/git/GitOwnerSelect.tsx +71 -0
  75. package/src/features/settings/git/GitProvider.ts +40 -0
  76. package/src/features/settings/git/GitProviderConnectButtons.tsx +63 -0
  77. package/src/features/settings/git/GitRepositoriesList.tsx +76 -0
  78. package/src/features/settings/git/GitRepositoriesSearch.tsx +69 -0
  79. package/src/features/settings/git/GitRepositoryConnectDialog.tsx +85 -0
  80. package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +60 -0
  81. package/src/features/settings/git/useGitIntegrationExperiment.ts +8 -0
  82. package/src/features/settings/git/useGitOwners.ts +12 -0
  83. package/src/features/settings/git/useGitRepos.ts +24 -0
  84. package/src/features/settings/git/useLinkedGitRepos.ts +41 -0
  85. package/src/features/settings/git/useWriteAPIToken.ts +23 -0
  86. package/src/features/slices/actions/createSlice.ts +5 -29
  87. package/src/features/slices/actions/deleteSlice.ts +33 -0
  88. package/src/features/slices/actions/renameSlice.ts +37 -0
  89. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +0 -1
  90. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +0 -1
  91. package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +0 -1
  92. package/src/hooks/useUser.ts +14 -0
  93. package/src/icons/SettingsIcon.tsx +19 -0
  94. package/src/modules/availableCustomTypes/index.ts +29 -135
  95. package/src/modules/loading/types.ts +0 -5
  96. package/src/modules/modal/types.ts +0 -3
  97. package/src/modules/slices/index.ts +27 -193
  98. package/src/modules/slices/selector.ts +0 -14
  99. package/src/modules/useSliceMachineActions.ts +70 -89
  100. package/src/modules/userContext/index.ts +3 -3
  101. package/src/redux/saga.ts +0 -4
  102. package/test/src/modules/__fixtures__/serverState.ts +1 -2
  103. package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
  104. package/test/src/modules/slices.test.ts +1 -267
  105. package/out/_next/static/chunks/18539003-5cc559566b738915.js +0 -97
  106. package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
  107. package/out/_next/static/chunks/318-ce7e74f18f2d5b22.js +0 -1
  108. package/out/_next/static/chunks/376-7e784d6069e01654.js +0 -8
  109. package/out/_next/static/chunks/727-3a3bc32518778317.js +0 -1
  110. package/out/_next/static/chunks/731-501990ebe6a71b32.js +0 -1
  111. package/out/_next/static/chunks/904-9a4c1264727ae89a.js +0 -1
  112. package/out/_next/static/chunks/pages/_app-cd9d4c76a4abc11a.js +0 -432
  113. package/out/_next/static/chunks/pages/changes-2a976f9efeb719aa.js +0 -1
  114. package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
  115. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +0 -1
  116. package/out/_next/static/chunks/pages/slices-e9c70c082ca3e3f9.js +0 -1
  117. package/out/_next/static/css/200244e3e0463c39.css +0 -1
  118. package/out/_next/static/m6psnC5u1xT7Y6osWHKjp/_buildManifest.js +0 -1
  119. package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
  120. package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
  121. package/test/components/CreateCustomTypeModal.test.tsx +0 -73
  122. /package/out/_next/static/{m6psnC5u1xT7Y6osWHKjp → Dz7wwTNVdXvoAjySXz7mE}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,e,t,i,f,b,n,u,d,h,l,k,j,p,g,o,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[a,j,p,"static/chunks/pages/index-64cfb8b0948ba8ef.js"],"/_error":["static/chunks/pages/_error-69b4f498bafdd188.js"],"/changelog":[s,e,"static/chunks/870-0c7a8a9622de78b7.js","static/chunks/pages/changelog-afd18276fe018b24.js"],"/changes":[s,t,"static/chunks/8eec4907-b712959d9f984b68.js",i,"static/chunks/918-5bb55fb464e34768.js",c,b,"static/css/37153180c3b0dd66.css","static/chunks/pages/changes-2a976f9efeb719aa.js"],"/custom-types":[a,j,p,"static/chunks/pages/custom-types-94b8f8dbf7727412.js"],"/custom-types/[customTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/custom-types/[customTypeId]-3f862ad6111a1fc0.js"],"/labs":["static/chunks/pages/labs-ee206005948f8e87.js"],"/page-types/[pageTypeId]":[s,n,u,d,h,e,f,i,l,g,c,a,k,o,r,"static/chunks/pages/page-types/[pageTypeId]-d1ffca11c42f2603.js"],"/slices":[s,t,f,c,b,"static/css/f8eb526e10bc2441.css","static/chunks/pages/slices-e9c70c082ca3e3f9.js"],"/slices/[lib]/[sliceName]/[variation]":[s,t,n,u,d,h,e,f,i,l,c,k,b,"static/css/b22c0750c14cc089.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[t,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/18539003-5cc559566b738915.js","static/chunks/376-7e784d6069e01654.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/59b4e022-7a3b5554b806349f.js","static/chunks/25-37d6fa7f064be04b.js","static/chunks/731-501990ebe6a71b32.js","static/chunks/183-4feb6bb3eddbc768.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/543-f8766685f7f451e2.js","static/chunks/50-cfc2514205b86001.js","static/chunks/286-ed90373e9a469944.js","static/chunks/f36c6662-03bb5e9d9aa0b0aa.js","static/chunks/4c744e84-e3161d754618373f.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-2c5b6c0367fcde86.js","static/chunks/696-b12edad30a3617e5.js","static/chunks/318-ce7e74f18f2d5b22.js","static/chunks/727-3a3bc32518778317.js","static/css/be1f49e49a5aa7eb.css","static/chunks/474-5a072e6fac61f703.js","static/chunks/904-9a4c1264727ae89a.js","static/css/72465cc1225f28a2.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1,159 +0,0 @@
1
- import { describe, expect } from "vitest";
2
- import { createCustomType } from "@src/features/customTypes/customTypesTable/createCustomType";
3
-
4
- describe("createCustomType test suite", () => {
5
- it("should create a custom type with repeatable true", () => {
6
- expect(createCustomType("id", "lama", true, "custom"))
7
- .toMatchInlineSnapshot(`
8
- {
9
- "format": "custom",
10
- "id": "id",
11
- "json": {
12
- "Main": {
13
- "uid": {
14
- "config": {
15
- "label": "UID",
16
- },
17
- "type": "UID",
18
- },
19
- },
20
- },
21
- "label": "lama",
22
- "repeatable": true,
23
- "status": true,
24
- }
25
- `);
26
- });
27
-
28
- it("should create a custom type with repeatable false", () => {
29
- const result = createCustomType("id", "lama", false, "custom");
30
- expect(result.id).toBe("id");
31
- expect(result.label).toBe("lama");
32
- expect(result.format).toBe("custom");
33
- expect(result.json).toHaveProperty("Main");
34
- expect(result).toMatchInlineSnapshot(`
35
- {
36
- "format": "custom",
37
- "id": "id",
38
- "json": {
39
- "Main": {},
40
- },
41
- "label": "lama",
42
- "repeatable": false,
43
- "status": true,
44
- }
45
- `);
46
- });
47
-
48
- it("should create a page type with a slice zone", () => {
49
- const result = createCustomType("🥪", "label", true, "page");
50
- expect(result.format).toBe("page");
51
- expect(result.json).toHaveProperty("Main");
52
- expect(result.json.Main).toHaveProperty("slices");
53
- expect(result.json).toHaveProperty("SEO & Metadata");
54
- expect(result).toMatchInlineSnapshot(`
55
- {
56
- "format": "page",
57
- "id": "🥪",
58
- "json": {
59
- "Main": {
60
- "slices": {
61
- "config": {
62
- "choices": {},
63
- },
64
- "fieldset": "Slice Zone",
65
- "type": "Slices",
66
- },
67
- "uid": {
68
- "config": {
69
- "label": "UID",
70
- },
71
- "type": "UID",
72
- },
73
- },
74
- "SEO & Metadata": {
75
- "meta_description": {
76
- "config": {
77
- "label": "Meta Description",
78
- "placeholder": "A brief summary of the page",
79
- },
80
- "type": "Text",
81
- },
82
- "meta_image": {
83
- "config": {
84
- "constraint": {
85
- "height": 1260,
86
- "width": 2400,
87
- },
88
- "label": "Meta Image",
89
- "thumbnails": [],
90
- },
91
- "type": "Image",
92
- },
93
- "meta_title": {
94
- "config": {
95
- "label": "Meta Title",
96
- "placeholder": "A title of the page used for social media and search engines",
97
- },
98
- "type": "Text",
99
- },
100
- },
101
- },
102
- "label": "label",
103
- "repeatable": true,
104
- "status": true,
105
- }
106
- `);
107
- });
108
- });
109
-
110
- it("when non repeatable page type is should contain Main with a slice-zone, no uid, and a SEO tab", () => {
111
- const result = createCustomType("foo", "bar", false, "page");
112
- expect(result).toMatchInlineSnapshot(`
113
- {
114
- "format": "page",
115
- "id": "foo",
116
- "json": {
117
- "Main": {
118
- "slices": {
119
- "config": {
120
- "choices": {},
121
- },
122
- "fieldset": "Slice Zone",
123
- "type": "Slices",
124
- },
125
- },
126
- "SEO & Metadata": {
127
- "meta_description": {
128
- "config": {
129
- "label": "Meta Description",
130
- "placeholder": "A brief summary of the page",
131
- },
132
- "type": "Text",
133
- },
134
- "meta_image": {
135
- "config": {
136
- "constraint": {
137
- "height": 1260,
138
- "width": 2400,
139
- },
140
- "label": "Meta Image",
141
- "thumbnails": [],
142
- },
143
- "type": "Image",
144
- },
145
- "meta_title": {
146
- "config": {
147
- "label": "Meta Title",
148
- "placeholder": "A title of the page used for social media and search engines",
149
- },
150
- "type": "Text",
151
- },
152
- },
153
- },
154
- "label": "bar",
155
- "repeatable": false,
156
- "status": true,
157
- }
158
- `);
159
- });
@@ -1,107 +0,0 @@
1
- import { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
- import type { CustomTypeFormat } from "@slicemachine/manager";
3
-
4
- export function createCustomType(
5
- id: string,
6
- label: string,
7
- repeatable: boolean,
8
- format: CustomTypeFormat,
9
- ): CustomType {
10
- const mainTab = makeMainTab(repeatable, format);
11
-
12
- return {
13
- id,
14
- label,
15
- format,
16
- repeatable,
17
- json: mainTab,
18
- status: true,
19
- };
20
- }
21
-
22
- function makeMainTab(
23
- repeatable: boolean,
24
- format: CustomTypeFormat,
25
- ): CustomType["json"] {
26
- if (repeatable === false && format === "page") {
27
- return { ...DEFAULT_MAIN_WITH_SLICE_ZONE, ...DEFAULT_SEO_TAB };
28
- }
29
-
30
- if (repeatable === false) {
31
- return DEFAULT_MAIN;
32
- }
33
-
34
- if (format === "page") {
35
- return {
36
- ...DEFAULT_MAIN_WITH_UID_AND_SLICE_ZONE,
37
- ...DEFAULT_SEO_TAB,
38
- };
39
- }
40
-
41
- return DEFAULT_MAIN_WITH_UID;
42
- }
43
-
44
- const DEFAULT_MAIN: CustomType["json"] = {
45
- Main: {},
46
- };
47
-
48
- const DEFAULT_MAIN_WITH_SLICE_ZONE: CustomType["json"] = {
49
- Main: {
50
- slices: {
51
- config: {
52
- choices: {},
53
- },
54
- fieldset: "Slice Zone",
55
- type: "Slices",
56
- },
57
- },
58
- };
59
-
60
- const DEFAULT_MAIN_WITH_UID: CustomType["json"] = {
61
- Main: {
62
- uid: {
63
- config: {
64
- label: "UID",
65
- },
66
- type: "UID",
67
- },
68
- },
69
- };
70
-
71
- const DEFAULT_MAIN_WITH_UID_AND_SLICE_ZONE: CustomType["json"] = {
72
- Main: {
73
- ...DEFAULT_MAIN_WITH_UID.Main,
74
- ...DEFAULT_MAIN_WITH_SLICE_ZONE.Main,
75
- },
76
- };
77
-
78
- const DEFAULT_SEO_TAB: CustomType["json"] = {
79
- "SEO & Metadata": {
80
- meta_description: {
81
- config: {
82
- label: "Meta Description",
83
- placeholder: "A brief summary of the page",
84
- },
85
- type: "Text",
86
- },
87
- meta_image: {
88
- config: {
89
- constraint: {
90
- height: 1260,
91
- width: 2400,
92
- },
93
- label: "Meta Image",
94
- thumbnails: [],
95
- },
96
- type: "Image",
97
- },
98
- meta_title: {
99
- config: {
100
- label: "Meta Title",
101
- placeholder:
102
- "A title of the page used for social media and search engines",
103
- },
104
- type: "Text",
105
- },
106
- },
107
- };
@@ -1,73 +0,0 @@
1
- // @vitest-environment jsdom
2
-
3
- import { describe, test, afterEach, expect, vi } from "vitest";
4
- import { Analytics } from "@segment/analytics-node";
5
-
6
- import { render, fireEvent, act } from "../__testutils__";
7
- import { CreateCustomTypeModal } from "../../components/Forms/CreateCustomTypeModal";
8
- import { ModalKeysEnum } from "../../src/modules/modal/types";
9
-
10
- vi.mock("next/router", () => require("next-router-mock"));
11
- global.console = { ...global.console, error: vi.fn() };
12
-
13
- describe("CreateCustomTypeModal", () => {
14
- afterEach(() => {
15
- vi.clearAllMocks();
16
- });
17
-
18
- test("when a slice is created the tracker should be called", async () => {
19
- const fakeId = "testing_id";
20
- const fakeName = "testing-name";
21
- const fakeRepo = "foo";
22
-
23
- render(<CreateCustomTypeModal format="custom" />, {
24
- preloadedState: {
25
- // @ts-expect-error TS(2739) FIXME: Type '{ repo: string; }' is missing the following ... Remove this comment to see the full error message
26
- environment: {
27
- repo: fakeRepo,
28
- },
29
- availableCustomTypes: {},
30
- // @ts-expect-error TS(2740) FIXME: Type '{ CREATE_CUSTOM_TYPE: true; }' is missing th... Remove this comment to see the full error message
31
- modal: { [ModalKeysEnum.CREATE_CUSTOM_TYPE]: true },
32
- },
33
- });
34
-
35
- const idInput = document.querySelector('[name="id"]');
36
- const labelInput = document.querySelector('[name="label"]');
37
- const submitButton = document.querySelector('[type="submit"]');
38
-
39
- await act(async () => {
40
- if (labelInput) {
41
- fireEvent.change(labelInput, { target: { value: fakeName } });
42
- }
43
- });
44
-
45
- await act(async () => {
46
- if (idInput) {
47
- fireEvent.change(idInput, { target: { value: fakeId } });
48
- }
49
- });
50
-
51
- await act(async () => {
52
- if (submitButton) {
53
- fireEvent.click(submitButton);
54
- }
55
- });
56
-
57
- expect(Analytics.prototype.track).toHaveBeenCalledOnce();
58
- expect(Analytics.prototype.track).toHaveBeenCalledWith(
59
- expect.objectContaining({
60
- event: "SliceMachine Custom Type Created",
61
- properties: {
62
- id: fakeId,
63
- name: fakeName,
64
- format: "custom",
65
- type: "repeatable",
66
- nodeVersion: process.versions.node,
67
- origin: "table",
68
- },
69
- }),
70
- expect.any(Function),
71
- );
72
- });
73
- });