command_proposal 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cc9baadf971edd54dc7558fbec28c8f515e9fb572975705f886b18a68693b7b
4
- data.tar.gz: 2793d9b73e85d8e0d509974cf9b6f7ed36517c4adbfec9a23f52bbc66d4effff
3
+ metadata.gz: 883775b419cb2a8279c8ba335c290a188e5952d535b3a96d4534f38102a7c680
4
+ data.tar.gz: d7c8d7cfb062d5863ad5e1c91311f79b295f1445f5a18bc7d643024c45a04944
5
5
  SHA512:
6
- metadata.gz: b80eb953b76e09aa2dbbc62c0df2884c15833e8dd1abc4bd66141f0c6b0adc608fcbda97efb80647ec31a1d92ac20d43fda79675560815b74cd93a878a79dc5f
7
- data.tar.gz: f26da392c2ed15eaf1f362d0e0bd131ac8c9a05df30390871acc56a9fb8543cb5e69c88816be1fc36cb78478797659222a0edf8e4945b948538f17b97e206579
6
+ metadata.gz: 885dff6a34419b84a063d9fad90991a98db1c064938414750b8b556b2ce8313e84ecefefbbb81cea8da460f71e3e24b60d2389cc1e94e7400ac63070f6bbd682
7
+ data.tar.gz: 5d105caabf028062646ada81f4d4004102fbdb25d395fd03840be507cf6e4a230e2f65929e85fe8d76942eda2dffb3605941bd8b9a4aef5987d56f8664bdbbc2
@@ -5279,7 +5279,7 @@
5279
5279
  }
5280
5280
 
5281
5281
  // Possibly split or suppress the update based on the presence
5282
- // of read-only spans in its range.
5282
+ // of readonly spans in its range.
5283
5283
  var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
