You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/09-Actions.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,9 +163,12 @@ Instead of defining an `action` handler, you can specify a `url` that the user w
163
163
}
164
164
```
165
165
166
+
> ☝️ Note: You cannot specify both `action` and `url` for the same action - only one should be used.
167
+
166
168
The URL can be:
167
169
- A relative path within your admin panel (starting with '/')
168
170
- An absolute URL (starting with 'http://' or 'https://')
171
+
- function which creates URL based on record fields
169
172
170
173
To open the URL in a new tab, append `target=_blank` as a query parameter. If the URL already has query parameters, use `&target=_blank`; otherwise use `?target=_blank`:
171
174
@@ -181,7 +184,46 @@ To open the URL in a new tab, append `target=_blank` as a query parameter. If th
181
184
}
182
185
```
183
186
184
-
> ☝️ Note: You cannot specify both `action` and `url` for the same action - only one should be used.
> ☝️ Note: Though url function might be async we recommend to omit long awaits, or ideally don't use them at all, cause slow execution of this hook might be a subject of bottleneck for resource pages rendering. For built actions the async functions would be called in parallel to optimize loading speed.
202
+
203
+
204
+
### Deep-level redirects.
205
+
206
+
Using `url` prop described above is recommended way to implementing URL navigation from actions (internal or external), because URLs are rendered into direct anchour tag and support all anchour features (like Open in new tab).
207
+
208
+
However, rearely you might also like to decide whether to redirect only after performing some logic (conditionally). This way is not recommended for most of cases, because it is not compatible with action native features (we can't know URL before executing action body):
@@ -313,4 +355,4 @@ Backend handler: read the payload via `extra`.
313
355
314
356
Notes:
315
357
- If you don’t emit a payload, the default behavior is used by the UI (e.g., in lists the current row context is used). When you do provide a payload, it will be forwarded to the backend as `extra` for your action handler.
316
-
- You can combine default context with your own payload by merging before emitting, for example: `emit('callAction', { ...row, asListed: true })` if your component has access to the row object.
358
+
- You can combine default context with your own payload by merging before emitting, for example: `emit('callAction', { ...row, asListed: true })` if your component has access to the row object.
0 commit comments