slice-machine-ui 2.17.3-beta.8 → 2.18.0

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 (91) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/by9lqJyIeSCZtBP_fLO45/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/04ad993f.d7f986af0f739cc9.js +28 -0
  4. package/out/_next/static/chunks/{248-6f20227ad4764216.js → 248-bdbfde18c5a04eae.js} +1 -1
  5. package/out/_next/static/chunks/{34-6c3125e6f01c62c7.js → 34-8d9d9b2944824750.js} +1 -1
  6. package/out/_next/static/chunks/489-6edb99e269996dd1.js +1 -0
  7. package/out/_next/static/chunks/50-586dc7ab5e584e76.js +1 -0
  8. package/out/_next/static/chunks/630-bb6e3db525588f16.js +1 -0
  9. package/out/_next/static/chunks/{647-7b9b5aa9468f9e4b.js → 647-4379a741c8d85d9e.js} +1 -1
  10. package/out/_next/static/chunks/907-445266211c48b1a5.js +1 -0
  11. package/out/_next/static/chunks/pages/{_app-87bfdef015dea569.js → _app-76c43bdc0320687e.js} +220 -222
  12. package/out/_next/static/chunks/pages/{changelog-98836c22c6a40c5d.js → changelog-21b960abba5abf71.js} +1 -1
  13. package/out/_next/static/chunks/pages/changes-bdfa50eadb1e5a42.js +1 -0
  14. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-4024560ca59ad2be.js → [customTypeId]-7102c23f96cd1768.js} +1 -1
  15. package/out/_next/static/chunks/pages/{labs-ad7f36c6f544c1a8.js → labs-d79597003a1ff74e.js} +1 -1
  16. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-0d2416da0958eb40.js → [pageTypeId]-d4bc920a5efffa0a.js} +1 -1
  17. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-b127d948a17968d3.js +1 -0
  18. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-98f85d5fb8d5c704.js +1 -0
  19. package/out/_next/static/chunks/pages/slices-046e5e978ffc3a42.js +1 -0
  20. package/out/_next/static/chunks/webpack-e0c07a2fe4908d81.js +1 -0
  21. package/out/_next/static/css/303dad78be1eb854.css +1 -0
  22. package/out/changelog.html +1 -1
  23. package/out/changes.html +1 -1
  24. package/out/custom-types/[customTypeId].html +1 -1
  25. package/out/custom-types.html +1 -1
  26. package/out/index.html +1 -1
  27. package/out/labs.html +1 -1
  28. package/out/page-types/[pageTypeId].html +1 -1
  29. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  30. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  31. package/out/slices.html +1 -1
  32. package/package.json +7 -8
  33. package/src/apiClient.ts +1 -1
  34. package/src/domain/fields.ts +7 -7
  35. package/src/features/auth/LogoutButton.tsx +37 -0
  36. package/src/features/builder/AddFieldDropdown.tsx +2 -2
  37. package/src/features/customTypes/customTypesBuilder/CreateSliceFromImageModal/CreateSliceFromImageModal.tsx +8 -21
  38. package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +4 -12
  39. package/src/features/customTypes/customTypesBuilder/sliceCreationOptions.tsx +5 -11
  40. package/src/features/environments/actions/getActiveEnvironment.ts +2 -8
  41. package/src/features/environments/useActiveEnvironment.ts +8 -1
  42. package/src/features/environments/useEnvironments.ts +8 -1
  43. package/src/features/navigation/Navigation.tsx +1 -7
  44. package/src/legacy/components/ChangesItems/ChangesItems.tsx +1 -8
  45. package/src/legacy/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -8
  46. package/src/legacy/components/ListItem/Header.tsx +18 -12
  47. package/src/legacy/components/ListItem/index.tsx +1 -0
  48. package/src/legacy/components/LoginModal/index.tsx +11 -3
  49. package/src/legacy/components/Navigation/SideNavEnvironmentSelector/SideNavEnvironmentSelector.tsx +3 -0
  50. package/src/legacy/components/Simulator/components/FailedConnect/index.tsx +51 -56
  51. package/src/legacy/components/ToasterContainer/index.tsx +3 -14
  52. package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +1 -4
  53. package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +1 -5
  54. package/src/legacy/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +4 -16
  55. package/src/legacy/lib/builders/SliceBuilder/index.tsx +1 -6
  56. package/src/legacy/lib/builders/common/EditModal/index.jsx +3 -10
  57. package/src/legacy/lib/builders/common/Zone/components/ZoneEmptyState/ZoneEmptyState.tsx +5 -10
  58. package/src/legacy/lib/models/common/widgets/Boolean/index.ts +3 -0
  59. package/src/legacy/lib/models/common/widgets/Color/index.ts +3 -0
  60. package/src/legacy/lib/models/common/widgets/ContentRelationship/index.ts +3 -0
  61. package/src/legacy/lib/models/common/widgets/Date/index.ts +3 -0
  62. package/src/legacy/lib/models/common/widgets/Embed/index.ts +3 -0
  63. package/src/legacy/lib/models/common/widgets/GeoPoint/index.ts +3 -0
  64. package/src/legacy/lib/models/common/widgets/Group/createGroupWidget.ts +2 -0
  65. package/src/legacy/lib/models/common/widgets/Image/index.ts +3 -0
  66. package/src/legacy/lib/models/common/widgets/Link/index.ts +3 -0
  67. package/src/legacy/lib/models/common/widgets/LinkToMedia/index.ts +2 -0
  68. package/src/legacy/lib/models/common/widgets/Number/index.ts +3 -0
  69. package/src/legacy/lib/models/common/widgets/Select/index.ts +3 -0
  70. package/src/legacy/lib/models/common/widgets/StructuredText/index.ts +3 -0
  71. package/src/legacy/lib/models/common/widgets/Table/index.ts +3 -0
  72. package/src/legacy/lib/models/common/widgets/Text/index.ts +3 -0
  73. package/src/legacy/lib/models/common/widgets/Timestamp/index.ts +3 -0
  74. package/src/legacy/lib/models/common/widgets/UID/index.ts +3 -0
  75. package/src/legacy/lib/models/common/widgets/Widget.ts +1 -0
  76. package/src/pages/slices.tsx +10 -38
  77. package/out/_next/static/KBrx-cAqXdE6ViRC7yyKz/_buildManifest.js +0 -1
  78. package/out/_next/static/chunks/33641354.3864aefb6106ae71.js +0 -28
  79. package/out/_next/static/chunks/44-a2056f993381ad0f.js +0 -1
  80. package/out/_next/static/chunks/489-6578dbeec3dcdace.js +0 -1
  81. package/out/_next/static/chunks/630-29c729ad2a291ef6.js +0 -1
  82. package/out/_next/static/chunks/907-590c914f55547b96.js +0 -1
  83. package/out/_next/static/chunks/pages/changes-db800bf4a08faa31.js +0 -1
  84. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-5008e29008aa04f4.js +0 -1
  85. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-0bc862dd7bd99611.js +0 -1
  86. package/out/_next/static/chunks/pages/slices-4b229ae47d0a37e2.js +0 -1
  87. package/out/_next/static/chunks/webpack-b3522fdebabf510a.js +0 -1
  88. package/out/_next/static/css/cc9b10286400c2b9.css +0 -1
  89. package/src/features/builder/useSectionsNamingExperiment.ts +0 -15
  90. package/src/utils/textConversion.ts +0 -11
  91. /package/out/_next/static/{KBrx-cAqXdE6ViRC7yyKz → by9lqJyIeSCZtBP_fLO45}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slice-machine-ui",
