@applicaster/zapp-react-native-utils 16.0.0-rc.90 → 16.0.0-rc.91
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/configurationUtils/__tests__/modalBlocksParser.test.ts +33 -85
- package/configurationUtils/modalBlocksParser.ts +10 -106
- package/entryActions/__tests__/buildEntryActions.test.ts +58 -18
- package/entryActions/aliasPresentation.ts +26 -42
- package/entryActions/index.ts +0 -2
- package/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getEmptyModalBlocksStructure,
|
|
3
|
+
parseModalBlocksConfiguration,
|
|
4
|
+
} from "../modalBlocksParser";
|
|
2
5
|
|
|
3
6
|
// Mock the platform selection logic so it's consistent
|
|
4
7
|
jest.mock("../../reactUtils", () => ({
|
|
@@ -151,110 +154,55 @@ describe("parseModalBlocksConfiguration", () => {
|
|
|
151
154
|
);
|
|
152
155
|
});
|
|
153
156
|
|
|
154
|
-
it("should map
|
|
157
|
+
it("should ignore keys that do not map to a known block sub-component", () => {
|
|
155
158
|
const result = parseModalBlocksConfiguration(
|
|
156
159
|
{
|
|
157
160
|
"button.create_new_playlist_asset":
|
|
158
161
|
"https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
|
|
159
|
-
},
|
|
160
|
-
"playlist-experience"
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
expect(result.button.leadingIcon.default).toEqual(
|
|
164
|
-
expect.objectContaining({
|
|
165
|
-
asset: "https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("should map item.checkbox_asset and checked_checkbox_asset onto item.checkbox", () => {
|
|
171
|
-
const result = parseModalBlocksConfiguration(
|
|
172
|
-
{
|
|
173
162
|
"item.checkbox_asset":
|
|
174
163
|
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
175
|
-
"item.checked_checkbox_asset":
|
|
176
|
-
"https://placehold.co/24x24/FFD60A/000000/png?text=CK",
|
|
177
|
-
},
|
|
178
|
-
"playlist-experience"
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(result.item.checkbox.default).toEqual(
|
|
182
|
-
expect.objectContaining({
|
|
183
|
-
asset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
184
|
-
checkedAsset: "https://placehold.co/24x24/FFD60A/000000/png?text=CK",
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("should map reorder/remove Studio assets onto item.actionButtons", () => {
|
|
190
|
-
const result = parseModalBlocksConfiguration(
|
|
191
|
-
{
|
|
192
|
-
"reorder_playlist_item.remove_from_playlist_asset":
|
|
193
|
-
"https://placehold.co/24x24/00FF00/000000/png?text=RM",
|
|
194
164
|
"reorder_playlist_item.reorder_handle_asset":
|
|
195
165
|
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
196
166
|
},
|
|
197
167
|
"playlist-experience"
|
|
198
168
|
);
|
|
199
169
|
|
|
200
|
-
expect(result.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
204
|
-
})
|
|
205
|
-
);
|
|
170
|
+
expect(result.button.leadingIcon.default?.asset).toBeUndefined();
|
|
171
|
+
expect(result.item.checkbox.default).toBeUndefined();
|
|
172
|
+
expect(result.item.actionButtons.default).toBeUndefined();
|
|
206
173
|
});
|
|
174
|
+
});
|
|
207
175
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"playlist_experience_assets_flavor1.remove_from_playlist_asset":
|
|
212
|
-
"https://placehold.co/24x24/00FF00/000000/png?text=RM",
|
|
213
|
-
"playlist_experience_assets_flavor1.reorder_handle_asset":
|
|
214
|
-
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
215
|
-
},
|
|
216
|
-
"playlist-experience"
|
|
217
|
-
);
|
|
176
|
+
describe("getEmptyModalBlocksStructure", () => {
|
|
177
|
+
it("should return every block with empty containers and no state entries", () => {
|
|
178
|
+
const result = getEmptyModalBlocksStructure();
|
|
218
179
|
|
|
219
|
-
expect(result.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
180
|
+
expect(result.header.container).toEqual({});
|
|
181
|
+
expect(result.item.background).toEqual({});
|
|
182
|
+
expect(result.button.background).toEqual({});
|
|
183
|
+
expect(result.action.background).toEqual({});
|
|
184
|
+
|
|
185
|
+
expect(result.button.leadingIcon.default).toBeUndefined();
|
|
186
|
+
expect(result.item.checkbox.default).toBeUndefined();
|
|
187
|
+
expect(result.item.actionButtons.default).toBeUndefined();
|
|
225
188
|
});
|
|
226
189
|
|
|
227
|
-
it("should
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
"playlist_experience_assets_flavor2.remove_from_playlist_asset":
|
|
231
|
-
"https://placehold.co/24x24/00FF00/000000/png?text=RM",
|
|
232
|
-
"playlist_experience_assets_flavor2.reorder_handle_asset":
|
|
233
|
-
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
234
|
-
},
|
|
235
|
-
"playlist-experience"
|
|
236
|
-
);
|
|
190
|
+
it("should return a fresh object on every call", () => {
|
|
191
|
+
const first = getEmptyModalBlocksStructure();
|
|
192
|
+
const second = getEmptyModalBlocksStructure();
|
|
237
193
|
|
|
238
|
-
expect(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
242
|
-
})
|
|
243
|
-
);
|
|
194
|
+
expect(first).not.toBe(second);
|
|
195
|
+
expect(first.header).not.toBe(second.header);
|
|
196
|
+
expect(first).toEqual(second);
|
|
244
197
|
});
|
|
245
198
|
|
|
246
|
-
it("should
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
"https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
|
|
251
|
-
"playlist_experience_assets_flavor1.reorder_handle_asset":
|
|
252
|
-
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
253
|
-
},
|
|
254
|
-
"queue-action"
|
|
255
|
-
);
|
|
199
|
+
it("should be what the parser returns when config or componentName is missing", () => {
|
|
200
|
+
expect(
|
|
201
|
+
parseModalBlocksConfiguration(undefined as any, "queue_action")
|
|
202
|
+
).toEqual(getEmptyModalBlocksStructure());
|
|
256
203
|
|
|
257
|
-
expect(
|
|
258
|
-
|
|
204
|
+
expect(parseModalBlocksConfiguration({ foo: "bar" }, "")).toEqual(
|
|
205
|
+
getEmptyModalBlocksStructure()
|
|
206
|
+
);
|
|
259
207
|
});
|
|
260
208
|
});
|
|
@@ -52,10 +52,7 @@ export type ModalBlocksConfig = {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export const
|
|
56
|
-
configuration: Record<string, any>,
|
|
57
|
-
componentName: string
|
|
58
|
-
): ModalBlocksConfig => {
|
|
55
|
+
export const getEmptyModalBlocksStructure = (): ModalBlocksConfig => {
|
|
59
56
|
const result: ModalBlocksConfig = {
|
|
60
57
|
header: {
|
|
61
58
|
container: {},
|
|
@@ -106,6 +103,15 @@ export const parseModalBlocksConfiguration = (
|
|
|
106
103
|
},
|
|
107
104
|
};
|
|
108
105
|
|
|
106
|
+
return result;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const parseModalBlocksConfiguration = (
|
|
110
|
+
configuration: Record<string, any>,
|
|
111
|
+
componentName: string
|
|
112
|
+
): ModalBlocksConfig => {
|
|
113
|
+
const result = getEmptyModalBlocksStructure();
|
|
114
|
+
|
|
109
115
|
if (!configuration || !componentName) {
|
|
110
116
|
return result;
|
|
111
117
|
}
|
|
@@ -190,107 +196,5 @@ export const parseModalBlocksConfiguration = (
|
|
|
190
196
|
|
|
191
197
|
parseBlock("button", ["background", "title", "icons", "leading_icon"]);
|
|
192
198
|
|
|
193
|
-
// Playlist-experience Studio keys live in this shared parser because modal
|
|
194
|
-
// blocks are themed by themePluginId. Gate them so other plugins are not
|
|
195
|
-
// affected by playlist-only asset names.
|
|
196
|
-
const isPlaylistExperience =
|
|
197
|
-
normalizedComponentName === "playlist_experience";
|
|
198
|
-
|
|
199
|
-
// Studio uploads Create New icon as button.create_new_playlist_asset (not
|
|
200
|
-
// button.leading_icon.asset). Map it onto leadingIcon so AudioPlayerButton
|
|
201
|
-
// can override the hardcoded action-type asset.
|
|
202
|
-
const createNewPlaylistAsset = isPlaylistExperience
|
|
203
|
-
? configuration["button.create_new_playlist_asset"] ||
|
|
204
|
-
configuration[
|
|
205
|
-
`${normalizedComponentName}_button_create_new_playlist_asset`
|
|
206
|
-
]
|
|
207
|
-
: undefined;
|
|
208
|
-
|
|
209
|
-
if (createNewPlaylistAsset) {
|
|
210
|
-
if (!result.button.leadingIcon.default) {
|
|
211
|
-
result.button.leadingIcon.default = {};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
result.button.leadingIcon.default.asset = createNewPlaylistAsset;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Studio checkbox assets are top-level item.* keys (not a parseBlock
|
|
218
|
-
// sub-component). Map onto item.checkbox so multiSelect can render them.
|
|
219
|
-
const checkboxAsset =
|
|
220
|
-
configuration["item.checkbox_asset"] ||
|
|
221
|
-
configuration[`${normalizedComponentName}_item_checkbox_asset`];
|
|
222
|
-
|
|
223
|
-
const checkedCheckboxAsset =
|
|
224
|
-
configuration["item.checked_checkbox_asset"] ||
|
|
225
|
-
configuration[`${normalizedComponentName}_item_checked_checkbox_asset`];
|
|
226
|
-
|
|
227
|
-
if (checkboxAsset || checkedCheckboxAsset) {
|
|
228
|
-
if (!result.item.checkbox.default) {
|
|
229
|
-
result.item.checkbox.default = {};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (checkboxAsset) {
|
|
233
|
-
result.item.checkbox.default.asset = checkboxAsset;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (checkedCheckboxAsset) {
|
|
237
|
-
result.item.checkbox.default.checkedAsset = checkedCheckboxAsset;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Edit Order row icons: prefer reorder_playlist_item.*, then flavor1, then
|
|
242
|
-
// flavor2 playlist_experience_assets_* (playlist-experience theme only).
|
|
243
|
-
const removeAsset = isPlaylistExperience
|
|
244
|
-
? configuration["reorder_playlist_item.remove_from_playlist_asset"] ||
|
|
245
|
-
configuration[
|
|
246
|
-
`${normalizedComponentName}_reorder_playlist_item_remove_from_playlist_asset`
|
|
247
|
-
] ||
|
|
248
|
-
configuration[
|
|
249
|
-
"playlist_experience_assets_flavor1.remove_from_playlist_asset"
|
|
250
|
-
] ||
|
|
251
|
-
configuration[
|
|
252
|
-
`${normalizedComponentName}_assets_flavor1_remove_from_playlist_asset`
|
|
253
|
-
] ||
|
|
254
|
-
configuration[
|
|
255
|
-
"playlist_experience_assets_flavor2.remove_from_playlist_asset"
|
|
256
|
-
] ||
|
|
257
|
-
configuration[
|
|
258
|
-
`${normalizedComponentName}_assets_flavor2_remove_from_playlist_asset`
|
|
259
|
-
]
|
|
260
|
-
: undefined;
|
|
261
|
-
|
|
262
|
-
const dragAsset = isPlaylistExperience
|
|
263
|
-
? configuration["reorder_playlist_item.reorder_handle_asset"] ||
|
|
264
|
-
configuration[
|
|
265
|
-
`${normalizedComponentName}_reorder_playlist_item_reorder_handle_asset`
|
|
266
|
-
] ||
|
|
267
|
-
configuration[
|
|
268
|
-
"playlist_experience_assets_flavor1.reorder_handle_asset"
|
|
269
|
-
] ||
|
|
270
|
-
configuration[
|
|
271
|
-
`${normalizedComponentName}_assets_flavor1_reorder_handle_asset`
|
|
272
|
-
] ||
|
|
273
|
-
configuration[
|
|
274
|
-
"playlist_experience_assets_flavor2.reorder_handle_asset"
|
|
275
|
-
] ||
|
|
276
|
-
configuration[
|
|
277
|
-
`${normalizedComponentName}_assets_flavor2_reorder_handle_asset`
|
|
278
|
-
]
|
|
279
|
-
: undefined;
|
|
280
|
-
|
|
281
|
-
if (removeAsset || dragAsset) {
|
|
282
|
-
if (!result.item.actionButtons.default) {
|
|
283
|
-
result.item.actionButtons.default = {};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (removeAsset) {
|
|
287
|
-
result.item.actionButtons.default.removeAsset = removeAsset;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (dragAsset) {
|
|
291
|
-
result.item.actionButtons.default.dragAsset = dragAsset;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
199
|
return result;
|
|
296
200
|
};
|
|
@@ -60,7 +60,7 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
60
60
|
expect(state.label).toBe("Label Property Action");
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
it("
|
|
63
|
+
it("humanizes an un-overridden alias and falls back to the placeholder asset", () => {
|
|
64
64
|
const entry = {
|
|
65
65
|
id: "entry-3",
|
|
66
66
|
extensions: {
|
|
@@ -71,11 +71,7 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
71
71
|
dismiss_on_action: true,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
button: { alias: "
|
|
75
|
-
actions: [{ type: "test" }],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
button: { alias: "delete_collection" },
|
|
74
|
+
button: { alias: "custom_unknown_action" },
|
|
79
75
|
actions: [{ type: "test" }],
|
|
80
76
|
},
|
|
81
77
|
],
|
|
@@ -84,42 +80,86 @@ describe("buildEntryActions - alias & label resolution", () => {
|
|
|
84
80
|
|
|
85
81
|
const actions = resolveEntryActions(entry as any);
|
|
86
82
|
|
|
87
|
-
expect(actions).toHaveLength(
|
|
83
|
+
expect(actions).toHaveLength(2);
|
|
88
84
|
|
|
85
|
+
// No built-in alias vocabulary any more: underscores become spaces and
|
|
86
|
+
// only the first letter is capitalized, so "queue" stays lowercase.
|
|
89
87
|
expect(actions[0].action.initialEntryState(entry as any)).toMatchObject({
|
|
90
88
|
state: 0,
|
|
91
|
-
label: "Add all to
|
|
89
|
+
label: "Add all to queue",
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
expect(actions[1].action.initialEntryState(entry as any)).toMatchObject({
|
|
95
93
|
state: 0,
|
|
96
|
-
label: "
|
|
94
|
+
label: "Custom unknown action",
|
|
97
95
|
});
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
// The asset has no such fallback: without an override it is the red-box
|
|
98
|
+
// placeholder, so a missing Studio icon is visible rather than absent.
|
|
99
|
+
for (const action of actions) {
|
|
100
|
+
expect(action.action.initialEntryState(entry as any)).toMatchObject({
|
|
101
|
+
asset: expect.stringMatching(/^data:image\/png;base64,/),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
it("
|
|
106
|
+
it("prefers aliasPresentation overrides over the humanized fallbacks", () => {
|
|
107
|
+
const deps = {
|
|
108
|
+
actionExecutor: { handleActions: jest.fn() } as any,
|
|
109
|
+
actionContext: {},
|
|
110
|
+
aliasPresentation: {
|
|
111
|
+
labels: { add_all_to_queue: "Add all to Queue" },
|
|
112
|
+
assets: { add_all_to_queue: "http://example.com/queue.png" },
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
106
116
|
const entry = {
|
|
107
117
|
id: "entry-4",
|
|
108
118
|
extensions: {
|
|
109
119
|
entry_action: [
|
|
110
120
|
{
|
|
111
|
-
button: { alias: "
|
|
121
|
+
button: { alias: "add_all_to_queue" },
|
|
122
|
+
actions: [{ type: "test" }],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
button: { alias: "not_overridden" },
|
|
112
126
|
actions: [{ type: "test" }],
|
|
113
127
|
},
|
|
114
128
|
],
|
|
115
129
|
},
|
|
116
130
|
};
|
|
117
131
|
|
|
118
|
-
const actions =
|
|
132
|
+
const actions = buildEntryActions(entry as any, deps);
|
|
119
133
|
|
|
120
|
-
expect(actions).
|
|
134
|
+
expect(actions[0].action.initialEntryState(entry as any)).toMatchObject({
|
|
135
|
+
label: "Add all to Queue",
|
|
136
|
+
asset: "http://example.com/queue.png",
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Overrides are per-alias, so an alias absent from the map still humanizes.
|
|
140
|
+
expect(actions[1].action.initialEntryState(entry as any)).toMatchObject({
|
|
141
|
+
label: "Not overridden",
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("returns no asset when the button has neither iconURL nor alias", () => {
|
|
146
|
+
const entry = {
|
|
147
|
+
id: "entry-5",
|
|
148
|
+
extensions: {
|
|
149
|
+
entry_action: [
|
|
150
|
+
{
|
|
151
|
+
button: { label: "Plain Label" },
|
|
152
|
+
actions: [{ type: "test" }],
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const actions = resolveEntryActions(entry as any);
|
|
121
159
|
const state = actions[0].action.initialEntryState(entry as any);
|
|
122
|
-
|
|
160
|
+
|
|
161
|
+
expect(state.label).toBe("Plain Label");
|
|
162
|
+
expect(state.asset).toBeUndefined();
|
|
123
163
|
});
|
|
124
164
|
|
|
125
165
|
it("uses actionExecutor.getActionState for plugin-provided label and asset", () => {
|
|
@@ -1,52 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Presentation
|
|
2
|
+
* Presentation fallbacks for backend action aliases.
|
|
3
3
|
*
|
|
4
4
|
* Entries may declare an action by `alias` alone, without a label or an icon.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* There is no built-in alias vocabulary: a label falls back to a humanized
|
|
6
|
+
* version of the alias itself, and an icon falls back to an inline placeholder
|
|
7
|
+
* that is deliberately conspicuous, so a missing asset reads as unconfigured
|
|
8
|
+
* rather than as a deliberate blank.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* alias vocabulary
|
|
10
|
-
*
|
|
10
|
+
* Both are last resorts, not a framework guarantee: an app that speaks its own
|
|
11
|
+
* alias vocabulary or needs other languages passes labels and assets through
|
|
12
|
+
* `EntryActionDeps.aliasPresentation`, which is consulted per alias.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
import { EntryAction } from "./types";
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
"https://assets-secure.applicaster.com/zapp/assets/app_family/1710/906728572617/playlist_add_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24.png";
|
|
17
|
-
|
|
18
|
-
const REMOVE_ICON =
|
|
19
|
-
"https://assets-secure.applicaster.com/zapp/assets/app_family/1710/372097240191/remove_24dp_EA3323_FILL0_wght400_GRAD0_opsz24.png";
|
|
20
|
-
|
|
21
|
-
const EDIT_ICON =
|
|
22
|
-
"https://upload.wikimedia.org/wikipedia/commons/b/b6/Edit-icon.png";
|
|
23
|
-
|
|
24
|
-
/** Known backend action alias labels. */
|
|
25
|
-
export const ALIAS_LABELS: Record<string, string> = {
|
|
26
|
-
add_to_playlist: "Add to Playlist",
|
|
27
|
-
add_to_queue: "Add to Queue",
|
|
28
|
-
add_all_to_queue: "Add all to Queue",
|
|
29
|
-
play_all: "Play All",
|
|
30
|
-
remove_item: "Remove item",
|
|
31
|
-
delete_collection: "Delete collection",
|
|
32
|
-
create_collection: "Create collection",
|
|
33
|
-
edit: "Edit",
|
|
34
|
-
edit_name: "Edit Name & Details",
|
|
35
|
-
};
|
|
17
|
+
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
remove_item: REMOVE_ICON,
|
|
44
|
-
delete_collection: REMOVE_ICON,
|
|
45
|
-
edit: EDIT_ICON,
|
|
46
|
-
edit_name: EDIT_ICON,
|
|
47
|
-
};
|
|
19
|
+
const logger = createLogger({
|
|
20
|
+
category: "zapp-react-native-utils:aliasPresentation",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const PLACEHOLDER_RED_BOX =
|
|
24
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJ0lEQVR4nO3NMQEAAAjDsIF/z2ACvlRAU5NMHuvPOQAAAAAAAMBdC/07Ai5sNw+CAAAAAElFTkSuQmCC";
|
|
48
25
|
|
|
49
|
-
/** Per-app
|
|
26
|
+
/** Per-app labels and icons, keyed by alias, that outrank the fallbacks. */
|
|
50
27
|
export type AliasPresentation = {
|
|
51
28
|
labels?: Record<string, string>;
|
|
52
29
|
assets?: Record<string, string>;
|
|
@@ -56,7 +33,7 @@ function formatAliasLabel(
|
|
|
56
33
|
alias: string,
|
|
57
34
|
overrides?: AliasPresentation
|
|
58
35
|
): string {
|
|
59
|
-
const label = overrides?.labels?.[alias]
|
|
36
|
+
const label = overrides?.labels?.[alias];
|
|
60
37
|
|
|
61
38
|
if (label) {
|
|
62
39
|
return label;
|
|
@@ -107,7 +84,7 @@ export function resolveButtonLabel(
|
|
|
107
84
|
return "";
|
|
108
85
|
}
|
|
109
86
|
|
|
110
|
-
/** Icon to show for an entry action: explicit iconURL,
|
|
87
|
+
/** Icon to show for an entry action: explicit iconURL, matching alias asset or fallback to red box. */
|
|
111
88
|
export function resolveButtonAsset(
|
|
112
89
|
button: EntryAction["button"],
|
|
113
90
|
overrides?: AliasPresentation
|
|
@@ -120,5 +97,12 @@ export function resolveButtonAsset(
|
|
|
120
97
|
return undefined;
|
|
121
98
|
}
|
|
122
99
|
|
|
123
|
-
|
|
100
|
+
if (!overrides?.assets?.[button.alias]) {
|
|
101
|
+
logger.log_warning(
|
|
102
|
+
`Entry action alias '${button.alias}' was not resolved by any plugin feedDecorator or app override. Falling back to placeholder red box.`,
|
|
103
|
+
{ data: { button } }
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return overrides?.assets?.[button.alias] ?? PLACEHOLDER_RED_BOX;
|
|
124
108
|
}
|
package/entryActions/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.91",
|
|
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": "16.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "16.0.0-rc.91",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|