ui: use hidden state for grpc wizard panels

This commit is contained in:
a.tolmachev
2026-05-02 14:02:26 +00:00
parent 558bce385d
commit 4203c34dcf
2 changed files with 35 additions and 35 deletions
+24 -24
View File
@@ -808,12 +808,12 @@ function selectGrpcSource(source) {
document.querySelectorAll('.grpc-source-btn').forEach(function(btn) {
btn.classList.toggle('active', btn.dataset.source === source);
});
document.getElementById('grpc-src-proto').style.display = source === 'proto' ? '' : 'none';
document.getElementById('grpc-src-reflection').style.display = source === 'reflection' ? '' : 'none';
document.getElementById('grpc-src-manual').style.display = source === 'manual' ? '' : 'none';
document.getElementById('grpc-src-proto').hidden = source !== 'proto';
document.getElementById('grpc-src-reflection').hidden = source !== 'reflection';
document.getElementById('grpc-src-manual').hidden = source !== 'manual';
// hide shared detail when switching sources
var detail = document.getElementById('grpc-method-detail');
if (detail) detail.style.display = 'none';
if (detail) detail.hidden = true;
selectedRpcMethod = null;
}
@@ -908,7 +908,7 @@ function renderServiceResults(parsed, ids) {
var notice = document.getElementById(ids.notice);
var countEl = document.getElementById(ids.count);
if (notice) {
notice.style.display = parsed.streamingCount > 0 ? '' : 'none';
notice.hidden = parsed.streamingCount <= 0;
if (countEl && parsed.streamingCount > 0) countEl.textContent = parsed.streamingCount;
}
@@ -959,8 +959,8 @@ function renderServiceResults(parsed, ids) {
});
}
document.getElementById(ids.view).style.display = '';
document.getElementById('grpc-method-detail').style.display = 'none';
document.getElementById(ids.view).hidden = false;
document.getElementById('grpc-method-detail').hidden = true;
}
function renderParsedProto(parsed) {
@@ -1016,12 +1016,12 @@ function selectRpcMethod(btn) {
if (resTypeEl) resTypeEl.textContent = resType;
var sigGrid = document.getElementById('grpc-detail-sig');
if (sigGrid) sigGrid.style.display = '';
if (sigGrid) sigGrid.hidden = false;
renderFieldList('grpc-req-fields', reqType);
renderFieldList('grpc-res-fields', resType);
document.getElementById('grpc-method-detail').style.display = '';
document.getElementById('grpc-method-detail').hidden = false;
}
function renderFieldList(elId, typeName) {
@@ -1086,12 +1086,12 @@ function showProtoFileInfo(name, size) {
var info = document.getElementById('proto-file-info');
var nameEl = document.getElementById('proto-file-name');
var sizeEl = document.getElementById('proto-file-size');
if (dropzone) dropzone.style.display = 'none';
if (info) info.style.display = '';
if (dropzone) dropzone.hidden = true;
if (info) info.hidden = false;
if (nameEl) nameEl.textContent = name;
if (sizeEl) sizeEl.textContent = (size / 1024).toFixed(1) + ' KB';
// hide paste area
document.getElementById('proto-paste-area').style.display = 'none';
document.getElementById('proto-paste-area').hidden = true;
document.getElementById('proto-paste-btn').textContent = 'Paste content';
}
@@ -1099,9 +1099,9 @@ function resetProto() {
var dropzone = document.getElementById('proto-dropzone');
var info = document.getElementById('proto-file-info');
var parsedView = document.getElementById('proto-parsed-view');
if (dropzone) dropzone.style.display = '';
if (info) info.style.display = 'none';
if (parsedView) parsedView.style.display = 'none';
if (dropzone) dropzone.hidden = false;
if (info) info.hidden = true;
if (parsedView) parsedView.hidden = true;
var fileInput = document.getElementById('proto-file-input');
if (fileInput) fileInput.value = '';
protoParsed = null;
@@ -1113,8 +1113,8 @@ function toggleProtoPaste() {
var area = document.getElementById('proto-paste-area');
var btn = document.getElementById('proto-paste-btn');
if (!area) return;
var open = area.style.display !== 'none';
area.style.display = open ? 'none' : '';
var open = !area.hidden;
area.hidden = open;
if (btn) btn.textContent = open ? 'Paste content' : 'Cancel paste';
if (!open) {
var ta = document.getElementById('proto-paste-input');
@@ -1125,7 +1125,7 @@ function toggleProtoPaste() {
function cancelProtoPaste() {
var area = document.getElementById('proto-paste-area');
var btn = document.getElementById('proto-paste-btn');
if (area) area.style.display = 'none';
if (area) area.hidden = true;
if (btn) btn.textContent = 'Paste content';
}
@@ -1134,13 +1134,13 @@ function parseProtoPasted() {
if (!ta || !ta.value.trim()) return;
var parsed = parseProto(ta.value);
wizardProtoUpload = { fileName: 'pasted.proto', content: ta.value };
document.getElementById('proto-paste-area').style.display = 'none';
document.getElementById('proto-paste-area').hidden = true;
var dropzone = document.getElementById('proto-dropzone');
if (dropzone) dropzone.style.display = 'none';
if (dropzone) dropzone.hidden = true;
var info = document.getElementById('proto-file-info');
var nameEl = document.getElementById('proto-file-name');
var sizeEl = document.getElementById('proto-file-size');
if (info) info.style.display = '';
if (info) info.hidden = false;
if (nameEl) nameEl.textContent = 'pasted.proto';
if (sizeEl) sizeEl.textContent = (ta.value.length / 1024).toFixed(1) + ' KB';
renderParsedProto(parsed);
@@ -1197,7 +1197,7 @@ function grpcManualRouteInput(val) {
var detail = document.getElementById('grpc-method-detail');
var sigGrid = document.getElementById('grpc-detail-sig');
if (!val || !val.startsWith('/') || val.indexOf('/', 1) === -1) {
if (detail) detail.style.display = 'none';
if (detail) detail.hidden = true;
return;
}
// Parse service + method from route: /[pkg.]Service/Method
@@ -1213,10 +1213,10 @@ function grpcManualRouteInput(val) {
if (sub) sub.textContent = serviceName + '/' + methodName;
// hide sig grid in manual mode (no field data)
if (sigGrid) sigGrid.style.display = 'none';
if (sigGrid) sigGrid.hidden = true;
grpcManualTypeInput();
if (detail) detail.style.display = '';
if (detail) detail.hidden = false;
}
function grpcManualTypeInput() {