Bulk import picks repositories as rows under an "import into" card, and the bulk import is a visible row on the import page
Browse files at this commit101fb760f5528ab943b7190af3a17dec5050e1c2Parent: a7c2717- style
- bulk import picks repositories as rows under an "import into" card, and the bulk import is a visible row on the import page
- fix
- repositories a bulk import skips (name taken) are now listed instead of only logged
4 changed files +202 -55
- crates/forge-web/src/i18n/migrate.rs +17 -0
- crates/forge-web/src/pages/import.rs +85 -38
- style/_import.scss +81 -17
- style/_repo.scss +19 -0
crates/forge-web/src/i18n/migrate.rsmodified+17 -0
| @@ -36,6 +36,8 @@ pub enum K { | |||
| 36 | OptionsNote, | 36 | OptionsNote, |
| 37 | StartImport, | 37 | StartImport, |
| 38 | BulkLink, | 38 | BulkLink, |
| 39 | + BulkLinkButton, | ||
| 40 | + BulkOwnerHelp, | ||
| 39 | // Bulk import. | 41 | // Bulk import. |
| 40 | BulkTitle, | 42 | BulkTitle, |
| 41 | BulkIntro, | 43 | BulkIntro, |
| @@ -124,6 +126,8 @@ const ALL: &[K] = &[ | |||
| 124 | K::OptionsNote, | 126 | K::OptionsNote, |
| 125 | K::StartImport, | 127 | K::StartImport, |
| 126 | K::BulkLink, | 128 | K::BulkLink, |
| 129 | + K::BulkLinkButton, | ||
| 130 | + K::BulkOwnerHelp, | ||
| 127 | K::BulkTitle, | 131 | K::BulkTitle, |
| 128 | K::BulkIntro, | 132 | K::BulkIntro, |
| 129 | K::BulkOwnerGitHub, | 133 | K::BulkOwnerGitHub, |
| @@ -227,6 +231,11 @@ fn pair(key: K) -> (&'static str, &'static str) { | |||
| 227 | ), | 231 | ), |
| 228 | K::StartImport => ("Start import", "İçe aktarmayı başlat"), | 232 | K::StartImport => ("Start import", "İçe aktarmayı başlat"), |
| 229 | K::BulkLink => ("Import several repositories", "Birden çok depoyu içe aktar"), | 233 | K::BulkLink => ("Import several repositories", "Birden çok depoyu içe aktar"), |
| 234 | + K::BulkLinkButton => ("Choose repositories", "Depoları seç"), | ||
| 235 | + K::BulkOwnerHelp => ( | ||
| 236 | + "The new repositories belong to this account. One whose name is taken there is skipped.", | ||
| 237 | + "Yeni depolar bu hesaba ait olur. Adı orada zaten alınmış olan atlanır.", | ||
| 238 | + ), | ||
| 230 | K::BulkTitle => ("Import several repositories", "Birden çok depoyu içe aktar"), | 239 | K::BulkTitle => ("Import several repositories", "Birden çok depoyu içe aktar"), |
| 231 | K::BulkIntro => ( | 240 | K::BulkIntro => ( |
| 232 | "List the repositories of a user or organization, tick the ones you want and import them together.", | 241 | "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 { | |||
| 341 | } | 350 | } |
| 342 | } | 351 | } |
| 343 | 352 | ||
| 353 | +/// The import list's note after a bulk import left some repositories out. `list` says which and why. | ||
| 354 | +pub fn bulk_skipped(lang: Lang, list: &str) -> String { | ||
| 355 | + match lang { | ||
| 356 | + Lang::En => format!("Not imported: {list}. Import them one by one to choose another name."), | ||
| 357 | + Lang::Tr => format!("İçe aktarılmayanlar: {list}. Başka bir ad seçmek için onları tek tek içe aktarın."), | ||
| 358 | + } | ||
| 359 | +} | ||
| 360 | + | ||
| 344 | pub fn progress_of(done: i64, total: i64) -> String { | 361 | pub fn progress_of(done: i64, total: i64) -> String { |
| 345 | format!("{done} / {total}") | 362 | format!("{done} / {total}") |
| 346 | } | 363 | } |
crates/forge-web/src/pages/import.rsmodified+85 -38
| @@ -108,6 +108,12 @@ struct SourceQuery { | |||
| 108 | error: Option<String>, | 108 | error: Option<String>, |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | +#[query_params(error = bad_request)] | ||
| 112 | +struct JobsQuery { | ||
| 113 | + /// The repositories a bulk import left out, with why, as one line. | ||
| 114 | + skipped: Option<String>, | ||
| 115 | +} | ||
| 116 | + | ||
| 111 | #[query_params(error = bad_request)] | 117 | #[query_params(error = bad_request)] |
| 112 | struct SeenQuery { | 118 | struct SeenQuery { |
| 113 | v: Option<String>, | 119 | v: Option<String>, |
| @@ -328,6 +334,15 @@ async fn import_form( | |||
| 328 | </div> | 334 | </div> |
| 329 | </header> | 335 | </header> |
| 330 | source_tabs(lang: lang, base: "/new/import", active: source) | 336 | source_tabs(lang: lang, base: "/new/import", active: source) |
| 337 | + if !is_git { | ||
| 338 | + <div class="newrepo-card import-bulk"> | ||
| 339 | + <div class="import-bulk-text"> | ||
| 340 | + <strong>(g::t(lang, K::BulkLink))</strong> | ||
| 341 | + <span class="muted small">(g::t(lang, K::BulkIntro))</span> | ||
| 342 | + </div> | ||
| 343 | + <a class="button" href=(bulk_href.as_str())>(g::t(lang, K::BulkLinkButton))</a> | ||
| 344 | + </div> | ||
| 345 | + } | ||
| 331 | <p class="muted small">(g::t(lang, K::ImportIntro))</p> | 346 | <p class="muted small">(g::t(lang, K::ImportIntro))</p> |
| 332 | <div class="newrepo-card"> | 347 | <div class="newrepo-card"> |
| 333 | if has_instance { | 348 | if has_instance { |
| @@ -379,9 +394,6 @@ async fn import_form( | |||
| 379 | <textarea name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> | 394 | <textarea name="description" rows="2" maxlength="350">(draft.description.as_str())</textarea> |
| 380 | </label> | 395 | </label> |
| 381 | </div> | 396 | </div> |
| 382 | - if !is_git { | ||
| 383 | - <p class="small"><a href=(bulk_href.as_str())>(g::t(lang, K::BulkLink))</a></p> | ||
| 384 | - } | ||
| 385 | </form> | 397 | </form> |
| 386 | }) | 398 | }) |
| 387 | } | 399 | } |
| @@ -684,48 +696,61 @@ async fn bulk_select( | |||
| 684 | if empty { | 696 | if empty { |
| 685 | empty_state(title: g::t(lang, K::BulkNone)) | 697 | empty_state(title: g::t(lang, K::BulkNone)) |
| 686 | } else { | 698 | } else { |
| 699 | + <div class="newrepo-card import-into"> | ||
| 700 | + <div class="action-row"> | ||
| 701 | + <div class="action-text"> | ||
| 702 | + <h3>(g::t(lang, K::TargetOwner))</h3> | ||
| 703 | + <p class="muted small">(g::t(lang, K::BulkOwnerHelp))</p> | ||
| 704 | + </div> | ||
| 705 | + <div class="action-control"> | ||
| 706 | + <select name="owner" aria-label=(g::t(lang, K::TargetOwner))> | ||
| 707 | + for name in owners.iter() { | ||
| 708 | + <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | ||
| 709 | + } | ||
| 710 | + </select> | ||
| 711 | + </div> | ||
| 712 | + </div> | ||
| 713 | + if form.source != "git" { | ||
| 714 | + <div class="import-into-opts"> | ||
| 715 | + option_boxes(lang: lang, opts: opts) | ||
| 716 | + </div> | ||
| 717 | + } | ||
| 718 | + </div> | ||
| 687 | <div class="newrepo-card import-pick"> | 719 | <div class="newrepo-card import-pick"> |
| 688 | - <label class="inline import-pick-all"> | 720 | + <label class="import-pick-row import-pick-all"> |
| 689 | <input type="checkbox" data-select-all=".import-pick-list"> | 721 | <input type="checkbox" data-select-all=".import-pick-list"> |
| 690 | - <span>(g::t(lang, K::BulkSelectAll))</span> | 722 | + <span class="import-pick-main"> |
| 723 | + <span class="import-pick-title">(g::t(lang, K::BulkSelectAll))</span> | ||
| 724 | + </span> | ||
| 691 | <span class="muted small">(count)</span> | 725 | <span class="muted small">(count)</span> |
| 692 | </label> | 726 | </label> |
| 693 | - <ul class="import-pick-list item-list"> | 727 | + <ul class="import-pick-list"> |
| 694 | for (i, repo) in repos.iter().enumerate() { | 728 | for (i, repo) in repos.iter().enumerate() { |
| 695 | - <li class="import-pick-row"> | 729 | + <li> |
| 696 | - <label class="inline"> | 730 | + <label class="import-pick-row"> |
| 697 | <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> | 731 | <input type="checkbox" name=(format!("sel_{i}")) value=(repo.full_name.as_str())> |
| 698 | - <span class="import-pick-name">(repo.name.as_str())</span> | 732 | + <span class="import-pick-main"> |
| 699 | - if repo.private { | 733 | + <span class="import-pick-title"> |
| 700 | - <span class="badge private">(g::t(lang, K::BulkPrivate))</span> | 734 | + <span class="import-pick-name">(repo.name.as_str())</span> |
| 701 | - } | 735 | + if repo.private { |
| 702 | - if repo.fork { | 736 | + <span class="badge private">(g::t(lang, K::BulkPrivate))</span> |
| 703 | - <span class="badge">(g::t(lang, K::BulkFork))</span> | 737 | + } |
| 704 | - } | 738 | + if repo.fork { |
| 705 | - if repo.archived { | 739 | + <span class="badge">(g::t(lang, K::BulkFork))</span> |
| 706 | - <span class="badge">(g::t(lang, K::BulkArchived))</span> | 740 | + } |
| 707 | - } | 741 | + if repo.archived { |
| 742 | + <span class="badge">(g::t(lang, K::BulkArchived))</span> | ||
| 743 | + } | ||
| 744 | + </span> | ||
| 745 | + if !repo.description.is_empty() { | ||
| 746 | + <span class="muted small import-pick-desc">(repo.description.as_str())</span> | ||
| 747 | + } | ||
| 748 | + </span> | ||
| 708 | </label> | 749 | </label> |
| 709 | - if !repo.description.is_empty() { | ||
| 710 | - <span class="muted small import-pick-desc">(repo.description.as_str())</span> | ||
| 711 | - } | ||
| 712 | </li> | 750 | </li> |
| 713 | } | 751 | } |
| 714 | </ul> | 752 | </ul> |
| 715 | </div> | 753 | </div> |
| 716 | - <div class="newrepo-card"> | ||
| 717 | - <label class="newrepo-owner"> | ||
| 718 | - <span>(g::t(lang, K::TargetOwner))</span> | ||
| 719 | - <select name="owner"> | ||
| 720 | - for name in owners.iter() { | ||
| 721 | - <option value=(name.as_str()) selected=(*name == selected_owner)>(name.as_str())</option> | ||
| 722 | - } | ||
| 723 | - </select> | ||
| 724 | - </label> | ||
| 725 | - if form.source != "git" { | ||
| 726 | - option_boxes(lang: lang, opts: opts) | ||
| 727 | - } | ||
| 728 | - </div> | ||
| 729 | } | 754 | } |
| 730 | </form> | 755 | </form> |
| 731 | }) | 756 | }) |
| @@ -924,6 +949,7 @@ async fn run_bulk( | |||
| 924 | } else { | 949 | } else { |
| 925 | Visibility::Private | 950 | Visibility::Private |
| 926 | }; | 951 | }; |
| 952 | + let mut skipped: Vec<String> = Vec::new(); | ||
| 927 | for (_, full_name) in picked { | 953 | for (_, full_name) in picked { |
| 928 | let Some((remote, inst)) = parse_remote(source, full_name, instance) else { | 954 | let Some((remote, inst)) = parse_remote(source, full_name, instance) else { |
| 929 | continue; | 955 | continue; |
| @@ -937,12 +963,21 @@ async fn run_bulk( | |||
| 937 | options, | 963 | options, |
| 938 | }; | 964 | }; |
| 939 | let name = default_name(&remote); | 965 | let name = default_name(&remote); |
| 940 | - // A name already taken, or any refusal, is skipped here; the list page shows the rest. | 966 | + // A name already taken, or any refusal, skips that one; the list page says which and why. |
| 941 | if let Err(message) = begin(cx, viewer, &target, &name, "", visibility, spec).await? { | 967 | if let Err(message) = begin(cx, viewer, &target, &name, "", visibility, spec).await? { |
| 942 | tracing::info!(repo = %remote, %message, "bulk import: skipped a repository"); | 968 | tracing::info!(repo = %remote, %message, "bulk import: skipped a repository"); |
| 969 | + skipped.push(format!("{name} ({message})")); | ||
| 943 | } | 970 | } |
| 944 | } | 971 | } |
| 945 | - Err(see_other("/import").into()) | 972 | + if skipped.is_empty() { |
| 973 | + return Err(see_other("/import").into()); | ||
| 974 | + } | ||
| 975 | + let mut list = skipped.join(", "); | ||
| 976 | + if list.len() > 1500 { | ||
| 977 | + list.truncate(list.floor_char_boundary(1500)); | ||
| 978 | + list.push('…'); | ||
| 979 | + } | ||
| 980 | + Err(see_other(format!("/import?skipped={}", crate::views::enc(&list))).into()) | ||
| 946 | } | 981 | } |
| 947 | 982 | ||
| 948 | // ---- jobs ---- | 983 | // ---- jobs ---- |
| @@ -1040,13 +1075,20 @@ async fn recent_imports( | |||
| 1040 | } | 1075 | } |
| 1041 | 1076 | ||
| 1042 | #[component] | 1077 | #[component] |
| 1043 | -async fn jobs_list(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<impl View> { | 1078 | +async fn jobs_list( |
| 1079 | + lang: Lang, | ||
| 1080 | + jobs: Vec<(ImportJob, Option<Repo>)>, | ||
| 1081 | + skipped: Option<String>, | ||
| 1082 | +) -> Result<impl View> { | ||
| 1044 | let empty = jobs.is_empty(); | 1083 | let empty = jobs.is_empty(); |
| 1045 | Ok(view! { | 1084 | Ok(view! { |
| 1046 | newrepo_tabs(lang: lang, active: "import") | 1085 | newrepo_tabs(lang: lang, active: "import") |
| 1047 | <section class="page-head" data-live="/import/events"> | 1086 | <section class="page-head" data-live="/import/events"> |
| 1048 | <h1>(g::t(lang, K::JobsTitle))</h1> | 1087 | <h1>(g::t(lang, K::JobsTitle))</h1> |
| 1049 | </section> | 1088 | </section> |
| 1089 | + if let Some(message) = skipped { | ||
| 1090 | + alert(message: message.as_str()) | ||
| 1091 | + } | ||
| 1050 | if empty { | 1092 | if empty { |
| 1051 | empty_state(title: g::t(lang, K::NoJobs), | 1093 | empty_state(title: g::t(lang, K::NoJobs), |
| 1052 | <a class="button" href="/new/import">(g::t(lang, K::ImportTitle))</a>) | 1094 | <a class="button" href="/new/import">(g::t(lang, K::ImportTitle))</a>) |
| @@ -1094,8 +1136,13 @@ async fn jobs_page(cx: &Cx) -> Result<impl View> { | |||
| 1094 | let lang = i18n::lang(cx, Some(&viewer.0)); | 1136 | let lang = i18n::lang(cx, Some(&viewer.0)); |
| 1095 | let state = app_context::<AppState>(cx); | 1137 | let state = app_context::<AppState>(cx); |
| 1096 | let rows = load_job_rows(state, &viewer.0.id, 50).await?; | 1138 | let rows = load_job_rows(state, &viewer.0.id, 50).await?; |
| 1139 | + let skipped = query_params::<JobsQuery>(cx)? | ||
| 1140 | + .skipped | ||
| 1141 | + .clone() | ||
| 1142 | + .filter(|s| !s.is_empty() && s.len() < 2000) | ||
| 1143 | + .map(|s| g::bulk_skipped(lang, &s)); | ||
| 1097 | Ok(view! { cx => | 1144 | Ok(view! { cx => |
| 1098 | - shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows)) | 1145 | + shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows, skipped: skipped)) |
| 1099 | }) | 1146 | }) |
| 1100 | } | 1147 | } |
| 1101 | 1148 | ||
style/_import.scssmodified+81 -17
| @@ -87,42 +87,106 @@ | |||
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | -.import-pick { | 90 | +// Where the picked repositories go: the owner as a settings row, what comes along under it. |
| 91 | +.import-into { | ||
| 91 | gap: 0; | 92 | gap: 0; |
| 92 | - padding: 0; | 93 | + padding: 4px 22px 16px; |
| 94 | + | ||
| 95 | + .action-control select { | ||
| 96 | + min-width: 180px; | ||
| 97 | + } | ||
| 93 | } | 98 | } |
| 94 | 99 | ||
| 95 | -.import-pick-all { | 100 | +.import-into-opts { |
| 96 | - margin: 0; | 101 | + padding-top: 14px; |
| 97 | - padding: 12px 22px; | 102 | + border-top: 1px solid var(--border); |
| 98 | - border-bottom: 1px solid var(--border); | 103 | + |
| 104 | + // Four short choices fit on one line here; the single-import form keeps them stacked. | ||
| 105 | + .import-opts { | ||
| 106 | + flex-direction: row; | ||
| 107 | + flex-wrap: wrap; | ||
| 108 | + gap: 8px 22px; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + .import-opts > p { | ||
| 112 | + flex-basis: 100%; | ||
| 113 | + } | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +// The repositories as rows: the whole row is the checkbox's label, a ticked row is tinted. | ||
| 117 | +.import-pick { | ||
| 118 | + gap: 0; | ||
| 119 | + padding: 0; | ||
| 120 | + overflow: hidden; | ||
| 99 | } | 121 | } |
| 100 | 122 | ||
| 101 | .import-pick-list { | 123 | .import-pick-list { |
| 102 | - max-height: 52vh; | 124 | + max-height: 60vh; |
| 125 | + margin: 0; | ||
| 126 | + padding: 0; | ||
| 103 | overflow-y: auto; | 127 | overflow-y: auto; |
| 128 | + list-style: none; | ||
| 129 | + | ||
| 130 | + li + li .import-pick-row { | ||
| 131 | + border-top: 1px solid var(--border); | ||
| 132 | + } | ||
| 104 | } | 133 | } |
| 105 | 134 | ||
| 106 | .import-pick-row { | 135 | .import-pick-row { |
| 107 | - display: flex; | 136 | + display: grid; |
| 108 | - flex-wrap: wrap; | 137 | + grid-template-columns: auto minmax(0, 1fr) auto; |
| 109 | - align-items: baseline; | 138 | + align-items: start; |
| 110 | - gap: 2px 12px; | 139 | + gap: 12px; |
| 111 | - padding: 9px 22px; | 140 | + margin: 0; |
| 112 | - border-bottom: 1px solid var(--border); | 141 | + padding: 11px 22px; |
| 142 | + cursor: pointer; | ||
| 143 | + | ||
| 144 | + > input { | ||
| 145 | + margin: 2px 0 0; | ||
| 146 | + } | ||
| 113 | 147 | ||
| 114 | - &:last-child { | 148 | + &:hover { |
| 115 | - border-bottom: 0; | 149 | + background: var(--surface-2); |
| 116 | } | 150 | } |
| 117 | 151 | ||
| 118 | - .inline { | 152 | + &:has(input:checked) { |
| 153 | + background: var(--accent-soft); | ||
| 154 | + } | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +.import-pick-all { | ||
| 158 | + align-items: center; | ||
| 159 | + border-bottom: 1px solid var(--border-strong); | ||
| 160 | + font-weight: 600; | ||
| 161 | + | ||
| 162 | + > input { | ||
| 119 | margin: 0; | 163 | margin: 0; |
| 120 | } | 164 | } |
| 165 | + | ||
| 166 | + &:has(input:checked) { | ||
| 167 | + background: none; | ||
| 168 | + } | ||
| 169 | +} | ||
| 170 | + | ||
| 171 | +.import-pick-main { | ||
| 172 | + display: flex; | ||
| 173 | + flex-direction: column; | ||
| 174 | + gap: 2px; | ||
| 175 | + min-width: 0; | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +.import-pick-title { | ||
| 179 | + display: flex; | ||
| 180 | + flex-wrap: wrap; | ||
| 181 | + align-items: center; | ||
| 182 | + gap: 4px 8px; | ||
| 183 | + min-width: 0; | ||
| 121 | } | 184 | } |
| 122 | 185 | ||
| 123 | .import-pick-name { | 186 | .import-pick-name { |
| 124 | font-family: var(--mono); | 187 | font-family: var(--mono); |
| 125 | font-size: 0.875rem; | 188 | font-size: 0.875rem; |
| 189 | + font-weight: 500; | ||
| 126 | } | 190 | } |
| 127 | 191 | ||
| 128 | .import-pick-desc { | 192 | .import-pick-desc { |
| @@ -275,7 +339,7 @@ | |||
| 275 | 339 | ||
| 276 | @media (max-width: 560px) { | 340 | @media (max-width: 560px) { |
| 277 | .import-pick-row, | 341 | .import-pick-row, |
| 278 | - .import-pick-all { | 342 | + .import-into { |
| 279 | padding-left: 14px; | 343 | padding-left: 14px; |
| 280 | padding-right: 14px; | 344 | padding-right: 14px; |
| 281 | } | 345 | } |
style/_repo.scssmodified+19 -0
| @@ -681,6 +681,25 @@ | |||
| 681 | padding: 20px 22px; | 681 | padding: 20px 22px; |
| 682 | } | 682 | } |
| 683 | 683 | ||
| 684 | +// The way to several repositories at once sits above the one-repository form, as a row with a | ||
| 685 | +// button, so it is seen before the form is filled in. | ||
| 686 | +.import-bulk { | ||
| 687 | + flex-direction: row; | ||
| 688 | + flex-wrap: wrap; | ||
| 689 | + align-items: center; | ||
| 690 | + justify-content: space-between; | ||
| 691 | + gap: 12px 20px; | ||
| 692 | + padding: 14px 22px; | ||
| 693 | +} | ||
| 694 | + | ||
| 695 | +.import-bulk-text { | ||
| 696 | + display: flex; | ||
| 697 | + flex-direction: column; | ||
| 698 | + gap: 2px; | ||
| 699 | + min-width: 0; | ||
| 700 | + flex: 1 1 280px; | ||
| 701 | +} | ||
| 702 | + | ||
| 684 | .newrepo-row { | 703 | .newrepo-row { |
| 685 | display: flex; | 704 | display: flex; |
| 686 | flex-wrap: wrap; | 705 | flex-wrap: wrap; |