Class: Protege::Agents::AgentToolkitsController

Inherits:
Protege::ApplicationController show all
Includes:
Protege::AgentScoped
Defined in:
app/controllers/protege/agents/agent_toolkits_controller.rb

Overview

Attaches and detaches an agent's toolkit grants — the list of toolkits given to one agent, in the agent's scope. Nested under agents via AgentScoped; mirrors AccessRulesController (Turbo child rows), rendering back to the agent's page. Managing a created grant (its gate, proactive flag, rules) is the top-level AgentToolkitsController.

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Attach a toolkit to the agent. Turbo requests append the grant row and reset the form; non-Turbo requests redirect back to the agent.



18
19
20
21
22
23
24
25
26
# File 'app/controllers/protege/agents/agent_toolkits_controller.rb', line 18

def create
  @agent_toolkit = @agent.agent_toolkits.build(agent_toolkit_params)
  saved          = @agent_toolkit.save

  respond_to do |format|
    format.turbo_stream { render :create, status: saved ? :ok : :unprocessable_entity }
    format.html         { redirect_to agent_path(@agent), **create_flash(saved) }
  end
end

#destroyvoid

This method returns an undefined value.

Detach a toolkit from the agent. Turbo requests remove the row in place.



31
32
33
34
35
36
37
38
# File 'app/controllers/protege/agents/agent_toolkits_controller.rb', line 31

def destroy
  @agent_toolkit.destroy

  respond_to do |format|
    format.turbo_stream { render turbo_stream: turbo_stream.remove(@agent_toolkit) }
    format.html         { redirect_to agent_path(@agent), notice: 'Toolkit detached.' }
  end
end