Add out-of-date notice to admin overview (#20172)
This commit is contained in:
parent
f753df3226
commit
f50e3e7511
3 changed files with 37 additions and 0 deletions
11
app/views/admin/overview/_notices.html.erb
Normal file
11
app/views/admin/overview/_notices.html.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
<% if ForemInstance.deployed_at.to_i.positive? && ForemInstance.deployed_at < 2.weeks.ago %>
|
||||
<div class="crayons-notice crayons-notice--<%= ForemInstance.deployed_at < 4.weeks.ago ? "danger" : "warning" %> mb-6">
|
||||
<p class="p-1">
|
||||
It has been <strong><%= time_ago_in_words ForemInstance.deployed_at %></strong> since this Forem was deployed. We recommend you <a href="https://github.com/forem/forem" class="fw-bold">re-deploy from the main branch</a> to stay up-to-date.
|
||||
</p>
|
||||
<p class="p-1 py-2 fs-s">
|
||||
If you stay out of date for too long, it greatly increases the risk that something could go wrong when you try to re-deploy.
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
<h1 class="crayons-title mb-4">
|
||||
Overview
|
||||
</h1>
|
||||
<%= render "notices" %>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col l:flex-row gap-4">
|
||||
|
|
|
|||
|
|
@ -8,6 +8,31 @@ RSpec.describe "/admin" do
|
|||
allow(FeatureFlag).to receive(:enabled?).and_call_original
|
||||
end
|
||||
|
||||
describe "Notices" do
|
||||
it "does not show warning if deployed at is recent" do
|
||||
allow(ForemInstance).to receive(:deployed_at).and_return(1.day.ago)
|
||||
get admin_path
|
||||
|
||||
expect(response.body).not_to include("If you stay out of date for too long")
|
||||
end
|
||||
|
||||
it "shows warning notice if deployed at is over two weeks ago" do
|
||||
allow(ForemInstance).to receive(:deployed_at).and_return(3.weeks.ago)
|
||||
get admin_path
|
||||
|
||||
expect(response.body).to include("If you stay out of date for too long")
|
||||
expect(response.body).to include("crayons-notice--warning")
|
||||
end
|
||||
|
||||
it "shows danger notice if deployed at is over four weeks ago" do
|
||||
allow(ForemInstance).to receive(:deployed_at).and_return(5.weeks.ago)
|
||||
get admin_path
|
||||
|
||||
expect(response.body).to include("If you stay out of date for too long")
|
||||
expect(response.body).to include("crayons-notice--danger")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Last deployed and Latest Commit ID card" do
|
||||
before do
|
||||
ForemInstance.instance_variable_set(:@deployed_at, nil)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue