diff --git a/crates/forge-web/src/i18n/migrate.rs b/crates/forge-web/src/i18n/migrate.rs index 3b790f7..242379f 100644 --- a/crates/forge-web/src/i18n/migrate.rs +++ b/crates/forge-web/src/i18n/migrate.rs @@ -36,6 +36,8 @@ pub enum K { OptionsNote, StartImport, BulkLink, + BulkLinkButton, + BulkOwnerHelp, // Bulk import. BulkTitle, BulkIntro, @@ -124,6 +126,8 @@ const ALL: &[K] = &[ K::OptionsNote, K::StartImport, K::BulkLink, + K::BulkLinkButton, + K::BulkOwnerHelp, K::BulkTitle, K::BulkIntro, K::BulkOwnerGitHub, @@ -227,6 +231,11 @@ fn pair(key: K) -> (&'static str, &'static str) { ), K::StartImport => ("Start import", "İçe aktarmayı başlat"), K::BulkLink => ("Import several repositories", "Birden çok depoyu içe aktar"), + K::BulkLinkButton => ("Choose repositories", "Depoları seç"), + K::BulkOwnerHelp => ( + "The new repositories belong to this account. One whose name is taken there is skipped.", + "Yeni depolar bu hesaba ait olur. Adı orada zaten alınmış olan atlanır.", + ), K::BulkTitle => ("Import several repositories", "Birden çok depoyu içe aktar"), K::BulkIntro => ( "List the repositories of a user or organization, tick the ones you want and import them together.", @@ -341,6 +350,14 @@ pub fn export_ttl_note(lang: Lang, days: u64) -> String { } } +/// The import list's note after a bulk import left some repositories out. `list` says which and why. +pub fn bulk_skipped(lang: Lang, list: &str) -> String { + match lang { + Lang::En => format!("Not imported: {list}. Import them one by one to choose another name."), + Lang::Tr => format!("İçe aktarılmayanlar: {list}. Başka bir ad seçmek için onları tek tek içe aktarın."), + } +} + pub fn progress_of(done: i64, total: i64) -> String { format!("{done} / {total}") } diff --git a/crates/forge-web/src/pages/import.rs b/crates/forge-web/src/pages/import.rs index f586e6e..97c4a5f 100644 --- a/crates/forge-web/src/pages/import.rs +++ b/crates/forge-web/src/pages/import.rs @@ -108,6 +108,12 @@ struct SourceQuery { error: Option, } +#[query_params(error = bad_request)] +struct JobsQuery { + /// The repositories a bulk import left out, with why, as one line. + skipped: Option, +} + #[query_params(error = bad_request)] struct SeenQuery { v: Option, @@ -328,6 +334,15 @@ async fn import_form( source_tabs(lang: lang, base: "/new/import", active: source) + if !is_git { +
+
+ (g::t(lang, K::BulkLink)) + (g::t(lang, K::BulkIntro)) +
+ (g::t(lang, K::BulkLinkButton)) +
+ }

(g::t(lang, K::ImportIntro))

