Skip to content

Commit 170b3e9

Browse files
committed
ability to deprecated distro without removing
1 parent f1b6ace commit 170b3e9

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

app/models/distro.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def all
1010
end
1111
end
1212

13+
def all_active
14+
@all_active ||= all.reject(&:deprecated?)
15+
end
16+
1317
def by_id(id)
1418
find { |i| i.id == id.to_s } || (raise "no such distro '#{id}'")
1519
end
@@ -65,6 +69,10 @@ def slug
6569
id.gsub(/[^0-9a-z]/i, '-')
6670
end
6771

72+
def deprecated?
73+
config['deprecated'] == true
74+
end
75+
6876
private
6977

7078
attr_reader :config

app/views/pages/distros.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<div class="container pt-3">
44

5-
<% ::Distro.all.group_by(&:family).each do |family, distros| %>
5+
<% ::Distro.all_active.group_by(&:family).each do |family, distros| %>
66
<div class="row pt-3 pb-3 align-items-center">
77
<div class="col-md-auto">
88
<%= render partial: 'distro_icon', locals: { family: family, size: 64 } %>

app/views/repositories/index.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<div class="card">
1717
<div class="card-body">
1818
<h6 class="card-title"><%= d.name %> <small class="text-secondary"><%= d.arch %></small></h6>
19+
<% if d.deprecated? %>
20+
<span class="text-warning">Deprecated <a href="#<%= d.id %>"><i class="bi bi-question-circle-fill"></i></a></span>
21+
<% end %>
1922

2023
<ul class="list-group list-group-flush">
2124
<% repos_for_distro.sort_by { |repo| repo.created_at }.each do |repo| %>

test/factories/repositories.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
::FactoryBot.define do
22
factory :repository do
33
project { association :project }
4-
distro_id { ::Distro.all.sample.id }
4+
distro_id { ::Distro.all_active.sample.id }
55
gpg_key_private { nil }
66
gpg_key_public { nil }
77
end

0 commit comments

Comments
 (0)