Skip to content

Commit 86fe346

Browse files
committed
wip
1 parent 5564bd4 commit 86fe346

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

deps/rabbitmq_management/priv/www/css/main.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ div.form-popup-help {
232232
width: 500px;
233233
z-index: 2;
234234
}
235-
p.warning, div.form-popup-warn { background: #FF9; }
235+
div.warning, p.warning, div.form-popup-warn { background: #FF9; }
236236

237237
div.form-popup-options { z-index: 3; overflow:auto; max-height:95%; }
238238

@@ -255,7 +255,14 @@ div.form-popup-options span:hover {
255255
cursor: pointer;
256256
}
257257

258-
p.warning { padding: 15px; border-radius: 5px; -moz-border-radius: 5px; text-align: center; }
258+
div.warning, p.warning { padding: 15px; border-radius: 5px; -moz-border-radius: 5px; text-align: center; }
259+
div.warning {
260+
margin: 15px 0;
261+
}
262+
263+
div.warning button {
264+
margin: auto;
265+
}
259266

260267
.highlight { min-width: 120px; font-size: 120%; text-align:center; padding:10px; background-color: #ddd; margin: 0 20px 0 0; color: #888; border-radius: 5px; -moz-border-radius: 5px; }
261268
.highlight strong { font-size: 2em; display: block; color: #444; font-weight: normal; }

deps/rabbitmq_management/priv/www/js/tmpl/feature-flags.ejs

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
}
1919
}
2020
if (needs_enabling) { %>
21-
<p class="warning">
22-
All stable feature flags must be enabled after completing an upgrade. Without enabling all flags, upgrading to future minor or major versions of RabbitMQ may not be possible. <a href="https://www.rabbitmq.com/feature-flags.html">[Learn more]</a>
23-
</p>
21+
<div id="ff-disabled-stable-warning" class="warning">
22+
<p>
23+
All stable feature flags must be enabled after completing an upgrade.
24+
Without enabling all flags, upgrading to future minor or major versions
25+
of RabbitMQ may not be possible.
26+
<a href="https://www.rabbitmq.com/docs/feature-flags">[Learn more]</a>
27+
</p>
28+
<button id="ff-enable-all-button" onclick='enable_all_stable_feature_flags(this);'>Enable all stable feature flags</button>
29+
</div>
2430
<% } %>
2531
<div class="section">
2632
<h2>Feature Flags</h2>
@@ -29,7 +35,36 @@
2935
<div class="updatable">
3036
<% if (nonreq_feature_flags.length > 0) { %>
3137
<script>
32-
function handle_feature_flag(checkbox, feature_flag) {
38+
var nonreq_feature_flags = <%= JSON.stringify(nonreq_feature_flags) %>;
39+
40+
function enable_all_stable_feature_flags(button) {
41+
button.disabled = true;
42+
43+
const event = new Event('change');
44+
for (var i = 0; i < nonreq_feature_flags.length; i++) {
45+
var feature_flag = nonreq_feature_flags[i];
46+
if (feature_flag.stability == 'experimental' || feature_flag.state == 'enabled')
47+
continue;
48+
49+
var checkbox = document.getElementById('ff-checkbox-' + feature_flag.name);
50+
if (checkbox.disabled)
51+
continue;
52+
53+
checkbox.dispatchEvent(event);
54+
}
55+
}
56+
57+
function lookup_feature_flag(feature_flag_name) {
58+
for (var i = 0; i < nonreq_feature_flags.length; i++) {
59+
var feature_flag = nonreq_feature_flags[i];
60+
if (feature_flag.name == feature_flag_name)
61+
return feature_flag;
62+
}
63+
}
64+
65+
function handle_feature_flag(checkbox, feature_flag_name) {
66+
var feature_flag = lookup_feature_flag(feature_flag_name);
67+
3368
checkbox.indeterminate = true;
3469
checkbox.disabled = true;
3570
checkbox.checked = false;
@@ -107,8 +142,6 @@ function handle_feature_flag(checkbox, feature_flag) {
107142
}
108143
109144
function enable_feature_flag(checkbox, feature_flag) {
110-
console.log('Enable', feature_flag);
111-
112145
var url = 'api/feature-flags/' + feature_flag.name + '/enable';
113146
var params = {name: feature_flag.name};
114147
@@ -120,9 +153,10 @@ function enable_feature_flag(checkbox, feature_flag) {
120153
},
121154
body: JSON.stringify(params),
122155
}).then((resp) => {
123-
console.log(resp);
124156
if (resp.ok) {
125157
checkbox.checked = true;
158+
159+
feature_flag.state = 'enabled';
126160
} else {
127161
checkbox.checked = false;
128162
checkbox.disabled = false;
@@ -132,6 +166,18 @@ function enable_feature_flag(checkbox, feature_flag) {
132166
});
133167
}
134168
checkbox.indeterminate = false;
169+
}).then(() => {
170+
for (var i = 0; i < nonreq_feature_flags.length; i++) {
171+
var feature_flag = nonreq_feature_flags[i];
172+
if (feature_flag.stability != 'experimental' && feature_flag.state == 'disabled') {
173+
var button = document.getElementById('ff-enable-all-button');
174+
button.disabled = false;
175+
return;
176+
}
177+
}
178+
179+
var warning = document.getElementById('ff-disabled-stable-warning');
180+
warning.style.display = 'none';
135181
});
136182
}
137183
</script>
@@ -215,9 +261,7 @@ function enable_feature_flag(checkbox, feature_flag) {
215261
<% if (feature_flag.state == 'enabled') { %>
216262
checked disabled
217263
<% } %>
218-
onchange='handle_feature_flag(
219-
this,
220-
<%= JSON.stringify(feature_flag) %>);'/>
264+
onchange='handle_feature_flag(this, "<%= feature_flag.name %>");'/>
221265
<label for="ff-checkbox-<%= feature_flag.name %>" class="toggle"/>
222266
</td>
223267
<td>

0 commit comments

Comments
 (0)