slice-machine-ui 1.19.3-dev-next-release.3 → 1.19.3-dev-environments.6

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 (80) hide show
  1. package/components/AppLayout/index.tsx +34 -10
  2. package/components/Navigation/Environment.tsx +47 -0
  3. package/components/Navigation/index.css.ts +6 -0
  4. package/components/Navigation/index.tsx +15 -2
  5. package/lib/builders/SliceBuilder/Sidebar/{AddVariationModal.tsx → VariationModal.tsx} +3 -3
  6. package/lib/builders/SliceBuilder/Sidebar/index.tsx +13 -52
  7. package/lib/builders/SliceBuilder/index.tsx +27 -31
  8. package/out/404.html +1 -1
  9. package/out/_next/static/{0Lwj5aWsM8JhkX_oWgDHj → SPaOafYlpiOTCKrKML7gk}/_buildManifest.js +1 -1
  10. package/out/_next/static/chunks/840-5b485c737b24324b.js +1 -0
  11. package/out/_next/static/chunks/904-e290f0254cc4b5df.js +1 -0
  12. package/out/_next/static/chunks/{958-c90d60818f1c468a.js → 958-be627006594efb21.js} +1 -1
  13. package/out/_next/static/chunks/pages/{_app-d42e615a839b8752.js → _app-2af35c541ee1bab0.js} +7 -7
  14. package/out/_next/static/chunks/pages/{changelog-fa36b9995c26e1d7.js → changelog-4b8369d91d82b28b.js} +1 -1
  15. package/out/_next/static/chunks/pages/changes-db6e8c6be5ae076e.js +1 -0
  16. package/out/_next/static/chunks/pages/labs-2922105ab714d32a.js +1 -0
  17. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ca780766d02c801b.js +1 -0
  18. package/out/_next/static/chunks/pages/slices-93b7af2624c85b8e.js +1 -0
  19. package/out/_next/static/css/{412af4286eb0b283.css → 009bd7f5ac85fc6a.css} +1 -1
  20. package/out/changelog.html +1 -1
  21. package/out/changes.html +1 -1
  22. package/out/custom-types/[customTypeId].html +1 -1
  23. package/out/custom-types.html +1 -1
  24. package/out/index.html +1 -1
  25. package/out/labs.html +1 -1
  26. package/out/page-types/[pageTypeId].html +1 -1
  27. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  28. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  29. package/out/slices.html +1 -1
  30. package/package.json +4 -4
  31. package/pages/slices.tsx +1 -0
  32. package/src/apiClient.ts +4 -32
  33. package/src/components/Divider/Divider.css.ts +31 -0
  34. package/src/components/Divider/Divider.stories.tsx +27 -0
  35. package/src/components/Divider/Divider.tsx +25 -0
  36. package/src/components/Divider/index.ts +1 -0
  37. package/src/components/PageLayout/PageLayout.css.ts +8 -3
  38. package/src/components/PageLayout/PageLayout.stories.tsx +10 -1
  39. package/src/components/PageLayout/PageLayout.tsx +7 -2
  40. package/src/components/SideNav/SideNav.css.ts +3 -10
  41. package/src/components/SideNav/SideNav.stories.tsx +29 -2
  42. package/src/components/SideNav/SideNav.tsx +5 -1
  43. package/src/components/SideNav/SideNavEnvironmentSelector.css.ts +69 -0
  44. package/src/components/SideNav/SideNavEnvironmentSelector.tsx +163 -0
  45. package/src/components/SideNav/index.ts +1 -0
  46. package/src/features/customTypes/__tests__/CustomTypeBuilderPage.test.tsx +4 -3
  47. package/src/features/environments/actions/getActiveEnvironmentDomain.ts +11 -0
  48. package/src/features/environments/actions/getEnvironments.ts +12 -0
  49. package/src/features/environments/actions/setEnvironment.ts +18 -0
  50. package/src/features/environments/useActiveEnvironment.ts +38 -0
  51. package/src/features/environments/useEnvironments.ts +7 -0
  52. package/src/features/legacyState/actions/getLegacySliceMachineState.ts +53 -0
  53. package/src/features/legacyState/useLegacySliceMachineState.ts +7 -0
  54. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +4 -3
  55. package/src/features/slices/sliceCards/SharedSliceCard.tsx +17 -44
  56. package/src/modules/environment/index.ts +2 -2
  57. package/src/modules/screenshots/sagas.ts +6 -3
  58. package/src/modules/selectedSlice/actions.ts +2 -7
  59. package/src/modules/selectedSlice/reducer.ts +1 -6
  60. package/src/modules/selectedSlice/sagas.ts +18 -10
  61. package/src/modules/slices/index.ts +1 -23
  62. package/src/modules/toaster/utils.tsx +12 -6
  63. package/src/modules/useSliceMachineActions.ts +3 -9
  64. package/test/pages/slices.test.tsx +4 -8
  65. package/test/src/modules/__fixtures__/serverState.ts +2 -0
  66. package/test/src/modules/selectedSlice/sagas.test.ts +12 -14
  67. package/test/src/modules/toaster/utils.test.ts +34 -3
  68. package/components/DeleteVariationModal/index.tsx +0 -83
  69. package/components/Forms/RenameVariationModal/RenameVariationModal.css.ts +0 -7
  70. package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +0 -117
  71. package/components/Forms/RenameVariationModal/index.ts +0 -1
  72. package/out/_next/static/chunks/840-884e41a48b92e5d3.js +0 -1
  73. package/out/_next/static/chunks/904-69cc3c4be2bff626.js +0 -1
  74. package/out/_next/static/chunks/pages/changes-e388be4457a43c3a.js +0 -1
  75. package/out/_next/static/chunks/pages/labs-ebce03a4e7a95a4e.js +0 -1
  76. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-7c811c2c79f01a25.js +0 -1
  77. package/out/_next/static/chunks/pages/slices-22db04643850c1d8.js +0 -1
  78. package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +0 -86
  79. package/src/features/slices/sliceBuilder/actions/renameVariation.ts +0 -80
  80. /package/out/_next/static/{0Lwj5aWsM8JhkX_oWgDHj → SPaOafYlpiOTCKrKML7gk}/_ssgManifest.js +0 -0
