ui: gate community wizard capabilities

This commit is contained in:
a.tolmachev
2026-05-03 17:11:30 +00:00
parent 10433d5193
commit 49c46c0d0b
14 changed files with 221 additions and 225 deletions
+54
View File
@@ -175,6 +175,9 @@
function bindProtocolCards() {
document.querySelectorAll('.protocol-card').forEach(function(card) {
card.addEventListener('click', function() {
if (card.hidden || card.getAttribute('aria-disabled') === 'true') {
return;
}
document.querySelectorAll('.protocol-card').forEach(function(item) {
item.classList.remove('selected');
item.setAttribute('aria-checked', 'false');
@@ -214,6 +217,56 @@
});
}
function applyEditionProtocolVisibility(capabilities) {
var supported = capabilities && Array.isArray(capabilities.supported_protocols)
? capabilities.supported_protocols.slice()
: ['rest', 'graphql', 'grpc'];
var hiddenProtocols = [];
document.querySelectorAll('.protocol-card').forEach(function(card) {
var protocol = card.dataset.protocol || 'rest';
var isSupported = supported.indexOf(protocol) >= 0;
card.hidden = !isSupported;
card.setAttribute('aria-disabled', isSupported ? 'false' : 'true');
if (!isSupported) {
card.classList.remove('selected');
card.setAttribute('aria-checked', 'false');
hiddenProtocols.push(protocol);
}
});
if (supported.indexOf(window.wizardProtocol) === -1) {
window.wizardProtocol = supported[0] || 'rest';
}
var selectedCard = document.querySelector('.protocol-card[data-protocol="' + window.wizardProtocol + '"]');
if (selectedCard) {
selectedCard.classList.add('selected');
selectedCard.setAttribute('aria-checked', 'true');
}
var step3Name = document.getElementById('sidebar-step-3-name');
var labels = window.CrankWizardState.step3Labels();
if (step3Name) {
step3Name.textContent = labels[window.wizardProtocol] || tKey('wizard.step3.rest.label');
}
var note = document.getElementById('wizard-edition-protocol-note');
var noteText = document.getElementById('wizard-edition-protocol-note-text');
if (note && noteText) {
if (hiddenProtocols.length) {
note.hidden = false;
noteText.textContent = tfKey('wizard.step1.community_protocol_note', {
protocols: hiddenProtocols.map(function(protocol) {
return tKey('settings.capability.' + protocol);
}).join(', ')
});
} else {
note.hidden = true;
}
}
}
window.CrankWizardShell = {
TOTAL_STEPS: TOTAL_STEPS,
step3PanelId: step3PanelId,
@@ -222,5 +275,6 @@
goToStep: goToStep,
loadWizardPanels: loadWizardPanels,
bindProtocolCards: bindProtocolCards,
applyEditionProtocolVisibility: applyEditionProtocolVisibility,
};
}());