Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action): add original url in the smart action handler #914

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/agent/src/routes/modification/action/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class ActionRoute extends CollectionRoute {
this.getRecordSelection(context, false),
]);
const requestBody = context.request.body as SmartActionApprovalRequestBody;
const contextUrl: string = context.request.url || context.request.originalUrl;

const canPerformCustomActionParams = {
caller,
Expand Down Expand Up @@ -103,7 +104,13 @@ export default class ActionRoute extends CollectionRoute {

// Now that we have the field list, we can parse the data again.
const data = ForestValueConverter.makeFormData(dataSource, rawData, fields);
const result = await this.collection.execute(caller, this.actionName, data, filterForCaller);
const result = await this.collection.execute(
caller,
this.actionName,
data,
filterForCaller,
contextUrl,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wrap this into an object (executionContext?), this way we could add more things in the future. 💪

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a good idea 🆗

);

if (result?.type === 'Error') {
context.response.status = HttpCode.BadRequest;
Expand Down
1 change: 1 addition & 0 deletions packages/datasource-toolkit/src/interfaces/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface Collection {
name: string,
formValues: RecordData,
filter?: Filter,
url?: string,
): Promise<ActionResult>;

getForm(
Expand Down
Loading