diff --git a/crates/forge-web/src/i18n/migrate.rs b/crates/forge-web/src/i18n/migrate.rs
index eca1ad8..7b39084 100644
--- a/crates/forge-web/src/i18n/migrate.rs
+++ b/crates/forge-web/src/i18n/migrate.rs
@@ -36,7 +36,6 @@ pub enum K {
OptionsNote,
StartImport,
BulkLink,
- JobsLink,
// Bulk import.
BulkTitle,
BulkIntro,
@@ -54,6 +53,8 @@ pub enum K {
// Jobs.
JobsTitle,
NoJobs,
+ RecentImports,
+ ViewAll,
JobQueued,
JobRunning,
JobDone,
@@ -123,7 +124,6 @@ const ALL: &[K] = &[
K::OptionsNote,
K::StartImport,
K::BulkLink,
- K::JobsLink,
K::BulkTitle,
K::BulkIntro,
K::BulkOwnerGitHub,
@@ -139,6 +139,8 @@ const ALL: &[K] = &[
K::BulkArchived,
K::JobsTitle,
K::NoJobs,
+ K::RecentImports,
+ K::ViewAll,
K::JobQueued,
K::JobRunning,
K::JobDone,
@@ -225,7 +227,6 @@ 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::JobsLink => ("Imports", "İçe aktarmalar"),
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.",
@@ -251,8 +252,10 @@ fn pair(key: K) -> (&'static str, &'static str) {
K::BulkPrivate => ("private", "özel"),
K::BulkFork => ("fork", "çatal"),
K::BulkArchived => ("archived", "arşivlenmiş"),
- K::JobsTitle => ("Imports", "İçe aktarmalar"),
+ K::JobsTitle => ("Import history", "İçe aktarma geçmişi"),
K::NoJobs => ("No imports yet.", "Henüz içe aktarma yok."),
+ K::RecentImports => ("Recent imports", "Son içe aktarmalar"),
+ K::ViewAll => ("View all", "Tümünü gör"),
K::JobQueued => ("Queued", "Sırada"),
K::JobRunning => ("Running", "Çalışıyor"),
K::JobDone => ("Done", "Bitti"),
diff --git a/crates/forge-web/src/pages/import.rs b/crates/forge-web/src/pages/import.rs
index f12f673..d2bc74f 100644
--- a/crates/forge-web/src/pages/import.rs
+++ b/crates/forge-web/src/pages/import.rs
@@ -161,7 +161,6 @@ pub(crate) async fn newrepo_tabs(lang: Lang, active: &str) -> Result
(g::t(lang, K::TabCreate))
(g::t(lang, K::TabImport))
- (g::t(lang, K::JobsLink))
})
}
@@ -386,17 +385,41 @@ async fn import_form(
})
}
+/// How many imports the Import tab lists under the form.
+const RECENT_IMPORTS: usize = 5;
+
+/// The GET import page: the form, then the recent imports.
+#[component]
+async fn import_home(
+ lang: Lang,
+ csrf: String,
+ draft: Draft,
+ owners: Vec,
+ jobs: Vec<(ImportJob, Option)>,
+ more: bool,
+) -> Result {
+ Ok(view! {
+ import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners)
+ recent_imports(lang: lang, jobs: jobs, more: more)
+ })
+}
+
#[page("/new/import")]
async fn import_page(cx: &Cx) -> Result {
let viewer = require_user(cx).await?;
let lang = i18n::lang(cx, Some(&viewer.0));
let query = query_params::(cx)?;
let source = source_of(query.source.as_deref());
- let owners = owner_choices(app_context::(cx), &viewer.0).await?;
+ let state = app_context::(cx);
+ let owners = owner_choices(state, &viewer.0).await?;
let csrf = viewer.1.csrf_token.clone();
+ // One more than the list shows, so the page knows whether to offer "View all".
+ let mut jobs = load_job_rows(state, &viewer.0.id, 6).await?;
+ let more = jobs.len() > RECENT_IMPORTS;
+ jobs.truncate(RECENT_IMPORTS);
Ok(view! { cx =>
shell(title: g::t(lang, K::ImportTitle), viewer: Some(&viewer),
- import_form(lang: lang, csrf: csrf.as_str(), draft: Draft::fresh(source), error: None, owners: owners))
+ import_home(lang: lang, csrf: csrf, draft: Draft::fresh(source), owners: owners, jobs: jobs, more: more))
})
}
@@ -948,11 +971,72 @@ fn ago(lang: Lang, stamp: &str) -> String {
stamp_to_unix(stamp).map_or_else(String::new, |t| relative_time(lang, t, now_unix()))
}
+/// The user's newest import jobs, each with its repository once it exists.
+async fn load_job_rows(
+ state: &AppState,
+ user_id: &str,
+ limit: u32,
+) -> Result)>> {
+ let jobs = state.store.list_import_jobs(user_id, limit).await?;
+ let mut rows = Vec::with_capacity(jobs.len());
+ for job in jobs {
+ let repo = match &job.repo_id {
+ Some(id) => state.store.repo_by_id(id).await?,
+ None => None,
+ };
+ rows.push((job, repo));
+ }
+ Ok(rows)
+}
+
+/// The import job rows, shared by the Import history page and the recent list on the Import tab.
+#[component]
+async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option)>) -> Result {
+ Ok(view! {
+
+ })
+}
+
+/// The few most recent imports, shown under the import form. Nothing renders without any.
+/// `more` says there are older ones, which the "View all" link opens.
+#[component]
+async fn recent_imports(
+ lang: Lang,
+ jobs: Vec<(ImportJob, Option)>,
+ more: bool,
+) -> Result {
+ let empty = jobs.is_empty();
+ Ok(view! {
+ if !empty {
+
+ }
+ })
+}
+
#[component]
async fn jobs_list(lang: Lang, jobs: Vec<(ImportJob, Option)>) -> Result {
let empty = jobs.is_empty();
Ok(view! {
- newrepo_tabs(lang: lang, active: "jobs")
+ newrepo_tabs(lang: lang, active: "import")
(g::t(lang, K::JobsTitle))
@@ -960,20 +1044,7 @@ async fn jobs_list(lang: Lang, jobs: Vec<(ImportJob, Option)>) -> Result(g::t(lang, K::NoJobs))
} else {
-
+ job_rows(lang: lang, jobs: jobs)
}
})
@@ -984,15 +1055,7 @@ async fn jobs_page(cx: &Cx) -> Result {
let viewer = require_user(cx).await?;
let lang = i18n::lang(cx, Some(&viewer.0));
let state = app_context::(cx);
- let jobs = state.store.list_import_jobs(&viewer.0.id, 50).await?;
- let mut rows = Vec::with_capacity(jobs.len());
- for job in jobs {
- let repo = match &job.repo_id {
- Some(id) => state.store.repo_by_id(id).await?,
- None => None,
- };
- rows.push((job, repo));
- }
+ let rows = load_job_rows(state, &viewer.0.id, 50).await?;
Ok(view! { cx =>
shell(title: g::t(lang, K::JobsTitle), viewer: Some(&viewer), jobs_list(lang: lang, jobs: rows))
})
@@ -1027,7 +1090,7 @@ async fn job_view(
let state_word = job.state.as_str();
let empty_log = log.is_empty();
Ok(view! {
- newrepo_tabs(lang: lang, active: "jobs")
+ newrepo_tabs(lang: lang, active: "import")
(job.source_ref.as_str())
diff --git a/crates/forge-web/src/pages/import_tests.rs b/crates/forge-web/src/pages/import_tests.rs
index 6d243d3..3946111 100644
--- a/crates/forge-web/src/pages/import_tests.rs
+++ b/crates/forge-web/src/pages/import_tests.rs
@@ -78,7 +78,7 @@ async fn scenario_pages_render(fx: &Fixture) {
"/new/import/bulk?source=github",
"Import several repositories",
),
- ("/import", "Imports"),
+ ("/import", "Import history"),
("/settings/export", "Export your data"),
] {
let (status, body) = send(&fx.router, "GET", uri, Some(TOKEN), None).await;