Skip to content

Commit

Permalink
Added edit session feature to load BatchConnect form with existing se…
Browse files Browse the repository at this point in the history
…ssion parameters (#3358)
  • Loading branch information
abujeda authored Feb 29, 2024
1 parent f013213 commit 4587cd0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ def new
set_session_context
set_prefill_templates

session_id = params[:session_id]
valid_session = session_id && BatchConnect::Session.exist?(session_id)

if @app.valid?
begin
@app.update_session_with_cache(@session_context, cache_file)
app_parameters_file = valid_session ? BatchConnect::Session.find(session_id).user_defined_context_file : cache_file
@app.update_session_with_cache(@session_context, app_parameters_file)
rescue => e
flash.now[:alert] = t('dashboard.batch_connect_form_attr_cache_error',error_message: e.message)
end
Expand Down
16 changes: 16 additions & 0 deletions apps/dashboard/app/helpers/batch_connect/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ def relaunch(session)
end
end

def edit(session)
title = t('dashboard.batch_connect_sessions_edit_title', title: session.title)
button_to(
new_batch_connect_session_context_path(token: session.token),
method: :get,
class: %w[btn px-1 py-0 btn-outline-dark],
form_class: %w[d-inline edit-session],
title: title,
'aria-label': title,
data: { toggle: "tooltip", placement: "left" },
params: {session_id: session.id}
) do
"#{fa_icon('pen', classes: nil, title: '')}".html_safe
end
end

def cancel_or_delete(session)
if Configuration.cancel_session_enabled && !session.completed?
cancel(session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
<%- end -%>
<%= status(session) %>
<%- if session.completed? -%>
<span class="card-text"> | </span>
<%= relaunch(session) %>
<span class="card-text"> | </span>
<%= edit(session) %>
<span class="card-text"> | </span>
<%= relaunch(session) %>
<%- end -%>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ en:
batch_connect_sessions_cancel_confirm: "Are you sure?"
batch_connect_sessions_cancel_title: "Cancel"
batch_connect_sessions_relaunch_title: "Relaunch"
batch_connect_sessions_edit_title: "Edit new %{title} with this session parameters"
batch_connect_sessions_errors_staging: "Failed to stage the template with the following error:"
batch_connect_sessions_errors_submission: "Failed to submit session with the following error:"
batch_connect_sessions_novnc_launch: "Launch %{app_title}"
Expand Down

0 comments on commit 4587cd0

Please sign in to comment.