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

Handle Action Logic for Selected Node #2622

Open
5 tasks
tomsmith8 opened this issue Jan 17, 2025 · 4 comments
Open
5 tasks

Handle Action Logic for Selected Node #2622

tomsmith8 opened this issue Jan 17, 2025 · 4 comments
Assignees
Labels

Comments

@tomsmith8
Copy link
Contributor

tomsmith8 commented Jan 17, 2025

Frontend Ticket: Handle Action Logic for Selected Node

Objective

Implement the frontend logic for handling actions when a user selects a node and clicks on an action. The logic includes rendering forms (if required), handling bounty flows, and submitting the action to the backend.


Requirements

1. Trigger Action on Node Selection

  • Trigger: When a user clicks on an action button associated with a selected node.
  • Fetch the corresponding action details from the schemaStore (added in Ticket 1).

2. Handle Form Logic

  • If form_required = true:

    • Render a form dynamically using the form_data structure.
    • Allow users to input data (e.g., a prompt).
    • Collect the form data for the POST request.
  • If form_required = false or not passed:

    • Skip the form step and proceed directly to the next action logic.

3. Handle Bounty Flow

  • If bounty = true:
    • Trigger the bounty flow after form submission (if applicable).
    • Use the workspace_id and amount parameters from the action details to display the bounty creation screen.

4. Submit Action to Backend

  • Send a POST /action request to the backend with the required data:
    • Mandatory:
      • ref_id: The selected node's reference ID.
      • action_name: The action to be performed.
    • Optional:
      • form_data (if a form is used).
      • bounty parameters (if applicable).

Example Payload:

{
  "ref_id": "node_123",
  "action_name": "generate_unit_test",
  "pubkey": "1234
  "form_data": {
    "prompt": "Write unit tests for function XYZ"
  },
  "bounty": {
    "workspace_id": "workspace_456",
    "amount": 100,
    "jwt"
  }
}

Flow Breakdown

User Interaction:

  • User selects a node.
  • Available actions are fetched and displayed as buttons (handled in Ticket 1).

Action Click Logic:

  • Fetch the action configuration from schemaStore:
  • Check if form_required = true.
  • If true, render the form and collect user input.
  • If false, skip the form step.
  • Check if bounty = true.
  • If true, trigger the bounty flow at the end.
  • Send the POST /action request with the collected data.

Acceptance Criteria

  • Clicking on an action button dynamically handles form_required logic:
  • Renders a form if required and collects input.
  • Skips the form step if not required.
  • If bounty = true, the bounty flow is triggered with appropriate parameters.
  • The POST /action request is sent to the backend with the correct payload.
@sophieturner0
Copy link
Contributor

@tomsmith8 assign me?

@MuhammadUmer44
Copy link
Contributor

@tomsmith8 I can help?

@tomsmith8
Copy link
Contributor Author

@sophieturner0 any update on this one?

@ManyRios
Copy link
Contributor

ManyRios commented Feb 2, 2025

@tomsmith8 same here

@tomsmith8 tomsmith8 assigned tobi-bams and unassigned sophieturner0 Feb 3, 2025
@tobi-bams tobi-bams linked a pull request Feb 6, 2025 that will close this issue
@tobi-bams tobi-bams removed a link to a pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants