@wix/auto-patterns 1.34.0 → 1.35.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.
- package/mcp-docs/action_cell.md +50 -2
- package/mcp-docs/auto-patterns-guide.md +611 -38
- package/mcp-docs/bulk_actions.md +78 -22
- package/mcp-docs/collection_page_actions.md +56 -2
- package/mcp-docs/custom_overrides.md +1 -0
- package/mcp-docs/entity_page_actions.md +78 -1
- package/mcp-docs/entity_page_view_actions.md +2 -0
- package/mcp-docs/error_handling.md +346 -11
- package/package.json +6 -6
package/mcp-docs/action_cell.md
CHANGED
|
@@ -40,6 +40,7 @@ Both properties are optional, but at least one should be provided for the Action
|
|
|
40
40
|
- Browser interactions (alerts, downloads)
|
|
41
41
|
- Complex operations
|
|
42
42
|
- ⚠️ Requires implementation: Must register action in overrides
|
|
43
|
+
- ⚠️ **CRITICAL: Error Handling Required** - When implementing custom actions that make HTTP requests, you MUST read the "Error Handling for HTTP Requests" section and apply the correct error handling patterns. Wix HTTP requests require `errorHandler.withErrorHandler`, while external API calls should NOT use errorHandler.
|
|
43
44
|
|
|
44
45
|
### Action Appearance: The `skin` Property
|
|
45
46
|
|
|
@@ -139,7 +140,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
139
140
|
},
|
|
140
141
|
successToast: 'Pet details downloaded',
|
|
141
142
|
errorToast: (err, {retry}) => ({
|
|
142
|
-
|
|
143
|
+
text: 'Download failed',
|
|
143
144
|
action: { text: 'Retry', onClick: retry }
|
|
144
145
|
})
|
|
145
146
|
});
|
|
@@ -149,6 +150,53 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
149
150
|
};
|
|
150
151
|
```
|
|
151
152
|
|
|
153
|
+
**⚠️ CRITICAL: Error Handling for HTTP Requests**
|
|
154
|
+
|
|
155
|
+
The example above uses SDK methods which don't require error handling. However, if your custom action makes HTTP requests, you MUST follow the error handling patterns:
|
|
156
|
+
|
|
157
|
+
**For Wix HTTP requests (httpClient, wix/data, wix/stores):**
|
|
158
|
+
```typescript
|
|
159
|
+
import { errorHandler } from '@wix/essentials';
|
|
160
|
+
|
|
161
|
+
export const myAction: CustomActionCellSecondaryActionResolver = (params) => {
|
|
162
|
+
return {
|
|
163
|
+
label: 'My Action',
|
|
164
|
+
icon: <MyIcon />,
|
|
165
|
+
onClick: () => {
|
|
166
|
+
// ✅ CORRECT: Wix API call wrapped with errorHandler
|
|
167
|
+
errorHandler.withErrorHandler(
|
|
168
|
+
async () => {
|
|
169
|
+
const response = await httpClient.request(
|
|
170
|
+
myWixApiCall({ data: params.actionParams.item })
|
|
171
|
+
);
|
|
172
|
+
return response.data;
|
|
173
|
+
},
|
|
174
|
+
{}
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**For External API requests (fetch, axios, third-party):**
|
|
182
|
+
```typescript
|
|
183
|
+
export const myAction: CustomActionCellSecondaryActionResolver = (params) => {
|
|
184
|
+
return {
|
|
185
|
+
label: 'My Action',
|
|
186
|
+
icon: <MyIcon />,
|
|
187
|
+
onClick: () => {
|
|
188
|
+
// ✅ CORRECT: External API call - NO errorHandler needed
|
|
189
|
+
fetch('https://api.external-service.com/endpoint', {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
body: JSON.stringify(params.actionParams.item)
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Read the "Error Handling for HTTP Requests" section for complete guidance.**
|
|
199
|
+
|
|
152
200
|
3. Export your action in `actions/index.tsx`:
|
|
153
201
|
```typescript
|
|
154
202
|
import { downloadPetDetails } from './downloadPetDetails';
|
|
@@ -209,7 +257,7 @@ Custom actions execute JavaScript code that you define. These actions receive pa
|
|
|
209
257
|
- Enable analytics tracking for user interactions
|
|
210
258
|
|
|
211
259
|
2. The implementation must return a `ResolvedAction` object with:
|
|
212
|
-
- `label`: Text displayed for the action
|
|
260
|
+
- `label`: Text displayed for the action
|
|
213
261
|
- `icon`: An Icon component from "@wix/wix-ui-icons-common"
|
|
214
262
|
- `onClick`: Handler function for the action
|
|
215
263
|
- `biName`: Business intelligence name for analytics tracking. Must match the `biName` in your action configuration (required)
|