3
- "version": "2.17.3-beta.8",
3
+ "version": "2.18.0",
4
4
  "license": "MIT",
5
5
  "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.",
6
6
  "repository": {
@@ -35,16 +35,16 @@
35
35
  "start-slicemachine": "./bin/start-slicemachine.cjs"
36
36
  },
37
37
  "dependencies": {
38
- "@slicemachine/manager": "0.25.2-beta.12",
39
- "start-slicemachine": "0.12.60-beta.12"
38
+ "@slicemachine/manager": "0.25.2",
39
+ "start-slicemachine": "0.12.60"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@emotion/react": "11.11.1",
43
43
  "@extractus/oembed-extractor": "3.1.8",
44
44
  "@prismicio/client": "7.17.0",
45
- "@prismicio/editor-fields": "0.4.77",
46
- "@prismicio/editor-support": "0.4.77",
47
- "@prismicio/editor-ui": "0.4.77",
45
+ "@prismicio/editor-fields": "0.4.87",
46
+ "@prismicio/editor-support": "0.4.87",
47
+ "@prismicio/editor-ui": "0.4.87",
48
48
  "@prismicio/mock": "0.7.1",
49
49
  "@prismicio/mocks": "2.14.0",
50
50
  "@prismicio/simulator": "0.1.4",
@@ -136,6 +136,5 @@
136
136
  "vitest": "0.32.0",
137
137
  "yup": "0.32.11",
138
138
  "zod": "3.23.8"
139
- },
140
- "stableVersion": "2.17.2"
139
+ }
141
140
  }
