env_bro 0.1.2 → 0.2.0

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: 3a59b7350b701724e75c49dd18a2b49c547d26c310148309e815926cabbeb748
4
- data.tar.gz: 602af135dd3431a9fcc12dbaf15d144b63436a6d508b9b80464f7d9a5446a504
3
+ metadata.gz: 21f2b78d6abd4eaeaaa0b84ac0cbe8d56babd647e8423c2ea10820c9d906a28f
4
+ data.tar.gz: '0518eb15e9bab022daf9e5c272fffe85d0bf5938a838223a50690ad5efc65f8d'
5
5
  SHA512:
6
- metadata.gz: 2225c57379b3649247942f9c29c231532f33caeb8b0e2e62c05d7e385fde182ba749336ea4a4f0e4b9b34693d5adc3d066b624ab9e6815959bb05168d2061fdf
7
- data.tar.gz: 786be05f5a2ef29c88530975c95e7219ff68acd24d8f77e457db76d58ccc12d89b05dc98b1db37b1c3c845e49e9716019bca9073ebfa4afee806234929b054a8
6
+ metadata.gz: cd24c5c8ac1ed1496281682f38a679e011f395243be0f48b6c825bad18ab0ad99812cfb15bc97024e0ad36dfdd9cf0a7b91708e064324513d0c576b38d1d6685
7
+ data.tar.gz: 4f745044caedfa94055356f6d164f0ce22c8319a8ec8a653861a1aa4b17a05b6cdcf1a4426e93f893f59aa4b590a39e04dc4dbd3b414ebc4aa9a9a0de4adf3ba
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Propose changes to Rails encrypted credentials without holding the keys.
4
4
 
5
5
  EnvBro manages the credentials of the environment it runs in: on production it edits
6
- `production.yml.enc`, on staging `staging.yml.enc`. Team members with permission open `/admin/env`,
6
+ `production.yml.enc`, on staging `staging.yml.enc`. Team members with permission open the BroHub dashboard (`/bro_hub/env_bro`),
7
7
  pick keys to add, change or remove, and download the re-encrypted file. They commit it on a branch and open a PR. A reviewer uploads the
8
8
  file from the PR and sees which keys changed, with values masked unless they choose to reveal them.
9
9
 
@@ -39,10 +39,27 @@ gem "env_bro", git: "https://github.com/rubydevro/env_bro.git"
39
39
  ```
40
40
 
41
41
  ```sh
42
- bin/rails generate env_bro:install # initializer, route (asks for the path; or --mount-path=/admin/env), migration
42
+ bin/rails generate env_bro:install # BroHub (mount + initializer), then EnvBro's initializer and migration. --mount-path=/bro_hub skips the question
43
43
  bin/rails db:migrate
44
44
  ```
45
45
 
46
+ EnvBro's pages live in [BroHub](https://github.com/rubydevro/bro_hub), the shared dashboard shell for the Bro gems
47
+ (EnvBro, SafeBro, ...). You mount BroHub once and it mounts EnvBro under it:
48
+
49
+ ```ruby
50
+ # config/routes.rb
51
+ mount BroHub::Engine => "/bro_hub" # EnvBro is at /bro_hub/env_bro
52
+ ```
53
+
54
+ BroHub also owns "who is signed in": set `BroHub.config.current_user` once (see the BroHub README) and every Bro gem uses it.
55
+ `config.current_user` below only needs setting when EnvBro must differ.
56
+
57
+ ### Upgrading from 0.1.x
58
+
59
+ Run `bin/rails generate bro_hub:install --remove-direct-mounts`: it mounts BroHub once and comments out the old direct `mount EnvBro::Engine => "..."` line. An old direct mount keeps working
60
+ (EnvBro then shows its own section in the same shell), so you can upgrade in two steps. Two things change in the UI:
61
+ the home page is now an environments overview instead of a redirect, and the layout comes from BroHub.
62
+
46
63
  The generator wraps Rails' built-in `bin/rails env_bro:install:migrations`. Use that task on its own
47
64
  to pick up new migrations after upgrading the gem.
48
65
 
@@ -51,13 +68,15 @@ Then set the permissions in `config/initializers/env_bro.rb`. Everything is deni
51
68
  ```ruby
