feat: polish alpine settings and wizard feedback

This commit is contained in:
a.tolmachev
2026-03-31 16:32:59 +03:00
parent 564334e300
commit 7aabf7077a
6 changed files with 167 additions and 336 deletions
+52 -9
View File
@@ -1352,19 +1352,19 @@ function prefillWizardFromEdit(detail, versionDocument) {
}
function bindWizardLiveActions() {
bindClick('wizard-upload-input-sample', uploadInputSampleFromWizard);
bindClick('wizard-upload-output-sample', uploadOutputSampleFromWizard);
bindClick('wizard-generate-draft', generateDraftFromWizard);
bindClick('wizard-run-test', runWizardTest);
bindLiveAction('wizard-upload-input-sample', 'Saving input sample…', uploadInputSampleFromWizard);
bindLiveAction('wizard-upload-output-sample', 'Saving output sample…', uploadOutputSampleFromWizard);
bindLiveAction('wizard-generate-draft', 'Generating draft…', generateDraftFromWizard);
bindLiveAction('wizard-run-test', 'Running test…', runWizardTest);
bindClick('wizard-copy-test-response', copyTestResponseToOutputSample);
bindClick('wizard-export-yaml', exportWizardYaml);
bindClick('wizard-import-yaml', importWizardYaml);
bindClick('wizard-publish-operation', publishWizardOperation);
bindLiveAction('wizard-export-yaml', 'Exporting YAML…', exportWizardYaml);
bindLiveAction('wizard-import-yaml', 'Importing YAML…', importWizardYaml);
bindLiveAction('wizard-publish-operation', 'Publishing operation…', publishWizardOperation);
bindClick('wizard-select-descriptor-set', function() {
var input = document.getElementById('wizard-descriptor-set-input');
if (input) input.click();
});
bindClick('wizard-upload-descriptor-set', uploadDescriptorSetAndDiscover);
bindLiveAction('wizard-upload-descriptor-set', 'Uploading descriptor set…', uploadDescriptorSetAndDiscover);
bindClick('wizard-import-yaml-file-trigger', function() {
var input = document.getElementById('wizard-import-yaml-file');
if (input) input.click();
@@ -1386,6 +1386,48 @@ function bindClick(id, handler) {
});
}
function bindLiveAction(id, busyLabel, handler) {
var element = document.getElementById(id);
if (!element) return;
element.addEventListener('click', function(event) {
event.preventDefault();
runWizardLiveAction(element, busyLabel, handler);
});
}
async function runWizardLiveAction(button, busyLabel, handler) {
if (!button || button.dataset.busy === 'true') {
return;
}
var originalLabel = button.textContent;
button.dataset.busy = 'true';
button.disabled = true;
button.classList.add('is-busy');
button.textContent = busyLabel;
try {
await handler();
} catch (error) {
showWizardLiveStatus(
'Live action failed',
error && error.message ? error.message : 'The backend request failed. Review the draft and try again.',
true
);
if (window.CrankUi) {
window.CrankUi.error(
error && error.message ? error.message : 'The backend request failed. Review the draft and try again.',
'Wizard action failed'
);
}
} finally {
button.dataset.busy = 'false';
button.disabled = false;
button.classList.remove('is-busy');
button.textContent = originalLabel;
}
}
function updateWizardProtocolVisibility() {
var grpcTools = document.getElementById('wizard-grpc-live-tools');
if (grpcTools) grpcTools.style.display = wizardProtocol === 'grpc' ? '' : 'none';
@@ -1399,7 +1441,8 @@ function showWizardLiveStatus(title, text, isError) {
titleEl.textContent = title;
textEl.textContent = text;
root.style.display = '';
root.style.borderColor = isError ? 'rgba(248, 113, 113, 0.35)' : '';
root.classList.toggle('is-error', !!isError);
root.classList.toggle('is-success', !isError);
}
function currentDraftVersion() {