Add destructive confirmation and import guidance
This commit is contained in:
@@ -185,6 +185,22 @@ function showWizardLiveStatus(title, text, isError) {
|
||||
root.classList.toggle('is-success', !isError);
|
||||
}
|
||||
|
||||
function showPendingImportGuidance() {
|
||||
var raw = sessionStorage.getItem('crank_import_guidance');
|
||||
if (!raw) return;
|
||||
sessionStorage.removeItem('crank_import_guidance');
|
||||
try {
|
||||
var warnings = JSON.parse(raw);
|
||||
if (!Array.isArray(warnings) || warnings.length === 0) return;
|
||||
showWizardLiveStatus(
|
||||
tKey('wizard.yaml.imported_with_warnings'),
|
||||
warnings.map(function(warning) { return '• ' + warning; }).join('\n')
|
||||
);
|
||||
} catch (_) {
|
||||
// Ignore invalid stale session data.
|
||||
}
|
||||
}
|
||||
|
||||
function currentDraftVersion() {
|
||||
if (wizardCurrentOperation && wizardCurrentOperation.draft_version_ref) {
|
||||
return wizardCurrentOperation.draft_version_ref.version;
|
||||
@@ -487,6 +503,9 @@ async function importWizardYaml() {
|
||||
return;
|
||||
}
|
||||
var imported = await window.CrankApi.importOperation(wizardWorkspaceId, yamlDocument, 'upsert');
|
||||
if (Array.isArray(imported.warnings) && imported.warnings.length > 0) {
|
||||
sessionStorage.setItem('crank_import_guidance', JSON.stringify(imported.warnings));
|
||||
}
|
||||
showWizardLiveStatus(tKey('wizard.yaml.imported'), tKey('wizard.yaml.imported_body'));
|
||||
window.location.href = window.location.pathname + '?mode=edit&operationId=' + encodeURIComponent(imported.operation_id);
|
||||
}
|
||||
@@ -587,9 +606,10 @@ function copyTestResponseToOutputSample() {
|
||||
showWizardLiveStatus(tKey('wizard.test.response_copied'), tKey('wizard.test.response_copied_body'));
|
||||
}
|
||||
|
||||
window.CrankWizardLive = {
|
||||
window.CrankWizardLive = {
|
||||
saveOperation: saveOperation,
|
||||
loadOperationForEdit: loadOperationForEdit,
|
||||
showPendingImportGuidance: showPendingImportGuidance,
|
||||
bindWizardLiveActions: bindWizardLiveActions,
|
||||
updateWizardProtocolVisibility: updateWizardProtocolVisibility,
|
||||
renderAgentFacingPreview: renderAgentFacingPreview,
|
||||
|
||||
Reference in New Issue
Block a user