5284
5284
  if (split) {
5285
5285
  for (var i = split.length - 1; i >= 0; --i)
@@ -68,6 +68,8 @@
68
68
  th, td {
69
69
  text-align: left;
70
70
  padding: 3px;
71
+
72
+ &.cmd-text-right { text-align: right; }
71
73
  }
72
74
  th {
73
75
  font-size: 12px;
@@ -18,7 +18,7 @@
18
18
  .line {
19
19
  min-height: 18px;
20
20
  counter-increment: line-count;
21
- font-size: 16px;
21
+ font-size: 14px;
22
22
  padding-left: 5px;
23
23
  position: relative;
24
24
 
@@ -26,7 +26,7 @@
26
26
  content: "[" counter(line-count) "]>";
27
27
  position: absolute;
28
28
  left: -40px;
29
- top: 3px;
29
+ top: 2px;
30
30
  width: 40px;
31
31
  font-size: 10px;
32
32
  vertical-align: middle;
@@ -67,13 +67,18 @@ class ::CommandProposal::RunnerController < ::CommandProposal::EngineController
67
67
  duration: humanized_duration(@iteration.duration),
68
68
  }.tap do |response|
69
69
  if @iteration.started?
70
- response[:endpoint] = runner_path(@task, @iteration)
70
+ response[:endpoint] = runner_url(@task, @iteration)
71
71
  end
72
72
  if @task.console?
73
73
  response[:result_html] = ApplicationController.render(
74
- partial: "command_proposal/tasks/lines",
74
+ partial: "command_proposal/tasks/console_lines",
75
75
  locals: { lines: @task.lines }
76
76
  )
77
+ else
78
+ response[:result_html] = ApplicationController.render(
79
+ partial: "command_proposal/tasks/lines",
80
+ locals: { lines: @iteration.result }
81
+ )
77
82
  end
78
83
  end
79
84
  end
@@ -4,7 +4,7 @@ module CommandProposal
4
4
  include Rails.application.routes.url_helpers
5
5
  # In order to keep the regular app's routes working in the base template, we have to manually
6
6
  # render the engine routes. Built a helper for this because it's long and nasty otherwise.
7
- def cmd_path(*args)
7
+ def cmd_url(*args)
8
8
  return string_path(*args) if args.first.is_a?(String)
9
9
  model_names = [:tasks, :iterations, :comments, :task, :iteration, :comment]
10
10
  host = nil
@@ -27,12 +27,33 @@ module CommandProposal
27
27
  end
28
28
  end
29
29
 
30
+ def cmd_path(*args)
31
+ args.tap { |arg_list|
32
+ if arg_list.last.is_a?(Hash)
33
+ arg_list.last.merge!(only_path: true)
34
+ else
35
+ arg_list << { only_path: true }
36
+ end
37
+ }
38
+
39
+ cmd_url(*args)
40
+ end
41
+
30
42
  def string_path(*args)
31
43
  [command_proposal_engine.command_proposal_tasks_url + args.shift, args.to_param.presence].compact.join("?")
32
44
  end
33
45
 
34
46
  # Runner controller doesn't map to a model, so needs special handling
35
47
  def runner_path(task, iteration=nil)
48
+ if iteration.present?
49
+ command_proposal_engine.command_proposal_task_runner_path(task, iteration)
50
+ else
51
+ command_proposal_engine.command_proposal_task_runner_index_path(task)
52
+ end
53
+ end
54
+
55
+ # Runner controller doesn't map to a model, so needs special handling
56
+ def runner_url(task, iteration=nil)
36
57
  if iteration.present?
37
58
  command_proposal_engine.command_proposal_task_runner_url(task, iteration)
38
59
  else
@@ -3,7 +3,7 @@
3
3
  # belongs_to :author
4
4
  # text :body
5
5
 
6
- require "command_proposal/service/external_belong"
6
+ require_dependency "command_proposal/service/external_belong"
7
7
 
8
8
  class ::CommandProposal::Comment < ApplicationRecord
9
9
  self.table_name = :command_proposal_comments
@@ -13,8 +13,8 @@
13
13
 
14
14
  # ADD: iteration_count?
15
15
 
16
- require "command_proposal/service/external_belong"
17
- require "command_proposal/service/json_wrapper"
16
+ require_dependency "command_proposal/service/external_belong"
17
+ require_dependency "command_proposal/service/json_wrapper"
18
18
 
19
19
  class ::CommandProposal::Iteration < ApplicationRecord
20
20
  self.table_name = :command_proposal_iterations
@@ -1,6 +1,7 @@
1
1
  module CommandProposal
2
2
  module Service
3
3
  class ProposalPresenter
4
+ include Rails.application.routes.url_helpers
4
5
  include ::CommandProposal::ApplicationHelper
5
6
  attr_accessor :iteration
6
7
 
@@ -19,8 +20,9 @@ module CommandProposal
19
20
  delegate :stopped_at, to: :iteration
20
21
  delegate :duration, to: :iteration
21
22
 
22
- def url(host: nil)
23
- cmd_path(@iteration.task, host: host)
23
+ def url
24
+ path = ::CommandProposal::Engine.routes.url_helpers.command_proposal_task_path(@iteration.task)
25
+ "#{base_path}#{path}"
24
26
  end
25
27
 
26
28
  def requester
@@ -34,6 +36,20 @@ module CommandProposal
34
36
  def type
35
37
  @iteration.session_type
36
38
  end
39
+
40
+ private
41
+
42
+ def base_path
43
+ url_opts = Rails.application.config.action_mailer.default_url_options || {}
44
+ url_opts.tap do |opts|
45
+ opts[:protocol] ||= "http"
46
+ opts[:host] ||= "localhost"
47
+ opts[:port] ||= 3000
48
+ end
49
+
50
+ port_str = url_opts[:host] == "localhost" ? ":#{url_opts[:port]}" : ""
51
+ "#{url_opts[:protocol] || 'http'}://#{url_opts[:host]}#{port_str}"
52
+ end
37
53
  end
38
54
  end
39
55
  end
@@ -0,0 +1,8 @@
1
+ <% if lines.none? && !(skip_empty ||= false) -%><div class="line"></div><% end
2
+ -%><% lines.each do |iteration| -%>
3
+ <div class="line"><%= iteration.code -%><%
4
+ if iteration.result.present?
5
+ -%><div class="result"><%= iteration.result %></div><%
6
+ end
7
+ -%></div>
8
+ <% end -%>
@@ -7,7 +7,7 @@
7
7
  <% when :approved, :started %>
8
8
  <%# Closing > offset to get rid of spacing issues. %>
9
9
  <div class="cmd-console" data-task="<%= @task.id %>" data-exe-url="<%= cmd_path(@task, :task_iterations) %>"
10
- ><div class="lines"><%= render partial: "lines", locals: { lines: @lines, skip_empty: true }
10
+ ><div class="lines"><%= render partial: "console_lines", locals: { lines: @lines, skip_empty: true }
11
11
  %></div
12
12
  ><div contenteditable="true" autofocus=true class="line cmd-entry"></div
13
13
  ></div>
@@ -26,7 +26,7 @@
26
26
  <% if @task.first_iteration.success? %>
27
27
  <p>Session closed.</p>
28
28
  <% end %>
29
- <div class="cmd-console" read-only=true><%= render partial: "lines", locals: { lines: @lines } %></div>
29
+ <div class="cmd-console" readonly=true><%= render partial: "console_lines", locals: { lines: @lines } %></div>
30
30
  <% end %>
31
31
 
32
32
  <% else %>
@@ -38,7 +38,7 @@
38
38
  <% if @task.first_iteration.success? %>
39
39
  <p>Session closed.</p>
40
40
  <% end %>
41
- <div class="cmd-console" read-only=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= render partial: "lines", locals: { lines: @lines } %></div>
41
+ <div class="cmd-console" readonly=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= render partial: "console_lines", locals: { lines: @lines } %></div>
42
42
 
43
43
  <% end %>
44
44
  <% end %>
@@ -1,54 +1,62 @@
1
1
  <%= render partial: "task_detail_table" %>
2
2
 
3
- <textarea class="cmd-terminal" readonly=true><%= @iteration.code %></textarea>
4
-
5
3
  <%= form_for @iteration, url: cmd_path(@iteration), html: { id: "edit-form-1" } do |f| %>
6
- <% if @iteration.params.any? && (@iteration.pending? || @iteration.complete?) %>
4
+ <% if @task.approved? && @iteration.params.any? %>
7
5
  <div class="form-field">
8
6
  <% @iteration.params.each do |param_key| %>
9
- <label for="iteration[args][<%= param_key %>]"><%= param_key %></label>
10
- <input type="text" name="iteration[args][<%= param_key %>]" value="">
7
+ <label for="command_proposal_iteration[args][<%= param_key %>]"><%= param_key %></label>
8
+ <br>
9
+ <input type="text" name="command_proposal_iteration[args][<%= param_key %>]" value="">
10
+ <br>
11
11
  <% end %>
12
12
  </div>
13
13
  <% end %>
14
14
 
15
- <% if @iteration.approved_at? %>
15
+ <% if @iteration.approved_at? && !params.key?(:iteration) %>
16
16
  <%= f.hidden_field :command, value: :run %>
17
17
  <%= f.submit "Execute" %>
18
+ <br>
18
19
  <% end %>
19
20
  <% end %>
20
21
 
21
- <%= form_for @iteration, url: cmd_path(@iteration), html: { id: "edit-form-2" } do |f| %>
22
- <% if @iteration&.started_at? %>
23
- <textarea class="cmd-terminal" readonly=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= @iteration&.result %></textarea>
24
- <% end %>
22
+ <% unless params.key?(:iteration) %>
23
+ <%= form_for @iteration, url: cmd_path(@iteration), html: { id: "edit-form-2" } do |f| %>
24
+ <% if current_is_author?(@iteration) %>
25
+
26
+ <% case @iteration.status&.to_sym %>
27
+ <% when :created, :failed, :cancelled %>
28
+ <% unless @iteration.approved_at? %>
29
+ <% if can_approve?(@iteration) %>
30
+ <%= f.hidden_field :command, value: :approve %>
31
+ <%= f.submit "Approve!" %>
32
+ <% else %>
33
+ <%= f.hidden_field :command, value: :request %>
34
+ <%= f.submit "Request Access" %>
35
+ <% end %>
36
+ <% end %>
37
+ <% when :started %>
38
+ <%= f.hidden_field :command, value: :cancel %>
39
+ <%= f.submit "CANCEL!", class: "cancel-btn", data: { confirm: "WARNING: Cancelling a command mid-process can be dangerous. Any processes that have already run will not be rolled back. Do you wish to continue?" } %>
40
+ <% end %>
25
41
 
26
- <% if current_is_author?(@iteration) %>
42
+ <% elsif can_approve?(@iteration) %>
27
43
 
28
- <% case @iteration.status&.to_sym %>
29
- <% when :created, :failed, :cancelled %>
30
- <% if can_approve?(@iteration) %>
44
+ <% if @iteration.approved? %>
45
+ <p>Approved. Ready to run.</p>
46
+ <% elsif @iteration.pending? %>
31
47
  <%= f.hidden_field :command, value: :approve %>
32
48
  <%= f.submit "Approve!" %>
33
- <% else %>
34
- <%= f.hidden_field :command, value: :request %>
35
- <%= f.submit "Request Access" %>
36
49
  <% end %>
37
- <% when :started %>
38
- <%= f.hidden_field :command, value: :cancel %>
39
- <%= f.submit "CANCEL!", class: "cancel-btn", data: { confirm: "WARNING: Cancelling a command mid-process can be dangerous. Any processes that have already run will not be rolled back. Do you wish to continue?" } %>
40
- <% end %>
41
-
42
- <% elsif can_approve?(@iteration) %>
43
50
 
44
- <% if @iteration.approved? %>
45
- <p>Approved. Ready to run.</p>
46
- <% elsif @iteration.pending? %>
47
- <%= f.hidden_field :command, value: :approve %>
48
- <%= f.submit "Approve!" %>
49
51
  <% end %>
50
-
51
52
  <% end %>
52
53
  <% end %>
53
54
 
54
- <% render partial: "past_iterations_list" %>
55
+ <% if @iteration&.started_at? %>
56
+ <div class="cmd-console" readonly=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= render partial: "lines", locals: { lines: @iteration&.result } %></div>
57
+ <% end %>
58
+
59
+ <br>
60
+ <textarea class="cmd-terminal" readonly=true><%= @iteration.code %></textarea>
61
+
62
+ <%= render partial: "past_iterations_list" %>
@@ -1,8 +1,4 @@
1
- <% if lines.none? && !(skip_empty ||= false) -%><div class="line"></div><% end
2
- -%><% lines.each do |iteration| -%>
3
- <div class="line"><%= iteration.code -%><%
4
- if iteration.result.present?
5
- -%><div class="result"><%= iteration.result %></div><%
6
- end
7
- -%></div>
8
- <% end -%>
1
+ <% if lines.blank? && !(skip_empty ||= false) -%><div class="line"></div><% end
2
+ -%><% lines.split("\n").each do |line|
3
+ -%><div class="line"><%= line -%></div><%
4
+ end -%>
@@ -12,15 +12,11 @@
12
12
  <%= f.hidden_field :command, value: :request %>
13
13
  <%= f.submit "Request Access" %>
14
14
  <% end %>
15
- <% when :approved %>
16
- <p>Include this module in other commands by using <code>bring :<%= @task.friendly_id %></code> at the top of the file.</p>
17
15
  <% end %>
18
16
 
19
17
  <% elsif can_approve?(@iteration) %>
20
18
 
21
- <% if @iteration.approved? %>
22
- <p>Approved. Ready to include.</p>
23
- <% elsif @iteration.pending? %>
19
+ <% if @iteration.pending? %>
24
20
  <%= f.hidden_field :command, value: :approve %>
25
21
  <%= f.submit "Approve!" %>
26
22
  <% end %>
@@ -28,6 +24,7 @@
28
24
  <% end %>
29
25
  <% end %>
30
26
 
27
+ <p>Include this module in other commands by using <code>bring :<%= @task.friendly_id %></code> at the top of the file.</p>
31
28
  <textarea class="cmd-terminal" readonly=true><%= @iteration&.code %></textarea>
32
29
 
33
- <% render partial: "past_iterations_list" %>
30
+ <%= render partial: "past_iterations_list" %>
@@ -1,3 +1,4 @@
1
+ hi
1
2
  <% if @task.iterations.many? %>
2
3
  <table class="cmd-table">
3
4
  <thead>
@@ -7,9 +8,16 @@
7
8
  <!-- <th>Diff</th> -->
8
9
  </thead>
9
10
  <tbody>
11
+ <% primary_iteration = @task.primary_iteration %>
10
12
  <% @task.iterations.where.not(id: @iteration&.id).order(created_at: :desc).each do |iteration| %>
11
13
  <tr>
12
- <td><%= link_to iteration.created_at.strftime("%b %-d, %Y at %H:%M"), cmd_path(@task, iteration: iteration.id) %></td>
14
+ <td>
15
+ <% if iteration.id == primary_iteration&.id %>
16
+ <%= link_to iteration.created_at.strftime("%b %-d, %Y at %H:%M"), cmd_path(@task) %>
17
+ <% else %>
18
+ <%= link_to iteration.created_at.strftime("%b %-d, %Y at %H:%M"), cmd_path(@task, iteration: iteration.id) %>
19
+ <% end %>
20
+ </td>
13
21
  <td><%= iteration.status.capitalize %></td>
14
22
  <!-- <td><%= iteration.comments.count %></td> -->
15
23
  <!-- <td><%= link_to "Diff", cmd_path(@task, iteration: @iteration.id, diff: iteration.id) %></td> -->
@@ -22,7 +22,7 @@
22
22
  <tbody>
23
23
  <% @iteration.args.each do |arg_k, arg_v| %>
24
24
  <tr>
25
- <th><%= arg_k %></th>
25
+ <th class="cmd-text-right"><%= arg_k %></th>
26
26
  <td><%= arg_v %></td>
27
27
  </tr>
28
28
  <% end %>
@@ -2,49 +2,51 @@
2
2
 
3
3
  <% if @iteration.present? %>
4
4
  <%= form_for @iteration, url: cmd_path(@iteration) do |f| %>
5
- <% @iteration.brings.each do |bring_module| %>
6
- <% needs_approval_str = " -- Module needs approval before running Task" unless bring_module.approved? %>
7
- <%= link_to "Module: #{bring_module.name}#{needs_approval_str}", cmd_path("#{bring_module.friendly_id}") %>
8
- <br>
9
- <% end %>
5
+ <% unless params.key?(:iteration) %>
6
+ <% @iteration.brings.each do |bring_module| %>
7
+ <% needs_approval_str = " -- Module needs approval before running Task" unless bring_module.approved? %>
8
+ <%= link_to "Module: #{bring_module.name}#{needs_approval_str}", cmd_path("#{bring_module.friendly_id}") %>
9
+ <br>
10
+ <% end %>
10
11
 
11
- <% if @iteration&.started_at? %>
12
- <textarea class="cmd-terminal" readonly=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= @iteration&.result %></textarea>
13
- <% end %>
12
+ <% if current_is_author?(@iteration) %>
13
+
14
+ <% case @iteration.status&.to_sym %>
15
+ <% when :created, :cancelled %>
16
+ <% if can_approve?(@iteration) %>
17
+ <%= f.hidden_field :command, value: :approve %>
18
+ <%= f.submit "Approve!" %>
19
+ <% else %>
20
+ <%= f.hidden_field :command, value: :request %>
21
+ <%= f.submit "Request Access" %>
22
+ <% end %>
23
+ <% when :failed %>
24
+ <p>Edit task to attempt to run again.</p>
25
+ <% when :approved %>
26
+ <%= f.hidden_field :command, value: :run %>
27
+ <%= f.submit "Execute" %>
28
+ <% when :started %>
29
+ <%= f.hidden_field :command, value: :cancel %>
30
+ <%= f.submit "CANCEL!", class: "cancel-btn", data: { confirm: "WARNING: Cancelling a command mid-process can be dangerous. Any processes that have already run will not be rolled back. Do you wish to continue?" } %>
31
+ <% when :success %>
32
+ <%= f.hidden_field :command, value: :request %>
33
+ <%= f.submit "Request Re-Run Access" %>
34
+ <% end %>
14
35
 
15
- <% if current_is_author?(@iteration) %>
36
+ <% elsif can_approve?(@iteration) %>
16
37
 
17
- <% case @iteration.status&.to_sym %>
18
- <% when :created, :cancelled %>
19
- <% if can_approve?(@iteration) %>
38
+ <% if @iteration.approved? %>
39
+ <p>Approved. Ready to run.</p>
40
+ <% elsif @iteration.pending? %>
20
41
  <%= f.hidden_field :command, value: :approve %>
21
42
  <%= f.submit "Approve!" %>
22
- <% else %>
23
- <%= f.hidden_field :command, value: :request %>
24
- <%= f.submit "Request Access" %>
25
43
  <% end %>
26
- <% when :failed %>
27
- <p>Edit task to attempt to run again.</p>
28
- <% when :approved %>
29
- <%= f.hidden_field :command, value: :run %>
30
- <%= f.submit "Execute" %>
31
- <% when :started %>
32
- <%= f.hidden_field :command, value: :cancel %>
33
- <%= f.submit "CANCEL!", class: "cancel-btn", data: { confirm: "WARNING: Cancelling a command mid-process can be dangerous. Any processes that have already run will not be rolled back. Do you wish to continue?" } %>
34
- <% when :success %>
35
- <%= f.hidden_field :command, value: :request %>
36
- <%= f.submit "Request Re-Run Access" %>
37
- <% end %>
38
-
39
- <% elsif can_approve?(@iteration) %>
40
44
 
41
- <% if @iteration.approved? %>
42
- <p>Approved. Ready to run.</p>
43
- <% elsif @iteration.pending? %>
44
- <%= f.hidden_field :command, value: :approve %>
45
- <%= f.submit "Approve!" %>
46
45
  <% end %>
46
+ <% end %>
47
47
 
48
+ <% if @iteration&.started_at? %>
49
+ <div class="cmd-console" readonly=true data-status="<%= @iteration.status %>" data-feed="<%= runner_path(@task, @iteration) %>"><%= render partial: "lines", locals: { lines: @iteration&.result } %></div>
48
50
  <% end %>
49
51
  <% end %>
50
52
  <% end %>
@@ -24,18 +24,18 @@
24
24
  Task - Batch of code that typically only needs to be executed once. Requires approval for every new run.
25
25
  <% end %>
26
26
  </p>
27
- <p>
28
- <%= f.radio_button :session_type, :console %>
29
- <%= f.label :session_type, value: :console do %>
30
- Console - Starts a session that allows line-by-line commands to be executed. Requires approval only to begin session.
31
- <% end %>
32
- </p>
33
27
  <p>
34
28
  <%= f.radio_button :session_type, :function %>
35
29
  <%= f.label :session_type, value: :function do %>
36
30
  Function - Reusable batch of code, can accept arguments. Only requires approval on code changes.
37
31
  <% end %>
38
32
  </p>
33
+ <p>
34
+ <%= f.radio_button :session_type, :console %>
35
+ <%= f.label :session_type, value: :console do %>
36
+ Console - Starts a session that allows line-by-line commands to be executed. Requires approval only to begin session.
37
+ <% end %>
38
+ </p>
39
39
  <p>
40
40
  <%= f.radio_button :session_type, :module %>
41
41
  <%= f.label :session_type, value: :module do %>
@@ -1,7 +1,8 @@
1
1
  <div class="cmd-wrapper">
2
- <%= link_to "New Command", cmd_path(:new, :task, session_type: params[:filter] || :task) %> <br>
2
+ <%= link_to "New #{params[:filter].presence&.capitalize || 'Command'}", cmd_path(:new, :task, session_type: params[:filter] || :task) %> <br>
3
3
  <br>
4
- <% ::CommandProposal::Task.session_types.each_with_index do |(session_type, _session_enum), idx| %><%=
4
+ <%= link_to "All", cmd_path(:tasks, current_params.except(:filter)), class: "cmd-tab #{:active unless params.key?(:filter)}"
5
+ %><% ::CommandProposal::Task.session_types.each_with_index do |(session_type, _session_enum), idx| %><%=
5
6
  selected = params[:filter] == session_type.to_s
6
7
  # Offset closing RB tags to fix spacing issues
7
8
  link_to session_type.capitalize, toggled_param(filter: session_type), class: "cmd-tab #{:active if selected}"
@@ -25,7 +25,6 @@ module CommandProposal
25
25
  when :approve then command_approve
26
26
  when :run then command_run
27
27
  when :cancel then command_cancel
28
- when :cancel then command_cancel
29
28
  when :close then command_close
30
29
  end
31
30
 
@@ -8,15 +8,16 @@ module CommandProposal
8
8
  @session = session
9
9
  end
10
10
 
11
- def execute(iteration, inline=false)
11
+ def execute(iteration)
12
12
  @iteration = iteration
13
- @inline = inline
14
13
  prepare
15
14
 
16
15
  run
17
16
 
18
17
  complete
18
+ proposal = ::CommandProposal::Service::ProposalPresenter.new(@iteration)
19
19
  @iteration = nil
20
+ proposal
20
21
  end
21
22
 
22
23
  def quick_run(iteration)
@@ -49,14 +50,16 @@ module CommandProposal
49
50
  stored_stdout = $stdout
50
51
  $stdout = StringIO.new
51
52
  result = nil # Init var for scope
53
+ status = nil
52
54
 
53
55
  running_thread = Thread.new do
54
56
  begin
55
57
  # Run bring functions in here so we can capture any string outputs
56
58
  # OR! Run the full runner and instead of saving to an iteration, return the string for prepending here
57
59
  result = @session.eval("_ = (#{@iteration.code})").inspect # rubocop:disable Security/Eval - Eval is scary, but in this case it's exactly what we need.
60
+ status = :success
58
61
  rescue Exception => e # rubocop:disable Lint/RescueException - Yes, rescue full Exception so that we can catch typos in evals as well
59
- @iteration.status = :failed
62
+ status = :failed
60
63
 
61
64
  result = results_from_exception(e)
62
65
  end
@@ -69,7 +72,10 @@ module CommandProposal
69
72
  @iteration.update(result: $stdout.try(:string).dup)
70
73
  end
71
74
 
72
- running_thread.exit if @iteration.cancelling?
75
+ if @iteration.cancelling?
76
+ running_thread.exit
77
+ status = :cancelled
78
+ end
73
79
 
74
80
  sleep 1
75
81
  end
@@ -79,6 +85,7 @@ module CommandProposal
79
85
  # Not using presence because we want to maintain other empty objects such as [] and {}
80
86
 
81
87
  $stdout = stored_stdout
88
+ @iteration.status = status
82
89
  @iteration.result = [output, "#{result || 'nil'}"].compact.join("\n")
83
90
  end
84
91
 
@@ -91,7 +98,7 @@ module CommandProposal
91
98
  if @iteration.cancelling? || @iteration.cancelled?
92
99
  @iteration.result += "\n\n~~~~~ CANCELLED ~~~~~"
93
100
  @iteration.status = :cancelled
94
- elsif @iteration.failed?
101
+ elsif @iteration.status&.to_sym == :failed
95
102
  # No-op
96
103
  else
97
104
  @iteration.status = :success
@@ -1,3 +1,8 @@
1
+ # gem build command_proposal.gemspec
2
+ # gam "Built version __ of gem."
3
+ # gpo
4
+ # gem push command_proposal-__.gem
5
+
1
6
  module CommandProposal
2
- VERSION = '1.0.1'
7
+ VERSION = '1.0.2'
3
8
  end
@@ -34,14 +34,14 @@
34
34
 
35
35
  # Called when a command is proposed for review
36
36
  config.proposal_callback = Proc.new { |proposal|
37
- # Slack.notify("#{proposal.requester} has proposed #{proposal.name}.\n<Click Here|#{proposal.url}> to view this proposal and approve.")
37
+ # Slack.notify("#{proposal.requester} has proposed #{proposal.name}.\n<#{proposal.url}|Click Here> to view this proposal and approve.")
38
38
  }
39
39
  # Called when a command runs and completes successfully
40
- config.success_callback = Proc.new { |iteration|
41
- # Slack.notify("The task #{proposal.name} has completed in #{proposal.duration}s.\n<Click Here|#{proposal.url}> to view the results.")
40
+ config.success_callback = Proc.new { |proposal|
41
+ # Slack.notify("The task #{proposal.name} has completed in #{proposal.duration}s.\n<#{proposal.url}|Click Here> to view the results.")
42
42
  }
43
43
  # Called when a command runs but fails to complete
44
- config.failed_callback = Proc.new { |iteration|
45
- # Slack.notify("The task #{proposal.name} has failed!\n<Click Here|#{proposal.url}> to see what went wrong.")
44
+ config.failed_callback = Proc.new { |proposal|
45
+ # Slack.notify("The task #{proposal.name} has failed!\n<#{proposal.url}|Click Here> to see what went wrong.")
46
46
  }
47
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_proposal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocco Nicholls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,6 +116,7 @@ files:
116
116
  - app/models/command_proposal/service/json_wrapper.rb
117
117
  - app/models/command_proposal/service/proposal_presenter.rb
118
118
  - app/models/command_proposal/task.rb
119
+ - app/views/command_proposal/tasks/_console_lines.html.erb
119
120
  - app/views/command_proposal/tasks/_console_show.html.erb
120
121
  - app/views/command_proposal/tasks/_function_show.html.erb
121
122
  - app/views/command_proposal/tasks/_lines.html.erb