@@ -1,86 +0,0 @@
1
- import type { NextRouter } from "next/router";
2
- import type { Dispatch, SetStateAction } from "react";
3
-
4
- import type { SliceBuilderState } from "@builders/SliceBuilder";
5
- import { SliceToastMessage } from "@components/ToasterContainer";
6
- import type { ComponentUI } from "@lib/models/common/ComponentUI";
7
- import type { VariationSM } from "@lib/models/common/Slice";
8
- import {
9
- deleteSliceVariation,
10
- readSlice,
11
- readSliceMocks,
12
- updateSlice,
13
- } from "@src/apiClient";
14
- import { SLICES_CONFIG } from "@src/features/slices/slicesConfig";
15
-
16
- type DeleteVariationArgs = {
17
- component: ComponentUI;
18
- router: NextRouter;
19
- setSliceBuilderState: Dispatch<SetStateAction<SliceBuilderState>>;
20
- updateAndSaveSlice: (component: ComponentUI) => void;
21
- variation: VariationSM;
22
- };
23
-
24
- export async function deleteVariation(
25
- args: DeleteVariationArgs,
26
- ): Promise<void> {
27
- args.setSliceBuilderState({ loading: true, done: false });
28
-
29
- try {
30
- // The slice may have been edited so we need to update the file system.
31
- const { errors: updateSliceErrors } = await updateSlice(args.component);
32
- if (updateSliceErrors.length > 0) {
33
- throw updateSliceErrors;
34
- }
35
-
36
- // Now, delete the variation and save the slice.
37
- const { errors: deleteSliceVariationErrors } = await deleteSliceVariation({
38
- libraryID: args.component.from,
39
- sliceID: args.component.model.id,
40
- variationID: args.variation.id,
41
- });
42
- if (deleteSliceVariationErrors.length > 0) {
43
- throw deleteSliceVariationErrors;
44
- }
45
- const { slice, errors: readSliceErrors } = await readSlice(
46
- args.component.from,
47
- args.component.model.id,
48
- );
49
- if (!slice || readSliceErrors.length > 0) {
50
- throw readSliceErrors;
51
- }
52
- const { mocks } = await readSliceMocks({
53
- libraryID: args.component.from,
54
- sliceID: args.component.model.id,
55
- });
56
- const url = SLICES_CONFIG.getBuilderPagePathname({
57
- libraryName: args.component.href,
58
- sliceName: slice.name,
59
- variationId: slice.variations[0].id,
60
- });
61
- await args.router.replace(url);
62
- args.updateAndSaveSlice({ ...args.component, model: slice, mocks });
63
-
64
- // Finally, display a success toast.
65
- const path = `${args.component.from}/${args.component.model.name}/model.json`;
66
- args.setSliceBuilderState({
67
- loading: false,
68
- done: true,
69
- error: false,
70
- message: SliceToastMessage({ path }),
71
- });
72
- } catch (error) {
73
- const message = `Could not delete variation \`${args.variation.name}\``;
74
- console.error(message, error);
75
-
76
- // Display a failure toast.
77
- args.setSliceBuilderState({
78
- loading: false,
79
- done: true,
80
- error: true,
81
- message,
82
- });
83
-
84
- throw error;
85
- }
86
- }
@@ -1,80 +0,0 @@
1
- import type { Dispatch, SetStateAction } from "react";
2
-
3
- import type { SliceBuilderState } from "@builders/SliceBuilder";
4
- import { SliceToastMessage } from "@components/ToasterContainer";
5
- import type { ComponentUI } from "@lib/models/common/ComponentUI";
6
- import type { VariationSM } from "@lib/models/common/Slice";
7
- import {
8
- readSlice,
9
- readSliceMocks,
10
- renameSliceVariation,
11
- updateSlice,
12
- } from "@src/apiClient";
13
-
14
- type RenameVariationArgs = {
15
- component: ComponentUI;
16
- setSliceBuilderState: Dispatch<SetStateAction<SliceBuilderState>>;
17
- updateAndSaveSlice: (component: ComponentUI) => void;
18
- variation: VariationSM;
19
- variationName: string;
20
- };
21
-
22
- export async function renameVariation(
23
- args: RenameVariationArgs,
24
- ): Promise<void> {
25
- args.setSliceBuilderState({ loading: true, done: false });
26
-
27
- try {
28
- // The slice may have been edited so we need to update the file system.
29
- const { errors: updateSliceErrors } = await updateSlice(args.component);
30
- if (updateSliceErrors.length > 0) {
31
- throw updateSliceErrors;
32
- }
33
-
34
- // Now, rename the variation and save the slice.
35
- const { errors: renameSliceVariationErrors } = await renameSliceVariation(
36
- args.component,
37
- { ...args.variation, name: args.variationName },
38
- );
39
- if (renameSliceVariationErrors.length > 0) {
40
- throw renameSliceVariationErrors;
41
- }
42
- const { slice, errors: readSliceErrors } = await readSlice(
43
- args.component.from,
44
- args.component.model.id,
45
- );
46
- if (readSliceErrors.length > 0) {
47
- throw readSliceErrors;
48
- }
49
- if (!slice) {
50
- throw new Error(`Could not read variation \`${args.variation.name}\``);
51
- }
52
- const { mocks } = await readSliceMocks({
53
- libraryID: args.component.from,
54
- sliceID: args.component.model.id,
55
- });
56
- args.updateAndSaveSlice({ ...args.component, model: slice, mocks });
57
-
58
- // Finally, display a success toast.
59
- const path = `${args.component.from}/${args.component.model.name}/model.json`;
60
- args.setSliceBuilderState({
61
- loading: false,
62
- done: true,
63
- error: false,
64
- message: SliceToastMessage({ path }),
65
- });
66
- } catch (error) {
67
- const message = `Could not rename variation \`${args.variation.name}\``;
68
- console.error(message, error);
69
-
70
- // Display a failure toast.
71
- args.setSliceBuilderState({
72
- loading: false,
73
- done: true,
74
- error: true,
75
- message,
76
- });
77
-
78
- throw error;
79
- }
80
- }