package/src/apiClient.ts CHANGED
@@ -163,7 +163,7 @@ export const pushChanges: SliceMachineManagerClient["prismicRepository"]["pushCh
163
163
 
164
164
  /** Auth Routes * */
165
165
 
166
- export const startAuth = async (): Promise<void> => {
166
+ export const clearAuth = async (): Promise<void> => {
167
167
  return await managerClient.user.logout();
168
168
  };
169
169
 
@@ -92,7 +92,7 @@ export const imageField: NestableField = {
92
92
  type: "Image",
93
93
  };
94
94
 
95
- export const LinkField: NestableField = {
95
+ export const linkField: NestableField = {
96
96
  name: "Link",
97
97
  description: "A link to a website, asset, or document.",
98
98
  icon: "link",
@@ -111,8 +111,8 @@ export const contentRelationshipField: NestableField = {
111
111
  variant: "ContentRelationship",
112
112
  };
113
113
 
114
- export const LinkToMediaField: NestableField = {
115
- name: "Link To Media",
114
+ export const linkToMediaField: NestableField = {
115
+ name: "Link to Media",
116
116
  description: "A link to a media asset.",
117
117
  icon: "attachFile",
118
118
  thumbnail:
@@ -182,8 +182,8 @@ export const nestableFields: NestableField[] = [
182
182
  booleanField,
183
183
  numberField,
184
184
  selectField,
185
- LinkField,
186
- LinkToMediaField,
185
+ linkField,
186
+ linkToMediaField,
187
187
  colorField,
188
188
  dateField,
189
189
  tableField,
@@ -197,7 +197,7 @@ export const nestableFields: NestableField[] = [
197
197
  * UID
198
198
  */
199
199
 
200
- export const UIDField: UIDField = {
200
+ export const uidField: UIDField = {
201
201
  name: "UID",
202
202
  description: "Unique Identifier",
203
203
  icon: "tag",
@@ -230,4 +230,4 @@ export const groupFields: GroupField[] = [groupField, nestedGroupField];
230
230
  * All fields
231
231
  */
232
232
 
233
- export const fields = [...nestableFields, UIDField, ...groupFields];
233
+ export const fields = [...nestableFields, uidField, ...groupFields];
@@ -0,0 +1,37 @@
1
+ import { IconButton, Tooltip } from "@prismicio/editor-ui";
2
+ import * as Sentry from "@sentry/nextjs";
3
+ import { toast } from "react-toastify";
4
+
5
+ import { clearAuth as managerLogout, getState } from "@/apiClient";
6
+ import { invalidateActiveEnvironmentData } from "@/features/environments/useActiveEnvironment";
7
+ import { invalidateEnvironmentsData } from "@/features/environments/useEnvironments";
8
+ import useSliceMachineActions from "@/modules/useSliceMachineActions";
9
+
10
+ export function LogoutButton() {
11
+ const { refreshState } = useSliceMachineActions();
12
+
13
+ async function onClick() {
14
+ await managerLogout();
15
+
16
+ const serverState = await getState();
17
+ refreshState(serverState);
18
+
19
+ Sentry.setUser({ id: serverState.env.shortId });
20
+
21
+ // refresh queries to update the UI
22
+ invalidateEnvironmentsData();
23
+ invalidateActiveEnvironmentData();
24
+
25
+ toast.success("Logged out");
26
+ }
27
+
28
+ return (
29
+ <Tooltip content="Log out" side="right">
30
+ <IconButton
31
+ icon="logout"
32
+ onClick={() => void onClick()}
33
+ hiddenLabel="Log out"
34
+ />
35
+ </Tooltip>
36
+ );
37
+ }
@@ -18,7 +18,7 @@ import {
18
18
  FieldVariant,
19
19
  groupField,
20
20
  nestableFields,
21
- UIDField,
21
+ uidField,
22
22
  } from "@/domain/fields";
23
23
 
24
24
  export type AddFieldDropdownProps = {
@@ -47,7 +47,7 @@ export function AddFieldDropdown(props: AddFieldDropdownProps) {
47
47
  (field) =>
48
48
  nestableFields.some(
49
49
  (nestableField) => nestableField.name === field.name,
50
- ) || field.name === UIDField.name,
50
+ ) || field.name === uidField.name,
51
51
  );
52
52
  const groupFieldToRender = fields.find(
53
53
  (field) => field.name === groupField.name,
@@ -22,15 +22,10 @@ import { toast } from "react-toastify";
22
22
 
23
23
  import { getState, telemetry } from "@/apiClient";
24
24
  import { addAiFeedback } from "@/features/aiFeedback";
25
- import {
26
- useSectionsNamingExperiment,
27
- UseSectionsNamingExperimentReturnType,
28
- } from "@/features/builder/useSectionsNamingExperiment";
29
25
  import { useOnboarding } from "@/features/onboarding/useOnboarding";
30
26
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
31
27
  import { managerClient } from "@/managerClient";
32
28
  import useSliceMachineActions from "@/modules/useSliceMachineActions";
33
- import { pluralize } from "@/utils/textConversion";
34
29
 
35
30
  import { Slice, SliceCard } from "./SliceCard";
36
31
 
@@ -58,7 +53,7 @@ export function CreateSliceFromImageModal(
58
53
  const { syncChanges } = useAutoSync();
59
54
  const { createSliceSuccess } = useSliceMachineActions();
60
55
  const { completeStep } = useOnboarding();
61
- const sectionsNamingExperiment = useSectionsNamingExperiment();
56
+
62
57
  /**
63
58
  * Keeps track of the current instance id.
64
59
  * When the modal is closed, the id is reset.
@@ -244,8 +239,7 @@ export function CreateSliceFromImageModal(
244
239
  <DialogHeader title="Generate from image" />
245
240
  <DialogContent gap={0}>
246
241
  <DialogDescription hidden>
247
- Upload images to generate {pluralize(sectionsNamingExperiment.value)}{" "}
248
- with AI
242
+ Upload images to generate slices with AI
249
243
  </DialogDescription>
250
244
  {slices.length === 0 ? (
251
245
  <Box padding={16} height="100%">
@@ -285,8 +279,7 @@ export function CreateSliceFromImageModal(
285
279
  loading={isCreatingSlices}
286
280
  onClick={onSubmit}
287
281
  >
288
- {getSubmitButtonLabel({ location, sectionsNamingExperiment })} (
289
- {readySlices.length})
282
+ {getSubmitButtonLabel(location)} ({readySlices.length})
290
283
  </DialogActionButton>
291
284
  </DialogActions>
292
285
  </DialogContent>
@@ -298,7 +291,6 @@ function UploadBlankSlate(props: {
298
291
  droppingFiles?: boolean;
299
292
  onFilesSelected: (files: File[]) => void;
300
293
  }) {
301
- const sectionsNamingExperiment = useSectionsNamingExperiment();
302
294
  const { droppingFiles = false, onFilesSelected } = props;
303
295
 
304
296
  return (
@@ -320,8 +312,7 @@ function UploadBlankSlate(props: {
320
312
  />
321
313
  <BlankSlateTitle>Upload your design images.</BlankSlateTitle>
322
314
  <BlankSlateDescription>
323
- Once uploaded, you can generate{" "}
324
- {pluralize(sectionsNamingExperiment.value)} automatically using AI.
315
+ Once uploaded, you can generate slices automatically using AI.
325
316
  </BlankSlateDescription>
326
317
  <BlankSlateActions>
327
318
  <FileUploadButton
@@ -469,19 +460,15 @@ async function addSlices(newSlices: NewSlice[]) {
469
460
  return { library, slices };
470
461
  }
471
462
 
472
- const getSubmitButtonLabel = ({
473
- location,
474
- sectionsNamingExperiment,
475
- }: {
476
- location: "custom_type" | "page_type" | "slices";
477
- sectionsNamingExperiment: UseSectionsNamingExperimentReturnType;
478
- }) => {
463
+ const getSubmitButtonLabel = (
464
+ location: "custom_type" | "page_type" | "slices",
465
+ ) => {
479
466
  switch (location) {
480
467
  case "custom_type":
481
468
  return "Add to type";
482
469
  case "page_type":
483
470
  return "Add to page";
484
471
  case "slices":
485
- return `Add to ${pluralize(sectionsNamingExperiment.value)}`;
472
+ return "Add to slices";
486
473
  }
487
474
  };
@@ -9,9 +9,6 @@ import {
9
9
  } from "@prismicio/editor-ui";
10
10
  import { FC } from "react";
11
11
 
12
- import { useSectionsNamingExperiment } from "@/features/builder/useSectionsNamingExperiment";
13
- import { capitalizeFirstLetter, pluralize } from "@/utils/textConversion";
14
-
15
12
  import { getSliceCreationOptions } from "./sliceCreationOptions";
16
13
 
17
14
  export type SliceZoneBlankSlateProps = {
@@ -31,10 +28,8 @@ export const SliceZoneBlankSlate: FC<SliceZoneBlankSlateProps> = ({
31
28
  projectHasAvailableSlices,
32
29
  isSlicesTemplatesSupported,
33
30
  }) => {
34
- const sectionsNamingExperiment = useSectionsNamingExperiment();
35
31
  const sliceCreationOptions = getSliceCreationOptions({
36
32
  menuType: "ActionList",
37
- sectionsNamingExperiment,
38
33
  });
39
34
 
40
35
  return (
@@ -45,14 +40,11 @@ export const SliceZoneBlankSlate: FC<SliceZoneBlankSlateProps> = ({
45
40
  name="add"
46
41
  size="large"
47
42
  />
48
- <BlankSlateTitle size="big">
49
- Add {pluralize(sectionsNamingExperiment.value)}
50
- </BlankSlateTitle>
43
+ <BlankSlateTitle size="big">Add slices</BlankSlateTitle>
51
44
  <BlankSlateDescription>
52
- {pluralize(capitalizeFirstLetter(sectionsNamingExperiment.value))} are
53
- website sections that you can reuse on different pages with different
54
- content. Each on different pages with different content. Each{" "}
55
- {sectionsNamingExperiment.value} has its own component in your code.
45
+ Slices are website sections that you can reuse on different pages with
46
+ different content. Each on different pages with different content. Each{" "}
47
+ slice has its own component in your code.
56
48
  </BlankSlateDescription>
57
49
  <BlankSlateActions>
58
50
  <ActionList>
@@ -1,15 +1,11 @@
1
1
  import { BackgroundIcon } from "@prismicio/editor-ui";
2
2
 
3
- import { UseSectionsNamingExperimentReturnType } from "@/features/builder/useSectionsNamingExperiment";
4
- import { pluralize } from "@/utils/textConversion";
5
-
6
3
  type SliceCreationOptionArgs = {
7
4
  menuType: "ActionList" | "Dropdown";
8
- sectionsNamingExperiment: UseSectionsNamingExperimentReturnType;
9
5
  };
10
6
 
11
7
  export const getSliceCreationOptions = (args: SliceCreationOptionArgs) => {
12
- const { menuType, sectionsNamingExperiment } = args;
8
+ const { menuType } = args;
13
9
 
14
10
  return {
15
11
  fromImage: {
@@ -24,7 +20,7 @@ export const getSliceCreationOptions = (args: SliceCreationOptionArgs) => {
24
20
  />
25
21
  ),
26
22
  title: "Generate from image",
27
- description: `Build a ${sectionsNamingExperiment.value} based on your design image.`,
23
+ description: "Build a slice based on your design image.",
28
24
  },
29
25
  fromScratch: {
30
26
  BackgroundIcon: (
@@ -38,7 +34,7 @@ export const getSliceCreationOptions = (args: SliceCreationOptionArgs) => {
38
34
  />
39
35
  ),
40
36
  title: "Start from scratch",
41
- description: `Build a custom ${sectionsNamingExperiment.value} your way.`,
37
+ description: "Build a custom slice your way.",
42
38
  },
43
39
  fromTemplate: {
44
40
  BackgroundIcon: (
@@ -65,10 +61,8 @@ export const getSliceCreationOptions = (args: SliceCreationOptionArgs) => {
65
61
  radius={6}
66
62
  />
67
63
  ),
68
- title: `Reuse an existing ${sectionsNamingExperiment.value}`,
69
- description: `Select from your created ${pluralize(
70
- sectionsNamingExperiment.value,
71
- )}`,
64
+ title: "Reuse an existing slice",
65
+ description: "Select from your created slices.",
72
66
  },
73
67
  };
74
68
  };
@@ -5,10 +5,6 @@ import {
5
5
 
6
6
  import { managerClient } from "@/managerClient";
7
7
 
8
- type GetActiveEnvironmentArgs = {
9
- retried?: boolean;
10
- };
11
-
12
8
  type GetActiveEnvironmentReturnType =
13
9
  | {
14
10
  activeEnvironment: Environment;
@@ -20,10 +16,8 @@ type GetActiveEnvironmentReturnType =
20
16
  };
21
17
 
22
18
  export async function getActiveEnvironment(
23
- args?: GetActiveEnvironmentArgs,
19
+ retried = false,
24
20
  ): Promise<GetActiveEnvironmentReturnType> {
25
- const { retried = false } = args ?? {};
26
-
27
21
  try {
28
22
  const activeEnvironmentResult =
29
23
  await managerClient.project.fetchActiveEnvironment();
@@ -41,7 +35,7 @@ export async function getActiveEnvironment(
41
35
  await managerClient.project.updateEnvironment({ environment: undefined });
42
36
 
43
37
  // Call recursively with isRetry=true to prevent infinite loop if it fails again and again.
44
- return await getActiveEnvironment({ retried: true });
38
+ return await getActiveEnvironment(true);
45
39
  }
46
40
 
47
41
  return { error };
@@ -1,7 +1,14 @@
1
- import { useRequest } from "@prismicio/editor-support/Suspense";
1
+ import {
2
+ invalidateFetcherData,
3
+ useRequest,
4
+ } from "@prismicio/editor-support/Suspense";
2
5
 
3
6
  import { getActiveEnvironment } from "./actions/getActiveEnvironment";
4
7
 
8
+ export function invalidateActiveEnvironmentData() {
9
+ invalidateFetcherData(getActiveEnvironment);
10
+ }
11
+
5
12
  export function useActiveEnvironment() {
6
13
  return useRequest(getActiveEnvironment, []);
7
14
  }
@@ -1,7 +1,14 @@
1
- import { useRequest } from "@prismicio/editor-support/Suspense";
1
+ import {
2
+ invalidateFetcherData,
3
+ useRequest,
4
+ } from "@prismicio/editor-support/Suspense";
2
5
 
3
6
  import { getEnvironments } from "./actions/getEnvironments";
4
7
 
8
+ export function invalidateEnvironmentsData() {
9
+ invalidateFetcherData(getEnvironments);
10
+ }
11
+
5
12
  export function useEnvironments() {
6
13
  return useRequest(getEnvironments, []);
7
14
  }
@@ -13,11 +13,9 @@ import { useMarketingContent } from "@/hooks/useMarketingContent";
13
13
  import { FolderIcon } from "@/icons/FolderIcon";
14
14
  import { LightningIcon } from "@/icons/Lightning";
15
15
  import { MenuBookIcon } from "@/icons/MenuBookIcon";
16
- import { capitalizeFirstLetter, pluralize } from "@/utils/textConversion";
17
16
 
18
17
  import { ChangesItem } from "../../legacy/components/Navigation/ChangesItem";
19
18
  import { Environment } from "../../legacy/components/Navigation/Environment";
20
- import { useSectionsNamingExperiment } from "../builder/useSectionsNamingExperiment";
21
19
  import { NavigationItem } from "./NavigationItem";
22
20
  import { SliceMachineVersion } from "./SliceMachineVersion";
23
21
  import { UpdateInfo } from "./UpdateInfo";
@@ -26,7 +24,6 @@ export function Navigation() {
26
24
  const router = useRouter();
27
25
 
28
26
  const { documentationLink } = useMarketingContent();
29
- const sectionsNamingExperiment = useSectionsNamingExperiment();
30
27
  const adapter = useAdapterName();
31
28
 
32
29
  interface CustomTypeNavigationItemProps {
@@ -75,9 +72,7 @@ export function Navigation() {
75
72
  <CustomTypeNavigationItem type="custom" />
76
73
 
77
74
  <NavigationItem
78
- title={pluralize(
79
- capitalizeFirstLetter(sectionsNamingExperiment.value),
80
- )}
75
+ title="Slices"
81
76
  href="/slices"
82
77
  Icon={FolderIcon}
83
78
  active={router.asPath.startsWith("/slices")}
@@ -98,7 +93,6 @@ export function Navigation() {
98
93
  <OnboardingGuide />
99
94
  </Suspense>
100
95
  </ErrorBoundary>
101
-
102
96
  <NavigationItem
103
97
  title="Documentation"
104
98
  href={documentationLink}
@@ -4,7 +4,6 @@ import { AiOutlineExclamationCircle } from "react-icons/ai";
4
4
 
5
5
  import { countMissingScreenshots } from "@/domain/slice";
6
6
  import { ErrorBoundary } from "@/ErrorBoundary";
7
- import { useSectionsNamingExperiment } from "@/features/builder/useSectionsNamingExperiment";
8
7
  import { SharedSliceCard } from "@/features/slices/sliceCards/SharedSliceCard";
9
8
  import { ModelsStatuses } from "@/features/sync/getUnSyncChanges";
10
9
  import { useScreenshotChangesModal } from "@/hooks/useScreenshotChangesModal";
@@ -16,7 +15,6 @@ import { ComponentUI } from "@/legacy/lib/models/common/ComponentUI";
16
15
  import { LocalOrRemoteCustomType } from "@/legacy/lib/models/common/ModelData";
17
16
  import { ModelStatus } from "@/legacy/lib/models/common/ModelStatus";
18
17
  import { AuthStatus } from "@/modules/userContext/types";
19
- import { capitalizeFirstLetter, pluralize } from "@/utils/textConversion";
20
18
 
21
19
  import { DevCollaborationExperiment } from "./DevCollaborationExperiment";
22
20
 
@@ -36,7 +34,6 @@ export const ChangesItems: React.FC<ChangesItemsProps> = ({
36
34
  isOnline,
37
35
  }) => {
38
36
  const { modalPayload, onOpenModal } = useScreenshotChangesModal();
39
- const sectionsNamingExperiment = useSectionsNamingExperiment();
40
37
 
41
38
  const { sliceFilterFn, defaultVariationSelector } = modalPayload;
42
39
 
@@ -71,11 +68,7 @@ export const ChangesItems: React.FC<ChangesItemsProps> = ({
71
68
  <Box padding={{ bottom: 8 }}>
72
69
  <ChangesSectionHeader>
73
70
  <Box>
74
- <Text variant="h5">
75
- {pluralize(
76
- capitalizeFirstLetter(sectionsNamingExperiment.value),
77
- )}
78
- </Text>
71
+ <Text variant="h5">Slices</Text>
79
72
  <Text variant="h5" sx={{ marginLeft: 8 }}>
80
73
  {unSyncedSlices.length}
81
74
  </Text>
@@ -4,7 +4,6 @@ import Select from "react-select";
4
4
  import { Box, Label } from "theme-ui";
5
5
 
6
6
  import { getState } from "@/apiClient";
7
- import { useSectionsNamingExperiment } from "@/features/builder/useSectionsNamingExperiment";
8
7
  import { useOnboarding } from "@/features/onboarding/useOnboarding";
9
8
  import { createSlice } from "@/features/slices/actions/createSlice";
10
9
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
@@ -12,7 +11,6 @@ import ModalFormCard from "@/legacy/components/ModalFormCard";
12
11
  import { LibraryUI } from "@/legacy/lib/models/common/LibraryUI";
13
12
  import { SliceSM } from "@/legacy/lib/models/common/Slice";
14
13
  import useSliceMachineActions from "@/modules/useSliceMachineActions";
15
- import { capitalizeFirstLetter } from "@/utils/textConversion";
16
14
 
17
15
  import { InputBox } from "../components/InputBox";
18
16
  import { validateSliceModalValues } from "../formsValidator";
@@ -38,7 +36,6 @@ export const CreateSliceModal: FC<CreateSliceModalProps> = ({
38
36
  const [isCreatingSlice, setIsCreatingSlice] = useState(false);
39
37
  const { syncChanges } = useAutoSync();
40
38
  const { completeStep } = useOnboarding();
41
- const sectionsNamingExperiment = useSectionsNamingExperiment();
42
39
 
43
40
  const onSubmit = async (values: FormValues) => {
44
41
  const sliceName = values.sliceName;
@@ -82,17 +79,15 @@ export const CreateSliceModal: FC<CreateSliceModalProps> = ({
82
79
  validateSliceModalValues(values, localLibraries, remoteSlices)
83
80
  }
84
81
  content={{
85
- title: `Create a new ${sectionsNamingExperiment.value}`,
82
+ title: "Create a new slice",
86
83
  }}
87
84
  >
88
85
  {({ touched, values, setFieldValue, errors }) => (
89
86
  <Box>
90
87
  <InputBox
91
88
  name="sliceName"
92
- label={`${capitalizeFirstLetter(
93
- sectionsNamingExperiment.value,
94
- )} name`}
95
- placeholder={`Pascalised ${sectionsNamingExperiment.value} API ID (e.g. TextBlock)`}
89
+ label="Slice name"
90
+ placeholder="Pascalised slice API ID (e.g. TextBlock)"
96
91
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
97
92
  error={touched.sliceName ? errors.sliceName : undefined}
98
93
  testId="slice-name-input"
@@ -1,3 +1,4 @@
1
+ import { Box, Tooltip } from "@prismicio/editor-ui";
1
2
  import * as CSS from "csstype";
2
3
  import { IconType } from "react-icons";
3
4
  import { Flex, Text, Theme } from "theme-ui";
@@ -9,6 +10,7 @@ interface ItemHeaderProps {
9
10
  sliceFieldName: string | undefined;
10
11
  theme: Theme;
11
12
  WidgetIcon: IconType;
13
+ widgetIconTooltip: string;
12
14
  }
13
15
 
14
16
  const ItemHeader: React.FC<ItemHeaderProps> = ({
@@ -16,20 +18,24 @@ const ItemHeader: React.FC<ItemHeaderProps> = ({
16
18
  sliceFieldName,
17
19
  theme,
18
20
  WidgetIcon,
21
+ widgetIconTooltip,
19
22
  }) => (
20
23
  <Flex sx={{ alignItems: "center", position: "relative" }}>
21
- <WidgetIcon
22
- size={28}
23
- style={{
24
- color: theme.colors?.primary as CSS.Property.Color,
25
- marginRight: "8px",
26
- borderRadius: "4px",
27
- padding: "4px",
28
- border: "2px solid",
29
- borderColor: theme.colors?.primary as CSS.Property.Color,
30
- flexShrink: 0,
31
- }}
32
- />
24
+ <Tooltip content={widgetIconTooltip} sideOffset={2} disableHoverableContent>
25
+ <Box margin={{ right: 8 }}>
26
+ <WidgetIcon
27
+ size={28}
28
+ style={{
29
+ color: theme.colors?.primary as CSS.Property.Color,
30
+ borderRadius: "4px",
31
+ padding: "4px",
32
+ border: "2px solid",
33
+ borderColor: theme.colors?.primary as CSS.Property.Color,
34
+ flexShrink: 0,
35
+ }}
36
+ />
37
+ </Box>
38
+ </Tooltip>
33
39
  <TextWithTooltip
34
40
  text={text}
35
41
  as="p"
@@ -114,6 +114,7 @@ function ListItem<F extends TabField, S extends AnyObjectSchema>({
114
114
  renderFieldAccessor && renderFieldAccessor(key)
115
115
  }
116
116
  WidgetIcon={widget.Meta.icon}
117
+ widgetIconTooltip={widget.label}
117
118
  />
118
119
  <Flex sx={{ flex: "0 0 auto" }}>
119
120
  {shouldDisplayRepeatableBadge && (
@@ -13,8 +13,10 @@ import {
13
13
  Text,
14
14
  } from "theme-ui";
15
15
 
16
- import { checkAuthStatus, getState, startAuth } from "@/apiClient";
16
+ import { checkAuthStatus, clearAuth, getState } from "@/apiClient";
17
17
  import { getActiveEnvironment } from "@/features/environments/actions/getActiveEnvironment";
18
+ import { invalidateActiveEnvironmentData } from "@/features/environments/useActiveEnvironment";
19
+ import { invalidateEnvironmentsData } from "@/features/environments/useEnvironments";
18
20
  import { useAutoSync } from "@/features/sync/AutoSyncProvider";
19
21
  import { getUnSyncedChanges } from "@/features/sync/getUnSyncChanges";
20
22
  import SliceMachineModal from "@/legacy/components/SliceMachineModal";
@@ -50,7 +52,7 @@ const LoginModal: React.FunctionComponent = () => {
50
52
  }),
51
53
  );
52
54
  const { syncChanges } = useAutoSync();
53
- const { closeModals, startLoadingLogin, stopLoadingLogin } =
55
+ const { closeModals, startLoadingLogin, stopLoadingLogin, refreshState } =
54
56
  useSliceMachineActions();
55
57
 
56
58
  const prismicBase = preferWroomBase(env.manifest.apiEndpoint);
@@ -64,7 +66,7 @@ const LoginModal: React.FunctionComponent = () => {
64
66
 
65
67
  try {
66
68
  startLoadingLogin();
67
- await startAuth();
69
+ await clearAuth();
68
70
  window.open(loginRedirectUrl, "_blank");
69
71
  await startPolling<CheckAuthStatusResponse, ValidAuthStatus>(
70
72
  checkAuthStatus,
@@ -76,11 +78,17 @@ const LoginModal: React.FunctionComponent = () => {
76
78
  60,
77
79
  );
78
80
 
81
+ // refresh queries to update the UI
82
+ invalidateEnvironmentsData();
83
+ invalidateActiveEnvironmentData();
84
+
79
85
  toast.success("Logged in");
80
86
  stopLoadingLogin();
81
87
  closeModals();
82
88
 
83
89
  const serverState = await getState();
90
+ refreshState(serverState);
91
+
84
92
  const slices = normalizeFrontendSlices(
85
93
  serverState.libraries,
86
94
  serverState.remoteSlices,
@@ -18,6 +18,7 @@ import type { Environment } from "@slicemachine/manager/client";
18
18
  import { clsx } from "clsx";
19
19
  import type { FC, ReactNode } from "react";
20
20
 
21
+ import { LogoutButton } from "@/features/auth/LogoutButton";
21
22
  import { LoginIcon } from "@/icons/LoginIcon";
22
23
  import { LogoIcon } from "@/icons/LogoIcon";
23
24
 
@@ -138,6 +139,8 @@ export const SideNavEnvironmentSelector: FC<SideNavEnvironmentSelectorProps> = (
138
139
  }
139
140
  />
140
141
  ) : undefined}
142
+
143
+ {variant === "default" && <LogoutButton />}
141
144
  </Box>
142
145
  </>
143
146
  )}