豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit be741de

Browse files
authored
Merge pull request #986 from pkrisko/feat/add-version-check-enabled-config
Add version_check_enabled config to skip version.js in UI
2 parents bc8e58d + d17bc3b commit be741de

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

lib/flipper/ui/configuration.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class Configuration
4545
# false and it will go away. Defaults to true.
4646
attr_accessor :cloud_recommendation
4747

48+
# Public: Set to false to disable the version check that fetches the
49+
# latest release from flippercloud.io. Useful when a strict Content
50+
# Security Policy is in place. Defaults to true.
51+
attr_accessor :version_check_enabled
52+
4853
# Public: What should show up in the form to add actors. This can be
4954
# different per application since flipper_id's can be whatever an
5055
# application needs. Defaults to "a flipper id".
@@ -114,6 +119,7 @@ def initialize
114119
@feature_removal_enabled = true
115120
@fun = true
116121
@cloud_recommendation = true
122+
@version_check_enabled = true
117123
@add_actor_placeholder = "a flipper id"
118124
@descriptions_source = DEFAULT_DESCRIPTIONS_SOURCE
119125
@actor_names_source = DEFAULT_ACTOR_NAMES_SOURCE

lib/flipper/ui/views/layout.erb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
<%- end -%>
1919

2020
<div class="text-muted small text-end">
21-
<a href="#" class="badge text-bg-warning ms-2 d-none" style="font-size:100%" id="new-version-badge" data-version="<%= Flipper::VERSION %>">
22-
</a>
21+
<% if Flipper::UI.configuration.version_check_enabled %>
22+
<a href="#" class="badge text-bg-warning ms-2 d-none" style="font-size:100%" id="new-version-badge" data-version="<%= Flipper::VERSION %>">
23+
</a>
24+
<% end %>
2325

2426
<% if Flipper.deprecated_ruby_version? %>
2527
<a href="https://github.com/flippercloud/flipper/pull/776" class="badge text-bg-danger ms-2" style="font-size:100%">
@@ -83,6 +85,8 @@
8385
<script src="<%= script_name + popper_js[:src] %>" integrity="<%= popper_js[:hash] %>" crossorigin="anonymous"></script>
8486
<script src="<%= script_name + bootstrap_js[:src] %>" integrity="<%= bootstrap_js[:hash] %>" crossorigin="anonymous"></script>
8587
<script src="<%= script_name %>/js/application.js?v=<%= Flipper::VERSION %>"></script>
86-
<script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
88+
<% if Flipper::UI.configuration.version_check_enabled %>
89+
<script src="<%= script_name %>/js/version.js?v=<%= Flipper::VERSION %>"></script>
90+
<% end %>
8791
</body>
8892
</html>

spec/flipper/ui/configuration_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@
7373
end
7474
end
7575

76+
describe "#version_check_enabled" do
77+
it "has default value" do
78+
expect(configuration.version_check_enabled).to eq(true)
79+
end
80+
81+
it "can be updated" do
82+
configuration.version_check_enabled = false
83+
expect(configuration.version_check_enabled).to eq(false)
84+
end
85+
end
86+
7687
describe "#feature_removal_enabled" do
7788
it "has default value" do
7889
expect(configuration.feature_removal_enabled).to eq(true)

0 commit comments

Comments
 (0)