Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions ydb/core/cms/ui/cms.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
'use strict';

function setLocation(parameters) {
window.location.hash = $.param(parameters);
}

function showTab(parameters) {
$('.nav-tabs a[href="#' + parameters.page + '"]').tab('show');
}

function setTab(parameters) {
setLocation(parameters);
showTab(parameters);
}

function main() {
// making main container wider
//$('.container').toggleClass('container container-fluid');

if (window.location.hash == '') {
window.location.hash = 'page=configs';
var activeTabs = $('.nav-tabs a.active');
for (var i = 0; i < activeTabs.length; ++i) {
setTab({page: activeTabs[i].hash.substr(1)});
break;
Comment on lines +22 to +24
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The loop with immediate break is unnecessarily complex. Consider using activeTabs.first() or activeTabs[0] directly since you only need the first active tab.

Suggested change
for (var i = 0; i < activeTabs.length; ++i) {
setTab({page: activeTabs[i].hash.substr(1)});
break;
if (activeTabs.length > 0) {
setTab({page: activeTabs[0].hash.substr(1)});

Copilot uses AI. Check for mistakes.

}
} else {
window.location.hash.substr(1).split('&').forEach((o) => { var a = o.split('='); Parameters[a[0]] = decodeURIComponent(a[1]); } );
if (Parameters.page !== undefined) {
$('.nav-tabs a[href="#' + Parameters.page + '"]').tab('show');
showTab(Parameters);
}
if (Parameters.show !== undefined) {
for (var id of Parameters.show.split(',')) {
Expand All @@ -21,8 +38,7 @@ function main() {
document.getElementById('host-ref').textContent += " - " + window.location.hostname;

$('.nav-tabs a').on('shown.bs.tab', function (e) {
Parameters.page = e.target.hash.substr(1);
window.location.hash = $.param(Parameters);
setLocation({page: e.target.hash.substr(1)});
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setLocation call only sets the page parameter, but the original code preserved all existing Parameters. This change will lose other URL parameters like show when switching tabs.

Suggested change
setLocation({page: e.target.hash.substr(1)});
// Preserve all existing parameters, only update 'page'
var currentParams = {};
if (window.location.hash.length > 1) {
window.location.hash.substr(1).split('&').forEach(function(o) {
var a = o.split('=');
if (a[0]) currentParams[a[0]] = decodeURIComponent(a[1]);
});
}
currentParams.page = e.target.hash.substr(1);
setLocation(currentParams);

Copilot uses AI. Check for mistakes.

})

initCommon();
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/cms/ui/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function onYamlConfigEnabledFetched(data) {
if (data['enabled']) {
$('#yaml-configs-enabled-warning').show();
} else if ($('#yaml-config').hasClass('active')) {
$('#cms-nav a[href="#configs"]').tab('show');
setTab({page: 'configs'});
}
}
}
Expand Down
Loading