52
69
  EnvBro.configure do |config|
53
70
  # Who may do what. Each lambda gets the current user.
54
- config.can_propose = ->(user) { user.developer? }
55
- config.can_review = ->(user) { user.admin? }
56
- config.can_reveal = ->(user) { user.admin? }
71
+ config.can_create = ->(user) { user.developer? } # propose new keys
72
+ config.can_update = ->(user) { user.developer? } # propose new values for existing keys
73
+ config.can_destroy = ->(user) { user.lead? } # propose removing keys
74
+ config.can_review = ->(user) { user.lead? } # upload a proposal, see what changed (masked)
75
+ config.can_reveal = ->(user) { user.admin? } # see the actual values in a review (audited)
57
76
 
58
77
  # Defaults shown:
59
78
  # config.parent_controller = "::ApplicationController" # gives access to your auth
60
- # config.current_user = ->(controller) { controller.send(:current_user) }
79
+ # config.current_user = ->(controller) { controller.send(:current_user) } # default: BroHub.config.current_user
61
80
  # config.user_label = ->(user) { user.email }
62
81
  # config.require_ssl = Rails.env.production?
63
82
  # config.metadata_key = "env_bro"
@@ -65,6 +84,17 @@ EnvBro.configure do |config|
65
84
  end
66
85
  ```
67
86
 
87
+ Any of `can_create`, `can_update` and `can_destroy` opens the propose page, which then only
88
+ offers what the user may do (no "add keys" panel without `can_create`, no value fields without
89
+ `can_update`, no remove toggles without `can_destroy`). The server checks every change too.
90
+
91
+ Higher permissions include the lower ones, so you only grant each person one:
92
+
93
+ - `can_review` also grants create, update and destroy.
94
+ - `can_reveal` also grants everything else.
95
+
96
+ `config.can_propose = ->(user) { ... }` is a shorthand that sets create, update and destroy together.
97
+
68
98
  ## One environment per deployment
69
99
 
70
100
  EnvBro uses `Rails.application.credentials`, so it finds the file and key exactly like Rails does
@@ -95,7 +125,7 @@ what's wrong instead of the forms.
95
125
  ```sh
96
126
  bundle install
97
127
  bin/rails test # unit + integration tests
