Skip to content

Commit f7a740c

Browse files
committed
rabbit_feature_flags: Rework the management UI page
[Why] The "Feature flags" admin section had several issues: * It was not designed for experimental feature flags. What was done for RabbitMQ 4.0.0 was still unclear as to what a user should expect for experimental feature flags. * The UI uses synchronous requests from the browser main thread. It means that for a feature flag that has a long running migration callback, the browser tab could freeze for a very long time. [How] The feature flags table is reworked and now displays: * a series of icons to highlight the following: * a feature flag that has a migration function and thus that can take time to be enabled * a feature flag that is experimental * whether this experimental feature flag is supported or not * a toggle to quickly show if a feature flag is enabled or not and let the user enable it at the same time. For stable feature flags, when a user click on the toggle, the toggle goes into an intermediate state while waiting for the response from the broker. If the response is successful, the toggle is green. Otherwise it goes back to red and the error is displayed in a popup as before. For experimental feature flags, when a user click on the toggle, a popup is displayed to let the user know of the possible constraints and consequences, with one or two required checkboxes to tick so the user confirms they understand the message. The feature flag is enabled only after the user validates the popup. The displayed message and the checkboxes depend on if the experimental feature flag is supported or not (it is a new attribute of experimental feature flags). The request to enable feature flags now uses the modern `fetch()` API. Therefore it uses Javascript promises and does not block the main thread: the UI remains responsive while a migration callback runs. Finally, an "Enable all stable feature flags" button has been added to the warning that tells the user some stable feature flags are still disabled. V2: Pause auto-refresh while a feature flag is being handled. This fixes some display inconsistencies.
1 parent d2d6082 commit f7a740c

File tree

3 files changed

+416
-119
lines changed

3 files changed

+416
-119
lines changed

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

Lines changed: 55 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; }
@@ -367,3 +374,49 @@ div.bindings-wrapper p.arrow { font-size: 200%; }
367374
}
368375

369376
table.dynamic-shovels td label {width: 200px; margin-right:10px;padding: 4px 0px 5px 0px}
377+
378+
input[type=checkbox].toggle {
379+
display: none;
380+
}
381+
382+
label.toggle {
383+
cursor: pointer;
384+
text-indent: -9999px;
385+
width: 32px;
386+
height: 16px;
387+
background: #ff5630;
388+
display: block;
389+
border-radius: 16px;
390+
position: relative;
391+
margin: auto;
392+
}
393+
394+
label.toggle:after {
395+
content: '';
396+
position: absolute;
397+
top: 2px;
398+
left: 2px;
399+
width: 12px;
400+
height: 12px;
401+
background: #fff;
402+
border-radius: 12px;
403+
transition: 0.3s;
404+
}
405+
406+
input.toggle:indeterminate + label.toggle {
407+
background: #ffab00;
408+
}
409+
410+
input.toggle:checked + label.toggle {
411+
background: #36b37e;
412+
}
413+
414+
input.toggle:indeterminate + label.toggle:after {
415+
left: calc(50%);
416+
transform: translateX(-50%);
417+
}
418+
419+
input.toggle:checked + label.toggle:after {
420+
left: calc(100% - 2px);
421+
transform: translateX(-100%);
422+
}

deps/rabbitmq_management/priv/www/js/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,23 @@ function reset_timer() {
303303
}
304304
}
305305

306+
function pause_auto_refresh() {
307+
if (typeof globalThis.rmq_webui_auto_refresh_paused == 'undefined')
308+
globalThis.rmq_webui_auto_refresh_paused = 0;
309+
310+
globalThis.rmq_webui_auto_refresh_paused++;
311+
if (timer != null) {
312+
clearInterval(timer);
313+
}
314+
}
315+
316+
function resume_auto_refresh() {
317+
globalThis.rmq_webui_auto_refresh_paused--;
318+
if (globalThis.rmq_webui_auto_refresh_paused == 0) {
319+
reset_timer();
320+
}
321+
}
322+
306323
function update_manual(div, query) {
307324
var path;
308325
var template;

0 commit comments

Comments
 (0)