@applicaster/zapp-react-native-utils 15.1.6-alpha.3988508055 → 15.1.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.
- package/actionsExecutor/ActionExecutorContext.tsx +0 -4
- package/actionsExecutor/actions/__tests__/showToast.test.ts +25 -3
- package/actionsExecutor/actions/index.ts +0 -4
- package/actionsExecutor/actions/refreshComponent.ts +0 -6
- package/actionsExecutor/actions/showToast.ts +7 -5
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/actionsExecutor/types.ts +3 -5
- package/modalState/index.ts +83 -30
- package/package.json +2 -2
- package/reactHooks/layout/index.ts +1 -1
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +0 -22
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +0 -88
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +0 -76
- package/actionsExecutor/actions/dismissBottomSheet.ts +0 -22
- package/actionsExecutor/actions/openBottomSheet.ts +0 -318
- package/modalState/ContentViewModel.ts +0 -111
- package/modalState/EditableCollection.ts +0 -17
- package/modalState/EditableCollectionRegistry.ts +0 -51
- package/modalState/ModalOrchestrator.ts +0 -198
- package/modalState/RemoteEditableCollection.ts +0 -189
- package/modalState/__tests__/ContentViewModel.editable.test.ts +0 -69
- package/modalState/__tests__/ContentViewModel.test.ts +0 -165
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +0 -112
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +0 -28
- package/modalState/__tests__/RemoteEditableCollection.test.ts +0 -259
- package/modalState/__tests__/useBottomSheetContent.test.ts +0 -372
- package/modalState/store.ts +0 -102
- package/modalState/types.ts +0 -110
- package/modalState/useBottomSheetContent.ts +0 -98
|
@@ -19,11 +19,9 @@ import {
|
|
|
19
19
|
appRestartAction,
|
|
20
20
|
confirmDialogAction,
|
|
21
21
|
createNavigateToScreenAction,
|
|
22
|
-
dismissBottomSheetAction,
|
|
23
22
|
localStorageRemoveAction,
|
|
24
23
|
localStorageSetAction,
|
|
25
24
|
localStorageToggleFlagAction,
|
|
26
|
-
openBottomSheetAction,
|
|
27
25
|
refreshComponentAction,
|
|
28
26
|
screenSetVariableAction,
|
|
29
27
|
screenToggleFlagAction,
|
|
@@ -92,8 +90,6 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
92
90
|
|
|
93
91
|
actionExecutor.registerAction("screenSetVariable", screenSetVariableAction);
|
|
94
92
|
actionExecutor.registerAction("screenToggleFlag", screenToggleFlagAction);
|
|
95
|
-
actionExecutor.registerAction("openBottomSheet", openBottomSheetAction);
|
|
96
|
-
actionExecutor.registerAction("dismissBottomSheet", dismissBottomSheetAction);
|
|
97
93
|
actionExecutor.registerAction("showToast", showToastAction);
|
|
98
94
|
};
|
|
99
95
|
|
|
@@ -11,14 +11,13 @@ describe("showToastAction", () => {
|
|
|
11
11
|
jest.clearAllMocks();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it("calls postEvent with
|
|
14
|
+
it("calls postEvent with the provided options and returns Success", async () => {
|
|
15
15
|
const action = {
|
|
16
16
|
type: "showToast",
|
|
17
17
|
options: {
|
|
18
18
|
id: "toast-1",
|
|
19
19
|
message: "Added to queue",
|
|
20
20
|
extraMessage: "Extra info",
|
|
21
|
-
timeout: 3000,
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
|
|
@@ -32,13 +31,36 @@ describe("showToastAction", () => {
|
|
|
32
31
|
message: "Added to queue",
|
|
33
32
|
extraMessage: "Extra info",
|
|
34
33
|
style: undefined,
|
|
35
|
-
timeout:
|
|
34
|
+
timeout: undefined,
|
|
36
35
|
},
|
|
37
36
|
]);
|
|
38
37
|
|
|
39
38
|
expect(result).toBe(ActionResult.Success);
|
|
40
39
|
});
|
|
41
40
|
|
|
41
|
+
it("preserves an explicit timeout and style override", async () => {
|
|
42
|
+
const action = {
|
|
43
|
+
type: "showToast",
|
|
44
|
+
options: {
|
|
45
|
+
message: "Playlist created",
|
|
46
|
+
timeout: 3000,
|
|
47
|
+
style: { backgroundColor: "#00FF00" },
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
await showToastAction(action);
|
|
52
|
+
|
|
53
|
+
expect(postEvent).toHaveBeenCalledWith("showToast", [
|
|
54
|
+
{
|
|
55
|
+
id: undefined,
|
|
56
|
+
message: "Playlist created",
|
|
57
|
+
extraMessage: undefined,
|
|
58
|
+
style: { backgroundColor: "#00FF00" },
|
|
59
|
+
timeout: 3000,
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
|
|
42
64
|
it("handles missing or empty options without throwing", async () => {
|
|
43
65
|
const action = {
|
|
44
66
|
type: "showToast",
|
|
@@ -28,7 +28,3 @@ export { screenToggleFlagAction } from "./screenToggleFlag";
|
|
|
28
28
|
export { createNavigateToScreenAction } from "./navigateToScreen";
|
|
29
29
|
|
|
30
30
|
export { showToastAction } from "./showToast";
|
|
31
|
-
|
|
32
|
-
export { openBottomSheetAction } from "./openBottomSheet";
|
|
33
|
-
|
|
34
|
-
export { dismissBottomSheetAction } from "./dismissBottomSheet";
|
|
@@ -82,12 +82,6 @@ export const refreshComponentAction: ActionHandler = async (
|
|
|
82
82
|
}) || source;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
if (!dataSource) {
|
|
86
|
-
log_info("handleAction: refreshComponent skipped: no dataSource found");
|
|
87
|
-
|
|
88
|
-
return ActionResult.Success;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
85
|
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
|
|
92
86
|
source,
|
|
93
87
|
inflatedUrl: dataSource,
|
|
@@ -17,13 +17,15 @@ export interface ShowToastActionOptions {
|
|
|
17
17
|
export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
|
|
18
18
|
action
|
|
19
19
|
): Promise<ActionResult> => {
|
|
20
|
+
const options = action?.options;
|
|
21
|
+
|
|
20
22
|
postEvent("showToast", [
|
|
21
23
|
{
|
|
22
|
-
id:
|
|
23
|
-
message:
|
|
24
|
-
extraMessage:
|
|
25
|
-
style:
|
|
26
|
-
timeout:
|
|
24
|
+
id: options?.id,
|
|
25
|
+
message: options?.message,
|
|
26
|
+
extraMessage: options?.extraMessage,
|
|
27
|
+
style: options?.style,
|
|
28
|
+
timeout: options?.timeout,
|
|
27
29
|
},
|
|
28
30
|
]);
|
|
29
31
|
|
|
@@ -27,7 +27,7 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
const behavior = {
|
|
30
|
-
...feed.extensions?.behavior,
|
|
30
|
+
...feed.extensions?.["behavior"],
|
|
31
31
|
select_mode: "multi",
|
|
32
32
|
current_selection: `@{${scope}/${key}}`,
|
|
33
33
|
};
|
|
@@ -75,7 +75,7 @@ function makeSingleSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
const behavior = {
|
|
78
|
-
...feed.extensions?.behavior,
|
|
78
|
+
...feed.extensions?.["behavior"],
|
|
79
79
|
select_mode: "single",
|
|
80
80
|
current_selection: `@{${scope}/${key}}`,
|
|
81
81
|
};
|
|
@@ -141,11 +141,11 @@ function makeSingleSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export const decorateFeed = (feed: ZappFeed) => {
|
|
144
|
-
if (!(feed.extensions?.role === "preference_editor")) {
|
|
144
|
+
if (!(feed.extensions?.["role"] === "preference_editor")) {
|
|
145
145
|
return feed;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const key = feed.extensions?.preference_editor_options?.key;
|
|
148
|
+
const key = feed.extensions?.["preference_editor_options"]?.["key"];
|
|
149
149
|
|
|
150
150
|
if (!key) {
|
|
151
151
|
log_error(
|
|
@@ -160,8 +160,8 @@ export const decorateFeed = (feed: ZappFeed) => {
|
|
|
160
160
|
const decoratedFeed = R.clone(feed);
|
|
161
161
|
|
|
162
162
|
const isSingleSelect =
|
|
163
|
-
(feed.extensions?.preference_editor_options?.select_mode ||
|
|
164
|
-
feed.extensions?.behavior?.select_mode) === "single";
|
|
163
|
+
(feed.extensions?.["preference_editor_options"]?.select_mode ||
|
|
164
|
+
feed.extensions?.["behavior"]?.select_mode) === "single";
|
|
165
165
|
|
|
166
166
|
if (isSingleSelect) {
|
|
167
167
|
return makeSingleSelect(feed, key, decoratedFeed);
|
package/actionsExecutor/types.ts
CHANGED
|
@@ -16,10 +16,8 @@ export interface ActionExecutionContext {
|
|
|
16
16
|
/** The entry that defines the screen (if screen was opened from an entry) */
|
|
17
17
|
screenEntry?: ZappEntry;
|
|
18
18
|
|
|
19
|
-
/** The UI component that triggered the action
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
component?: ZappUIComponent & { parent?: ZappUIComponent };
|
|
19
|
+
/** The UI component that triggered the action */
|
|
20
|
+
component?: ZappUIComponent;
|
|
23
21
|
|
|
24
22
|
/** The route identifier for the current screen */
|
|
25
23
|
screenRoute?: string;
|
|
@@ -33,7 +31,7 @@ export interface ActionExecutionContext {
|
|
|
33
31
|
/** Callback function for action completion */
|
|
34
32
|
callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
|
|
35
33
|
|
|
36
|
-
screenState
|
|
34
|
+
screenState: Record<any, any>;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
/**
|
package/modalState/index.ts
CHANGED
|
@@ -1,30 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { useStore, createStore } from "zustand";
|
|
2
|
+
|
|
3
|
+
interface ModalState {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
screen: any;
|
|
6
|
+
options: Record<string, unknown>;
|
|
7
|
+
props: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ModalStore {
|
|
11
|
+
modalState: ModalState;
|
|
12
|
+
setModalState: (newState: Partial<ModalState>) => void;
|
|
13
|
+
openModal: (
|
|
14
|
+
item: any,
|
|
15
|
+
options?: Record<string, unknown>,
|
|
16
|
+
props?: Record<string, unknown>
|
|
17
|
+
) => void;
|
|
18
|
+
dismissModal: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const initialModalState: ModalState = {
|
|
22
|
+
visible: false,
|
|
23
|
+
screen: null,
|
|
24
|
+
options: {},
|
|
25
|
+
props: {},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const modalStore = createStore<ModalStore>((set) => ({
|
|
29
|
+
modalState: initialModalState,
|
|
30
|
+
setModalState: (newState) =>
|
|
31
|
+
set((state) => ({
|
|
32
|
+
modalState: { ...state.modalState, ...newState },
|
|
33
|
+
})),
|
|
34
|
+
openModal: ({ item, options = {}, props }: OpenModalArg) =>
|
|
35
|
+
set({
|
|
36
|
+
modalState: {
|
|
37
|
+
visible: true,
|
|
38
|
+
screen: item,
|
|
39
|
+
options: {
|
|
40
|
+
animated: true,
|
|
41
|
+
animationType: "slide",
|
|
42
|
+
onShow: () => {},
|
|
43
|
+
presentationStyle: "overFullScreen",
|
|
44
|
+
transparent: true,
|
|
45
|
+
...options,
|
|
46
|
+
onDismiss: () => set({ modalState: initialModalState }),
|
|
47
|
+
onRequestClose: () => set({ modalState: initialModalState }),
|
|
48
|
+
},
|
|
49
|
+
props,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
dismissModal: () => set(() => ({ modalState: initialModalState })),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
export const useModalStore = <T>(selector: (state: ModalStore) => T) =>
|
|
56
|
+
useStore(modalStore, selector);
|
|
57
|
+
|
|
58
|
+
export const openModal = modalStore.getInitialState().openModal;
|
|
59
|
+
|
|
60
|
+
export const dismissModal = modalStore.getInitialState().dismissModal;
|
|
61
|
+
|
|
62
|
+
export const openBottomSheetModal = ({
|
|
63
|
+
ModalBottomSheetContent,
|
|
64
|
+
modalBottomSheetContentProps,
|
|
65
|
+
props = {},
|
|
66
|
+
options = {},
|
|
67
|
+
}: OpenModalBottomSheetArgs) => {
|
|
68
|
+
openModal({
|
|
69
|
+
item: {
|
|
70
|
+
ModalBottomSheetContent,
|
|
71
|
+
modalBottomSheetContentProps,
|
|
72
|
+
},
|
|
73
|
+
props,
|
|
74
|
+
options: {
|
|
75
|
+
animationType: "none",
|
|
76
|
+
animated: false,
|
|
77
|
+
...options,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const useModalStoreState = (): ModalState =>
|
|
83
|
+
useModalStore<ModalState>((state) => state.modalState);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "15.1.6
|
|
3
|
+
"version": "15.1.6",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "15.1.6
|
|
30
|
+
"@applicaster/applicaster-types": "15.1.6",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { dismissBottomSheetAction } from "../dismissBottomSheet";
|
|
2
|
-
import { dismissModal } from "../../../modalState";
|
|
3
|
-
import { ActionResult } from "../../ActionExecutor";
|
|
4
|
-
|
|
5
|
-
jest.mock("../../../modalState", () => ({
|
|
6
|
-
dismissModal: jest.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
describe("dismissBottomSheetAction", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("calls dismissModal and returns ActionResult.Success", async () => {
|
|
15
|
-
const result = await dismissBottomSheetAction({
|
|
16
|
-
type: "dismissBottomSheet",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
expect(dismissModal).toHaveBeenCalledTimes(1);
|
|
20
|
-
expect(result).toBe(ActionResult.Success);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { loadItemsFromSource } from "../openBottomSheet";
|
|
2
|
-
|
|
3
|
-
const mockCall = jest.fn();
|
|
4
|
-
|
|
5
|
-
jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
|
|
6
|
-
RequestBuilder: jest.fn().mockImplementation(() => ({
|
|
7
|
-
setEntryContext: jest.fn().mockReturnThis(),
|
|
8
|
-
setScreenContext: jest.fn().mockReturnThis(),
|
|
9
|
-
setUrl: jest.fn().mockReturnThis(),
|
|
10
|
-
buildAxiosRequest: jest.fn().mockResolvedValue(undefined),
|
|
11
|
-
call: (...args: any[]) => mockCall(...args),
|
|
12
|
-
})),
|
|
13
|
-
PipesClientResponseHelper: jest.fn().mockImplementation(() => ({
|
|
14
|
-
error: null,
|
|
15
|
-
})),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
describe("loadItemsFromSource", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
jest.clearAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("returns items plus role and behavior from feed.extensions", async () => {
|
|
24
|
-
mockCall.mockResolvedValueOnce({
|
|
25
|
-
response: {
|
|
26
|
-
entry: [{ id: "a", title: "Playlist A", media_group: [] }],
|
|
27
|
-
extensions: {
|
|
28
|
-
role: "collection_selector",
|
|
29
|
-
behavior: {
|
|
30
|
-
select_mode: "multi",
|
|
31
|
-
current_selection: ["a"],
|
|
32
|
-
selector: "extensions.tag",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const result = await loadItemsFromSource("https://example.com/feed");
|
|
39
|
-
|
|
40
|
-
expect(result.role).toBe("collection_selector");
|
|
41
|
-
|
|
42
|
-
expect(result.behavior).toEqual({
|
|
43
|
-
selectMode: "multi",
|
|
44
|
-
currentSelection: ["a"],
|
|
45
|
-
selector: "extensions.tag",
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
expect(result.items).toHaveLength(1);
|
|
49
|
-
expect(result.items[0].isSelected).toBe(true);
|
|
50
|
-
expect(result.items[0].title).toBe("Playlist A");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("returns undefined role/behavior when feed has no extensions", async () => {
|
|
54
|
-
mockCall.mockResolvedValueOnce({
|
|
55
|
-
response: {
|
|
56
|
-
entry: [{ id: "1", title: "Plain", media_group: [] }],
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const result = await loadItemsFromSource("https://example.com/plain");
|
|
61
|
-
|
|
62
|
-
expect(result.role).toBeUndefined();
|
|
63
|
-
expect(result.behavior).toBeUndefined();
|
|
64
|
-
expect(result.items).toHaveLength(1);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("preserves events in dynamic_collection_options", async () => {
|
|
68
|
-
mockCall.mockResolvedValueOnce({
|
|
69
|
-
response: {
|
|
70
|
-
entry: [],
|
|
71
|
-
extensions: {
|
|
72
|
-
dynamic_collection_options: {
|
|
73
|
-
operations: "add,remove",
|
|
74
|
-
events: {
|
|
75
|
-
add: [{ type: "showTextInput", options: {} }],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const result = await loadItemsFromSource("https://example.com/feed");
|
|
83
|
-
|
|
84
|
-
expect(result.dynamicCollection?.events).toEqual({
|
|
85
|
-
add: [{ type: "showTextInput", options: {} }],
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { openBottomSheetAction } from "../openBottomSheet";
|
|
2
|
-
import { ActionResult } from "../../ActionExecutor";
|
|
3
|
-
import { openBottomSheetModal } from "../../../modalState/store";
|
|
4
|
-
import { modalOrchestrator } from "../../../modalState/ModalOrchestrator";
|
|
5
|
-
|
|
6
|
-
jest.mock("../../../modalState/store", () => ({
|
|
7
|
-
openBottomSheetModal: jest.fn(),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock("../../../modalState/ModalOrchestrator", () => ({
|
|
11
|
-
modalOrchestrator: {
|
|
12
|
-
open: jest.fn(),
|
|
13
|
-
},
|
|
14
|
-
isPresentSubMenuAction: jest.requireActual("../../../modalState/types")
|
|
15
|
-
.isPresentSubMenuAction,
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
describe("openBottomSheetAction custom content", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
jest.clearAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("opens default sheet with contentComponent body props", async () => {
|
|
24
|
-
const CustomContent = function CustomContent() {
|
|
25
|
-
return null;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const result = await openBottomSheetAction({
|
|
29
|
-
type: "openBottomSheet",
|
|
30
|
-
options: {
|
|
31
|
-
header: { title: "Create Playlist" },
|
|
32
|
-
content: {
|
|
33
|
-
component: CustomContent,
|
|
34
|
-
props: {
|
|
35
|
-
inputLabel: "Name your playlist",
|
|
36
|
-
buttonLabel: "Create",
|
|
37
|
-
defaultValue: "",
|
|
38
|
-
submitAction: { type: "sendCloudEvent", options: {} },
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
} as any);
|
|
43
|
-
|
|
44
|
-
expect(result).toBe(ActionResult.Success);
|
|
45
|
-
expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
|
|
46
|
-
expect(modalOrchestrator.open).not.toHaveBeenCalled();
|
|
47
|
-
|
|
48
|
-
const args = (openBottomSheetModal as jest.Mock).mock.calls[0][0];
|
|
49
|
-
// Default ModalComponent provides the standard header
|
|
50
|
-
expect(args.ModalBottomSheetContent).toBeUndefined();
|
|
51
|
-
|
|
52
|
-
expect(args.modalBottomSheetContentProps).toMatchObject({
|
|
53
|
-
title: "Create Playlist",
|
|
54
|
-
contentComponent: CustomContent,
|
|
55
|
-
contentComponentProps: {
|
|
56
|
-
inputLabel: "Name your playlist",
|
|
57
|
-
buttonLabel: "Create",
|
|
58
|
-
defaultValue: "",
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("returns Error when neither list data nor content.component is provided", async () => {
|
|
64
|
-
const result = await openBottomSheetAction({
|
|
65
|
-
type: "openBottomSheet",
|
|
66
|
-
options: {
|
|
67
|
-
header: { title: "Empty" },
|
|
68
|
-
content: {},
|
|
69
|
-
},
|
|
70
|
-
} as any);
|
|
71
|
-
|
|
72
|
-
expect(result).toBe(ActionResult.Error);
|
|
73
|
-
expect(openBottomSheetModal).not.toHaveBeenCalled();
|
|
74
|
-
expect(modalOrchestrator.open).not.toHaveBeenCalled();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="@applicaster/applicaster-types" />
|
|
2
|
-
import { dismissModal } from "../../modalState";
|
|
3
|
-
import { ActionResult } from "../ActionExecutor";
|
|
4
|
-
import { ActionHandler } from "../types";
|
|
5
|
-
import { createLogger } from "../../logger";
|
|
6
|
-
|
|
7
|
-
const { log_info } = createLogger({
|
|
8
|
-
subsystem: "ActionExecutorContext",
|
|
9
|
-
category: "General",
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Dismisses the active bottom sheet / modal.
|
|
14
|
-
*/
|
|
15
|
-
export const dismissBottomSheetAction: ActionHandler<
|
|
16
|
-
any
|
|
17
|
-
> = async (): Promise<ActionResult> => {
|
|
18
|
-
log_info("handleAction: dismissBottomSheet");
|
|
19
|
-
dismissModal();
|
|
20
|
-
|
|
21
|
-
return ActionResult.Success;
|
|
22
|
-
};
|