if has_instance { @@ -379,9 +394,6 @@ async fn import_form(
- if !is_git { -

(g::t(lang, K::BulkLink))

- } }) } @@ -684,48 +696,61 @@ async fn bulk_select( if empty { empty_state(title: g::t(lang, K::BulkNone)) } else { +
+
+
+

(g::t(lang, K::TargetOwner))

+

(g::t(lang, K::BulkOwnerHelp))

+
+
+ +
+
+ if form.source != "git" { +
+ option_boxes(lang: lang, opts: opts) +
+ } +
-
-
- - if form.source != "git" { - option_boxes(lang: lang, opts: opts) - } -
} }) @@ -924,6 +949,7 @@ async fn run_bulk( } else { Visibility::Private }; + let mut skipped: Vec = Vec::new(); for (_, full_name) in picked { let Some((remote, inst)) = parse_remote(source, full_name, instance) else { continue; @@ -937,12 +963,21 @@ async fn run_bulk( options, }; let name = default_name(&remote); - // A name already taken, or any refusal, is skipped here; the list page shows the rest. + // A name already taken, or any refusal, skips that one; the list page says which and why. if let Err(message) = begin(cx, viewer, &target, &name, "", visibility, spec).await? { tracing::info!(repo = %remote, %message, "bulk import: skipped a repository"); + skipped.push(format!("{name} ({message})")); } } - Err(see_other("/import").into()) + if skipped.is_empty() { + return Err(see_other("/import").into()); + } + let mut list = skipped.join(", "); + if list.len() > 1500 { + list.truncate(list.floor_char_boundary(1500)); + list.push('…'); + } + Err(see_other(format!("/import?skipped={}", crate::views::enc(&list))).into()) } // ---- jobs ---- @@ -1040,13 +1075,20 @@ async fn recent_imports( } #[component] -async fn jobs_list(lang: Lang, jobs: Vec<(ImportJob, Option)>) -> Result { +async fn jobs_list( + lang: Lang, + jobs: Vec<(ImportJob, Option)>, + skipped: Option, +) -> Result { let empty = jobs.is_empty(); Ok(view! { newrepo_tabs(lang: lang, active: "import")

(g::t(lang, K::JobsTitle))

+ if let Some(message) = skipped { + alert(message: message.as_str()) + } if empty { empty_state(title: g::t(lang, K::NoJobs), (g::t(lang, K::ImportTitle))) @@ -1094,8 +1136,13 @@ async fn jobs_page(cx: &Cx) -> Result { let lang = i18n::lang(cx, Some(&viewer.0)); let state = app_context::(cx); let rows = load_job_rows(state, &viewer.0.id, 50).await?; + let skipped = query_params::(cx)? + .skipped + .clone() + .filter(|s| !s.is_empty() && s.len() < 2000) + .map(|s| g::bulk_skipped(lang, &s)); Ok(view! { cx => - shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows)) + shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows, skipped: skipped)) }) } diff --git a/style/_import.scss b/style/_import.scss index 3cb97a5..ca93383 100644 --- a/style/_import.scss +++ b/style/_import.scss @@ -87,42 +87,106 @@ } } -.import-pick { +// Where the picked repositories go: the owner as a settings row, what comes along under it. +.import-into { gap: 0; - padding: 0; + padding: 4px 22px 16px; + + .action-control select { + min-width: 180px; + } } -.import-pick-all { - margin: 0; - padding: 12px 22px; - border-bottom: 1px solid var(--border); +.import-into-opts { + padding-top: 14px; + border-top: 1px solid var(--border); + + // Four short choices fit on one line here; the single-import form keeps them stacked. + .import-opts { + flex-direction: row; + flex-wrap: wrap; + gap: 8px 22px; + } + + .import-opts > p { + flex-basis: 100%; + } +} + +// The repositories as rows: the whole row is the checkbox's label, a ticked row is tinted. +.import-pick { + gap: 0; + padding: 0; + overflow: hidden; } .import-pick-list { - max-height: 52vh; + max-height: 60vh; + margin: 0; + padding: 0; overflow-y: auto; + list-style: none; + + li + li .import-pick-row { + border-top: 1px solid var(--border); + } } .import-pick-row { - display: flex; - flex-wrap: wrap; - align-items: baseline; - gap: 2px 12px; - padding: 9px 22px; - border-bottom: 1px solid var(--border); + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + align-items: start; + gap: 12px; + margin: 0; + padding: 11px 22px; + cursor: pointer; + + > input { + margin: 2px 0 0; + } - &:last-child { - border-bottom: 0; + &:hover { + background: var(--surface-2); } - .inline { + &:has(input:checked) { + background: var(--accent-soft); + } +} + +.import-pick-all { + align-items: center; + border-bottom: 1px solid var(--border-strong); + font-weight: 600; + + > input { margin: 0; } + + &:has(input:checked) { + background: none; + } +} + +.import-pick-main { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; +} + +.import-pick-title { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 4px 8px; + min-width: 0; } .import-pick-name { font-family: var(--mono); font-size: 0.875rem; + font-weight: 500; } .import-pick-desc { @@ -275,7 +339,7 @@ @media (max-width: 560px) { .import-pick-row, - .import-pick-all { + .import-into { padding-left: 14px; padding-right: 14px; } diff --git a/style/_repo.scss b/style/_repo.scss index 8b1aa4a..4c67388 100644 --- a/style/_repo.scss +++ b/style/_repo.scss @@ -681,6 +681,25 @@ padding: 20px 22px; } +// The way to several repositories at once sits above the one-repository form, as a row with a +// button, so it is seen before the form is filled in. +.import-bulk { + flex-direction: row; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 12px 20px; + padding: 14px 22px; +} + +.import-bulk-text { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; + flex: 1 1 280px; +} + .newrepo-row { display: flex; flex-wrap: wrap;