deleted = true does enforce requireed fields2
This commit is contained in:
@@ -616,7 +616,6 @@ import-success-message = Vloženo { $inserted ->
|
||||
[few] { $source_rows } připravených řádků
|
||||
*[other] { $source_rows } připravených řádků
|
||||
}.
|
||||
import-success-warnings = Upozornění: { $warnings }
|
||||
|
||||
# --- Import v průběhu -------------------------------------------------------
|
||||
import-progress-heading = Importuje se do { $table }
|
||||
|
||||
@@ -605,7 +605,6 @@ import-success-message = Inserted { $inserted ->
|
||||
[one] { $source_rows } prepared row
|
||||
*[other] { $source_rows } prepared rows
|
||||
}.
|
||||
import-success-warnings = Warnings: { $warnings }
|
||||
|
||||
# --- The import while it runs ----------------------------------------------
|
||||
import-progress-heading = Importing into { $table }
|
||||
|
||||
@@ -614,7 +614,6 @@ import-success-message = Vložený { $inserted ->
|
||||
[one] { $source_rows } pripraveného riadka
|
||||
*[other] { $source_rows } pripravených riadkov
|
||||
}.
|
||||
import-success-warnings = Upozornenia: { $warnings }
|
||||
|
||||
# --- Import počas behu ------------------------------------------------------
|
||||
import-progress-heading = Importuje sa do { $table }
|
||||
|
||||
@@ -302,12 +302,11 @@ pub(crate) async fn import_progress(
|
||||
|
||||
let response = match &snapshot.outcome {
|
||||
None => Html(ui::render_progress(locale, &id, &snapshot)).into_response(),
|
||||
Some(Outcome::Succeeded { warnings }) => Html(ui::render_success(
|
||||
Some(Outcome::Succeeded) => Html(ui::render_success(
|
||||
locale,
|
||||
snapshot.inserted,
|
||||
snapshot.total_rows,
|
||||
&snapshot.table_name,
|
||||
warnings,
|
||||
))
|
||||
.into_response(),
|
||||
Some(Outcome::RowFailed {
|
||||
@@ -448,19 +447,7 @@ async fn run_import(job: Running) {
|
||||
Ok(response) => {
|
||||
let response = response.into_inner();
|
||||
let inserted = usize::try_from(response.inserted_rows).unwrap_or(staged);
|
||||
let warnings = response
|
||||
.warnings
|
||||
.into_iter()
|
||||
.map(|warning| {
|
||||
format!(
|
||||
"CSV row {} ({}): {}",
|
||||
warning.row_index + 2,
|
||||
warning.table_name,
|
||||
warning.message,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
jobs.finish(&job.id, inserted, Outcome::Succeeded { warnings });
|
||||
jobs.finish(&job.id, inserted, Outcome::Succeeded);
|
||||
}
|
||||
Err(error) => {
|
||||
abort_import(&job, &import_id).await;
|
||||
|
||||
@@ -34,7 +34,7 @@ const KEEP_FINISHED: Duration = Duration::from_secs(300);
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) enum Outcome {
|
||||
/// Every staged row was committed atomically.
|
||||
Succeeded { warnings: Vec<String> },
|
||||
Succeeded,
|
||||
/// The backend stopped on one row. No rows from the import were committed.
|
||||
RowFailed {
|
||||
status: StatusCode,
|
||||
@@ -255,7 +255,7 @@ mod tests {
|
||||
assert!(jobs.is_running("session"));
|
||||
assert!(!jobs.is_running("other"));
|
||||
|
||||
jobs.finish(&id, 10, Outcome::Succeeded { warnings: Vec::new() });
|
||||
jobs.finish(&id, 10, Outcome::Succeeded);
|
||||
assert!(!jobs.is_running("session"));
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ mod tests {
|
||||
inserted: 0,
|
||||
total_rows: 0,
|
||||
elapsed: Duration::from_secs(1),
|
||||
outcome: Some(Outcome::Succeeded { warnings: Vec::new() }),
|
||||
outcome: Some(Outcome::Succeeded),
|
||||
};
|
||||
|
||||
assert_eq!(snapshot.percent(), 100);
|
||||
|
||||
@@ -169,23 +169,14 @@ pub(crate) fn render_success(
|
||||
inserted: usize,
|
||||
prepared_rows: usize,
|
||||
table_name: &str,
|
||||
warnings: &[String],
|
||||
) -> String {
|
||||
let mut message = tr!(
|
||||
let message = tr!(
|
||||
locale,
|
||||
"import-success-message",
|
||||
"inserted" => inserted as i64,
|
||||
"source_rows" => prepared_rows as i64,
|
||||
"table" => table_name.to_string(),
|
||||
);
|
||||
if !warnings.is_empty() {
|
||||
message.push(' ');
|
||||
message.push_str(&tr!(
|
||||
locale,
|
||||
"import-success-warnings",
|
||||
"warnings" => warnings.join("; "),
|
||||
));
|
||||
}
|
||||
render(&ImportSuccessDialog {
|
||||
locale,
|
||||
title: &tr!(locale, "import-success-title"),
|
||||
@@ -495,7 +486,7 @@ mod tests {
|
||||
/// dialog the user has to actively dismiss, not a toast on its own timer.
|
||||
#[test]
|
||||
fn a_finished_import_answers_with_a_dismissible_dialog_not_a_toast() {
|
||||
let html = render_success(Locale::English, 500, 500, "customers", &[]);
|
||||
let html = render_success(Locale::English, 500, 500, "customers");
|
||||
|
||||
assert!(!html.contains("Template error"), "{html}");
|
||||
assert!(html.contains(r#"role="dialog""#), "{html}");
|
||||
@@ -508,18 +499,4 @@ mod tests {
|
||||
assert!(html.contains("keydown.esc"), "{html}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_finished_import_displays_non_blocking_warnings() {
|
||||
let html = render_success(
|
||||
Locale::English,
|
||||
1,
|
||||
1,
|
||||
"customers",
|
||||
&["CSV row 2 (customers): Deleted row omitted required column 'name'".to_string()],
|
||||
);
|
||||
|
||||
assert!(html.contains("Warnings:"), "{html}");
|
||||
assert!(html.contains("CSV row 2"), "{html}");
|
||||
assert!(html.contains("Deleted row omitted required column"), "{html}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user