import 'package:flutter/widgets.dart'; import '../../../core/api_gateway.dart'; import '../domain/template_entry.dart'; /// The browser client's create-from-template wording, kept verbatim. const templateCreateNameLabel = 'New pipeline name (required)'; const templateCreateNote = "Creates a new draft pipeline on the server from this template's source; it is not run."; const templateCreateConfirmLabel = 'Create'; const templateCreateSendingLabel = 'Creating…'; const templateCreateCancelLabel = 'Cancel'; const templateCreateCloseLabel = 'Close'; /// Stable test/semantics keys for the prompt. const templateCreateNameKey = ValueKey('template-create-name'); const templateCreateConfirmKey = ValueKey('template-create-confirm'); const templateCreateCancelKey = ValueKey('template-create-cancel'); const templateCreateErrorKey = ValueKey('template-create-error'); const templateCreateSuccessKey = ValueKey('template-create-success'); /// `Create from {name}`, a blank name falling back to the template key. String templateCreateTitle(TemplateEntry template) => 'Create from ${template.name.trim().isNotEmpty ? template.name : template.key}'; /// The server's own created name, else the submitted name, trimmed. String templateCreatedName(JsonMap detail, String submittedName) { final name = '${detail['name'] ?? ''}'.trim(); return name.isNotEmpty ? name : submittedName.trim(); } /// `Created "{name}". It is in the Pipelines list.` — the browser's exact line. String templateCreateSuccess(String created) => 'Created "$created". It is in the Pipelines list.'; /// The server's refusal, verbatim; only a blank reason gets a generic sentence. String describeTemplateCreateError(Object error) { final message = '$error'; return message.trim().isEmpty ? 'The server did not create the pipeline.' : message; }