98
- cd test/dummy && bin/rails s # http://localhost:3000
128
+ cd test/dummy && bin/rails s # http://localhost:3000, EnvBro in BroHub at /bro_hub, old direct mount at /admin/env
99
129
  ```
100
130
 
101
131
  The dummy app comes with sample `development` and `test` credentials and keys in
@@ -103,13 +133,16 @@ The dummy app comes with sample `development` and `test` credentials and keys in
103
133
  home page, or append `?as=viewer|developer|admin` to any URL:
104
134
 
105
135
  - `viewer`: no access
106
- - `developer`: can propose changes
107
- - `admin`: can propose, review and reveal values
136
+ - `creator`: can add keys
137
+ - `updater`: can change existing values
138
+ - `developer`: can create, update and remove keys
139
+ - `reviewer`: can review, plus everything a developer can do
140
+ - `admin`: can reveal values, plus everything else
108
141
 
109
142
  To try the full flow:
110
143
 
111
144
  1. As a developer, propose a change and download the file.
112
- 2. As an admin, review that file.
145
+ 2. As a reviewer or admin, review that file.
113
146
 
114
147
  To check the stale-base warning, upload a different proposal as the base file.
115
148
 
@@ -1,6 +1,7 @@
1
1
  module EnvBro
2
2
  class ApplicationController < EnvBro.config.parent_controller.constantize
3
- layout "env_bro/application"
3
+ include BroHub::Layout
4
+ bro_hub_section :env_bro
4
5
 
5
6
  protect_from_forgery with: :exception
6
7
 
@@ -18,10 +19,15 @@ module EnvBro
18
19
  @env_bro_user = EnvBro.config.current_user.call(self)
19
20
  end
20
21
 
21
- # permission: :propose, :review or :reveal
22
+ # BroHub shows this name in the top bar, so it must be the same person EnvBro authorizes.
23
+ def bro_hub_user
24
+ env_bro_user
25
+ end
26
+
27
+ # permission: :create, :update, :destroy, :review or :reveal (higher ones include
28
+ # lower ones), or :propose for "any of create, update, destroy".
22
29
  def env_bro_can?(permission)
23
- return false if env_bro_user.nil?
24
- !!EnvBro.config.public_send(:"can_#{permission}").call(env_bro_user)
30
+ EnvBro.config.allows?(env_bro_user, permission)
25
31
  end
26
32
 
27
33
  def env_bro_authorize!(permission)
@@ -1,13 +1,8 @@
1
1
  module EnvBro
2
2
  class HomeController < ApplicationController
3
+ before_action { raise EnvBro::Forbidden unless env_bro_can?(:propose) || env_bro_can?(:review) }
4
+
3
5
  def index
4
- if env_bro_can?(:propose)
5
- redirect_to new_proposal_path
6
- elsif env_bro_can?(:review)
7
- redirect_to new_review_path
8
- else
9
- raise EnvBro::Forbidden
10
- end
11
6
  end
12
7
  end
13
8
  end
@@ -1,8 +1,10 @@
1
1
  module EnvBro
2
2
  class ProposalsController < ApplicationController
3
- before_action { env_bro_authorize!(:propose) }
3
+ before_action { env_bro_authorize!(:propose) } # any of create, update, destroy
4
4
  before_action :env_bro_require_ready
5
5
 
6
+ helper_method :can_create?, :can_update?, :can_destroy?
7
+
6
8
  def new
7
9
  @new_keys = [ Editor::Change.new(action: "set") ]
8
10
  @edits = {}
@@ -14,6 +16,8 @@ module EnvBro
14
16
  @edits = edit_params.index_by(&:key)
15
17
  changes = @new_keys + @edits.values.reject { |c| c.action == "set" && c.value.blank? }
16
18
 
19
+ authorize_changes!(changes)
20
+
17
21
  result = Editor.new(@environment).apply(changes, author: EnvBro.config.user_label.call(env_bro_user))
18
22
 
19
23
  Audit.record(:proposal_created, user: env_bro_user,
@@ -31,6 +35,23 @@ module EnvBro
31
35
  end
32
36
 
33
37
  private
38
+ def can_create? = env_bro_can?(:create)
39
+ def can_update? = env_bro_can?(:update)
40
+ def can_destroy? = env_bro_can?(:destroy)
41
+
42
+ # Each change needs the matching permission: removing a key is destroy, setting a key
43
+ # that already exists is update, setting a new one is create. Checked on the server, so
44
+ # a hand-built request can't do more than the form offers.
45
+ def authorize_changes!(changes)
46
+ existing = @environment.current_credentials
47
+ changes.each do |change|
48
+ key = change.key.to_s.strip
49
+ next if key.empty?
50
+ permission = change.action == "delete" ? :destroy : (existing.key?(key) ? :update : :create)
51
+ env_bro_authorize!(permission)
52
+ end
53
+ end
54
+
34
55
  # new_keys[0][key], new_keys[0][secret_value], ...
35
56
  def new_key_params
36
57
  indexed_rows(:new_keys).map do |row|
@@ -1,14 +1,20 @@
1
1
  module EnvBro
2
2
  module ApplicationHelper
3
+ # EnvBro's additions to BroHub's styles, once per page (and nonce-friendly).
4
+ def env_bro_styles
5
+ content_for(:head, render("env_bro/shared/page_styles")) unless content_for?(:head)
6
+ nil
7
+ end
8
+
3
9
  def env_bro_masked(value)
4
- return content_tag(:span, "(none)", class: "muted") if value.nil?
10
+ return content_tag(:span, "(none)", class: "bh-cell-muted") if value.nil?
5
11
  length = env_bro_format_value(value).length
6
12
  content_tag(:span, "•" * [ length, 12 ].min, class: "mask", title: "#{length} characters") +
7
- content_tag(:span, " #{length} chars", class: "muted small")
13
+ content_tag(:span, " #{length} chars", class: "bh-cell-muted")
8
14
  end
9
15
 
10
16
  def env_bro_value(value)
11
- return content_tag(:span, "(none)", class: "muted") if value.nil?
17
+ return content_tag(:span, "(none)", class: "bh-cell-muted") if value.nil?
12
18
  content_tag(:code, env_bro_format_value(value), class: "value")
13
19
  end
14
20
 
@@ -16,20 +22,22 @@ module EnvBro
16
22
  value.is_a?(String) ? value : value.to_json
17
23
  end
18
24
 
25
+ STATUS_TAGS = { "added" => "is-green", "changed" => "is-amber", "removed" => "is-red", "unchanged" => "" }.freeze
26
+
19
27
  def env_bro_status_badge(status)
20
- content_tag(:span, status.to_s, class: "badge badge-#{status}")
28
+ content_tag(:span, status.to_s, class: [ "bh-tag", STATUS_TAGS[status.to_s], "tag-#{status}" ].compact_blank)
21
29
  end
22
30
 
23
31
  ENVIRONMENT_BADGES = {
24
- ready: [ "ready", "ok" ],
25
- missing_file: [ "file missing", "danger" ],
26
- missing_key: [ "no key on server", "danger" ],
27
- wrong_key: [ "key doesn't match", "danger" ]
32
+ ready: [ "ready", "is-green" ],
33
+ missing_file: [ "file missing", "is-red" ],
34
+ missing_key: [ "no key on server", "is-red" ],
35
+ wrong_key: [ "key doesn't match", "is-red" ]
28
36
  }.freeze
29
37
 
30
38
  def env_bro_environment_badge(status)
31
39
  label, style = ENVIRONMENT_BADGES.fetch(status)
32
- content_tag(:span, label, class: "badge badge-#{style}")
40
+ content_tag(:span, label, class: "bh-tag #{style}")
33
41
  end
34
42
 
35
43
  def env_bro_time(time)
@@ -39,10 +47,10 @@ module EnvBro
39
47
  # Status of a proposal_created event: live / deployed / superseded / pending.
40
48
  def env_bro_deployment_badge(proposal, live)
41
49
  case proposal.deployment_status(live)
42
- when :live then content_tag(:span, "live since #{env_bro_time(proposal.deployment.created_at)}", class: "badge badge-ok")
43
- when :deployed then content_tag(:span, "deployed #{env_bro_time(proposal.deployment.created_at)}, replaced since", class: "badge badge-neutral")
44
- when :superseded then content_tag(:span, "superseded", class: "badge badge-neutral", title: "Never deployed. A newer proposal is live.")
45
- else content_tag(:span, "not deployed yet", class: "badge badge-changed")
50
+ when :live then content_tag(:span, "live since #{env_bro_time(proposal.deployment.created_at)}", class: "bh-tag is-green")
51
+ when :deployed then content_tag(:span, "deployed #{env_bro_time(proposal.deployment.created_at)}, replaced since", class: "bh-tag")
52
+ when :superseded then content_tag(:span, "superseded", class: "bh-tag", title: "Never deployed. A newer proposal is live.")
53
+ else content_tag(:span, "not deployed yet", class: "bh-tag is-amber")
46
54
  end
47
55
  end
48
56
 
@@ -1,36 +1,29 @@
1
- <% content_for :title, "Audit log" %>
2
- <div class="page-head">
3
- <div>
4
- <h1>Audit log</h1>
5
- <p class="muted">Who proposed, reviewed or revealed what, and when proposals went live. Key names only, never values.</p>
6
- </div>
7
- </div>
1
+ <% env_bro_styles %>
2
+ <% bro_hub_crumb "Audit log" %>
3
+ <%= bro_hub_hero eyebrow: "Audit log · #{@environment.name}", title: @events.size.to_s, subtitle: (@events.size == 1 ? "event" : "events"), tone: :green,
4
+ lead: "Who proposed, reviewed or revealed what, and when proposals went live. Key names only, never values." %>
8
5
 
9
- <div class="panel">
10
- <% if @events.empty? %>
11
- <p class="empty">Nothing recorded yet.</p>
12
- <% else %>
13
- <table>
14
- <thead>
15
- <tr><th>When</th><th>Who</th><th>Event</th><th>Keys</th><th>Status</th></tr>
16
- </thead>
17
- <tbody>
18
- <% @events.each do |event| %>
19
- <tr>
20
- <td class="nowrap small" title="<%= event.created_at.utc.iso8601 %>"><%= env_bro_time(event.created_at) %></td>
21
- <td><%= event.user_label %></td>
22
- <td class="nowrap"><span class="badge badge-neutral"><%= event.event.humanize %></span></td>
23
- <td class="key"><%= safe_join(event.keys, tag.br) %></td>
24
- <td class="nowrap small">
25
- <% if event.event == "proposal_created" %>
26
- <%= env_bro_deployment_badge(event, @live_proposal) %>
27
- <% elsif event.modified_after_review? %>
28
- <span class="badge badge-changed" title="The deployed file is not the one EnvBro built. It was re-encrypted after review.">modified after review</span>
29
- <% end %>
30
- </td>
31
- </tr>
32
- <% end %>
33
- </tbody>
34
- </table>
35
- <% end %>
36
- </div>
6
+ <% if @events.empty? %>
7
+ <div class="bh-table-wrap"><div class="bh-empty">Nothing recorded yet.</div></div>
8
+ <% else %>
9
+ <div class="bh-table-wrap">
10
+ <div class="bh-table eb-cols-audit">
11
+ <div class="bh-row is-head"><span>When</span><span>Who</span><span>Event</span><span>Keys</span><span>Status</span></div>
12
+ <% @events.each do |event| %>
13
+ <div class="bh-row">
14
+ <span class="bh-cell-muted" title="<%= event.created_at.utc.iso8601 %>"><%= env_bro_time(event.created_at) %></span>
15
+ <span class="bh-cell-strong"><%= event.user_label %></span>
16
+ <span><span class="bh-tag"><%= event.event.humanize %></span></span>
17
+ <span><%= safe_join(event.keys, tag.br) %></span>
18
+ <span>
19
+ <% if event.event == "proposal_created" %>
20
+ <%= env_bro_deployment_badge(event, @live_proposal) %>
21
+ <% elsif event.modified_after_review? %>
22
+ <span class="bh-tag is-amber" title="The deployed file is not the one EnvBro built. It was re-encrypted after review.">modified after review</span>
23
+ <% end %>
24
+ </span>
25
+ </div>
26
+ <% end %>
27
+ </div>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% env_bro_styles %>
2
+ <% bro_hub_crumb "Environments" %>
3
+ <%= bro_hub_hero eyebrow: "Encrypted credentials", title: "1", subtitle: "environment", tone: :green,
4
+ lead: "Pick an environment to propose a change. Existing values stay hidden." %>
5
+
6
+ <div class="bh-table-wrap">
7
+ <div class="bh-table eb-cols-envs">
8
+ <div class="bh-row is-head"><span>File</span><span>Keys</span><span>Groups</span><span>Last change</span><span>By</span></div>
9
+ <% credentials = (@environment.current_credentials if @environment.ready?) %>
10
+ <% meta = credentials&.metadata %>
11
+ <% meta = nil unless meta.is_a?(Hash) %>
12
+ <%= link_to (env_bro_can?(:propose) ? new_proposal_path : new_review_path), class: "bh-row eb-env-row" do %>
13
+ <span class="eb-env-name"><%= @environment.name %><small>.yml.enc</small></span>
14
+ <% if credentials %>
15
+ <span><%= credentials.key_paths.size %></span>
16
+ <span><%= credentials.outline.count(&:group) %></span>
17
+ <span class="bh-cell-muted"><%= meta&.fetch("proposed_at", nil).presence || "-" %></span>
18
+ <span><%= meta&.fetch("proposed_by", nil).presence || "-" %></span>
19
+ <% else %>
20
+ <span class="bh-cell-muted">-</span><span class="bh-cell-muted">-</span>
21
+ <span><%= env_bro_environment_badge(@environment.status) %></span><span></span>
22
+ <% end %>
23
+ <% end %>
24
+ </div>
25
+ </div>
@@ -3,5 +3,5 @@
3
3
  autocomplete="off" spellcheck="false" aria-label="New key" class="mono" data-track>
4
4
  <textarea name="new_keys[<%= index %>][secret_value]" rows="1" placeholder="Value"
5
5
  autocomplete="off" spellcheck="false" aria-label="Value" data-track data-autogrow><%= change.value %></textarea>
6
- <button type="button" class="icon-btn" data-remove-new-key title="Remove" aria-label="Remove this new key">✕</button>
6
+ <button type="button" class="icon-btn" data-remove-new-key title="Remove" aria-label="Remove this new key">×</button>
7
7
  </div>
@@ -1,39 +1,46 @@
1
- <% content_for :title, "Propose · #{@environment.name}" %>
2
- <div class="page-head">
3
- <div>
4
- <h1>Propose a change to <%= @environment.name %></h1>
5
- <p class="muted">Existing values stay hidden. Type a value to replace one, tick <em>remove</em> to drop a key, or add new keys.</p>
6
- </div>
7
- </div>
1
+ <% env_bro_styles %>
2
+ <% bro_hub_crumb @environment.name, "Propose a change" %>
3
+ <% content_for :bro_hub_crumb_actions do %>
4
+ <%= bro_hub_crumb_link @environment.name, new_proposal_path, active: true %>
5
+ <% end %>
6
+ <% abilities = [] %>
7
+ <% abilities << "add new keys" if can_create? %>
8
+ <% abilities << "type a value to replace one" if can_update? %>
9
+ <% abilities << "tick <em>remove</em> to drop a key".html_safe if can_destroy? %>
10
+ <%= bro_hub_hero eyebrow: "#{@environment.filename} · #{@outline.count { |line| !line.group }} keys",
11
+ title: "Propose a change", subtitle: content_tag(:span, "to #{@environment.name}", class: "bh-tone-green"),
12
+ lead: safe_join([ "Existing values stay hidden. You can ", safe_join(abilities, ", "), "." ]) %>
8
13
 
9
14
  <% if @error %>
10
- <div class="alert alert-error"><%= @error %></div>
15
+ <div class="eb-banner is-error"><%= @error %></div>
11
16
  <% end %>
12
17
 
13
18
  <%= form_with url: proposal_path, method: :post, local: true, data: { proposal_form: true, turbo: false } do %>
14
- <section class="panel">
15
- <div class="toolbar">
16
- <h2>Add new keys</h2>
17
- <button type="button" class="btn btn-small" data-add-new-key>+ Another key</button>
19
+ <% if can_create? %>
20
+ <section class="bh-block">
21
+ <div class="bh-block-head">
22
+ <h2 class="bh-h2">Add new keys</h2>
23
+ <button type="button" class="eb-add" data-add-new-key>+ Another key</button>
18
24
  </div>
19
25
  <div data-new-keys>
20
26
  <% @new_keys.each_with_index do |change, i| %>
21
27
  <%= render "new_key_row", change: change, index: i %>
22
28
  <% end %>
23
29
  </div>
24
- <p class="hint">Nest keys with dots: <code>stripe.publishable_key</code> goes under <code>stripe:</code>. A new group is created if needed.</p>
30
+ <p class="eb-note">Nest keys with dots: <code>stripe.publishable_key</code> goes under <code>stripe:</code>. A new group is created if needed.</p>
25
31
  </section>
32
+ <% end %>
26
33
 
27
- <section class="panel panel-flush">
28
- <div class="toolbar panel-pad">
29
- <h2><code><%= @environment.filename %></code></h2>
30
- <input type="search" class="filter" placeholder="Filter keys…" data-filter aria-label="Filter keys">
34
+ <section class="bh-block">
35
+ <div class="bh-block-head">
36
+ <h2 class="bh-h2" style="text-transform:none"><code><%= @environment.filename %></code></h2>
37
+ <input type="search" class="bh-input" style="flex:0 1 260px" placeholder="Filter keys…" data-filter aria-label="Filter keys">
31
38
  </div>
32
39
 
33
40
  <% if @outline.empty? %>
34
- <p class="empty">This file has no keys yet. Add some above.</p>
41
+ <p class="bh-hint">This file has no keys yet.<%= " Add some above." if can_create? %></p>
35
42
  <% else %>
36
- <div class="yaml">
43
+ <div class="bh-log eb-keys">
37
44
  <% index = 0 %>
38
45
  <% @outline.each do |line| %>
39
46
  <% if line.group %>
@@ -45,38 +52,48 @@
45
52
  <% removed = edit&.action == "delete" %>
46
53
  <div class="yaml-line yaml-leaf<%= ' is-removed' if removed %><%= ' is-changed' if edit&.value.present? %>" data-leaf="<%= line.path %>">
47
54
  <label class="yaml-key depth-<%= [ line.depth, 6 ].min %>" for="edit_<%= index %>"><%= line.name %>:</label>
48
- <input type="hidden" name="edits[<%= index %>][key]" value="<%= line.path %>">
49
- <textarea name="edits[<%= index %>][secret_value]" id="edit_<%= index %>" rows="1" placeholder="•••••• unchanged"
50
- autocomplete="off" spellcheck="false" data-track data-autogrow<%= ' disabled' if removed %>><%= edit&.value unless removed %></textarea>
51
- <label class="remove-toggle" title="Remove <%= line.path %>">
52
- <input type="checkbox" name="edits[<%= index %>][remove]" value="1" data-track data-remove-toggle<%= ' checked' if removed %>> remove
53
- </label>
55
+ <% if can_update? || can_destroy? %>
56
+ <input type="hidden" name="edits[<%= index %>][key]" value="<%= line.path %>">
57
+ <% end %>
58
+ <% if can_update? %>
59
+ <textarea name="edits[<%= index %>][secret_value]" id="edit_<%= index %>" rows="1" placeholder="•••••• unchanged"
60
+ autocomplete="off" spellcheck="false" data-track data-autogrow<%= ' disabled' if removed %>><%= edit&.value unless removed %></textarea>
61
+ <% else %>
62
+ <span class="bh-cell-muted">••••••</span>
63
+ <% end %>
64
+ <% if can_destroy? %>
65
+ <label class="remove-toggle" title="Remove <%= line.path %>">
66
+ <input type="checkbox" name="edits[<%= index %>][remove]" value="1" data-track data-remove-toggle<%= ' checked' if removed %>> remove
67
+ </label>
68
+ <% end %>
54
69
  </div>
55
70
  <% index += 1 %>
56
71
  <% end %>
57
72
  <% end %>
58
- <p class="empty hidden" data-filter-empty>No keys match.</p>
73
+ <p class="bh-hint hidden" data-filter-empty>No keys match.</p>
59
74
  </div>
60
75
  <% end %>
61
76
  </section>
62
77
 
63
- <div class="submitbar">
64
- <span class="muted" data-summary>No changes yet</span>
65
- <button type="submit" class="btn btn-primary" data-submit>Build &amp; download <%= @environment.filename %></button>
66
- </div>
67
-
68
- <div id="download-notice" class="alert alert-ok" hidden>
78
+ <div id="download-notice" class="eb-banner is-ok" hidden>
69
79
  <strong>Your download should start now.</strong> Next:
70
- <ol class="steps mt-12">
80
+ <ol class="eb-steps">
71
81
  <li>Create a branch in the app repo.</li>
72
82
  <li>Replace <code><%= env_bro_display_path(@environment.content_path) %></code> with the downloaded file.</li>
73
83
  <li>Commit, push and open a pull request. Mention which keys you changed and why.</li>
74
84
  <li>A reviewer checks it in EnvBro and merges.</li>
75
85
  </ol>
76
- <p class="small mt-12">If someone else's change merges first, build your file again. Encrypted files can't be merged.</p>
86
+ <p class="eb-note">If someone else's change merges first, build your file again. Encrypted files can't be merged.</p>
87
+ </div>
88
+
89
+ <div class="bh-sticky">
90
+ <span class="eb-summary" data-summary>No changes yet</span>
91
+ <button type="submit" class="bh-btn is-green is-auto" data-submit>Build &amp; download <%= @environment.filename %></button>
77
92
  </div>
78
93
  <% end %>
79
94
 
80
95
  <template id="new-key-template">
81
96
  <%= render "new_key_row", change: EnvBro::Editor::Change.new(action: "set"), index: "__INDEX__" %>
82
97
  </template>
98
+
99
+ <%= render "env_bro/shared/script" %>
@@ -1,32 +1,29 @@
1
- <% content_for :title, "Review · #{@environment.name}" %>
2
- <div class="page-head">
3
- <div>
4
- <h1>Review a proposed <%= @environment.name %> file</h1>
5
- <p class="muted">Upload the <code><%= @environment.filename %></code> from the pull request to see which keys it changes.</p>
6
- </div>
7
- </div>
1
+ <% env_bro_styles %>
2
+ <% bro_hub_crumb @environment.name, "Review a proposed file" %>
3
+ <%= bro_hub_hero eyebrow: @environment.filename, title: "Review", subtitle: "a proposed file", tone: :green,
4
+ lead: safe_join([ "Upload the ", tag.code(@environment.filename), " from the pull request to see which keys it changes." ]) %>
8
5
 
9
6
  <% if @error %>
10
- <div class="alert alert-error"><%= @error %></div>
7
+ <div class="eb-banner is-error"><%= @error %></div>
11
8
  <% end %>
12
9
 
13
10
  <%= form_with url: review_path, method: :post, multipart: true, local: true, data: { turbo: false } do %>
14
- <div class="panel">
11
+ <section class="bh-block eb-file">
15
12
  <div class="field">
16
- <label for="proposed_file">Proposed file</label>
17
- <input type="file" name="proposed_file" id="proposed_file" accept=".enc" required>
18
- <p class="hint">Download it from the PR branch, e.g. <code>git show my-branch:<%= env_bro_display_path(@environment.content_path) %> &gt; <%= @environment.filename %></code>.</p>
13
+ <label class="bh-field" for="proposed_file">Proposed file
14
+ <input type="file" name="proposed_file" id="proposed_file" accept=".enc" required class="bh-input">
15
+ </label>
16
+ <p class="eb-note">Download it from the PR branch, e.g. <code>git show my-branch:<%= env_bro_display_path(@environment.content_path) %> &gt; <%= @environment.filename %></code>.</p>
19
17
  </div>
20
18
 
21
- <details class="field">
19
+ <details class="eb-details" style="margin-top:28px">
22
20
  <summary>Compare against another version (optional)</summary>
23
- <div class="mt-12">
24
- <label for="base_file">Base file</label>
25
- <input type="file" name="base_file" id="base_file" accept=".enc">
26
- <p class="hint">By default the proposal is compared with the file deployed on this server. Upload the file from <code>main</code> if it is ahead of what's deployed.</p>
27
- </div>
21
+ <label class="bh-field" for="base_file">Base file
22
+ <input type="file" name="base_file" id="base_file" accept=".enc" class="bh-input">
23
+ </label>
24
+ <p class="eb-note">By default the proposal is compared with the file deployed on this server. Upload the file from <code>main</code> if it is ahead of what's deployed.</p>
28
25
  </details>
29
26
 
30
- <button type="submit" class="btn btn-primary">Show changes</button>
31
- </div>
27
+ <button type="submit" class="bh-btn is-green is-auto" style="margin-top:28px">Show changes</button>
28
+ </section>
32
29
  <% end %>