dir picker scrollables handling + confirmation
Dependencies
- [2]
EJPSD5XOshared allowed actions conditions between update and view - [3]
PKLUHYE4allow to copy change hash - [4]
LFEMJYYDstart of to_record selection - [5]
YGZ3VCW4add push - [6]
YRGDFHABproject dir picker - [7]
LPSUBGUBadd projects picker - [8]
MORKDJUEuse allowed actions binding for key subs - [9]
OLDN7R34retry upsert project - [10]
IMJQ4PMLfix and refactor action bindings - [11]
5BAPU7K6dir picker key navigation - [12]
TEDT26JQadd push and pull sub-menus - [13]
AZ5D2LQUallow to set record description - [14]
UTDTZCTXpull+push status, add info reports - [15]
ODCT4QJNadd pull - [*]
6YZAVBWUInitial commit
Change contents
- edit in inflorescence_model/src/action.rs at line 359
push_if(matches!(selection, dir_picker::Selection::Input),|| confirm("Confirm input"),ma,);push_if(matches!(selection, dir_picker::Selection::SubDir(_)),|| confirm("Confirm dir selection"),ma,);push_if(matches!(selection,dir_picker::Selection::ProjectPijul(_)| dir_picker::Selection::ProjectGit(_)),|| confirm("Confirm project selection"),ma,); - replacement in inflorescence_model/src/action.rs at line 649
let push_sub_menu = |can_push: bool| {move || -> Binding {Binding {keys_str: "S-p",keys: ModKeys::One(ModKey {key: Key::Character("p".into()),mods: Mods::SHIFT,}),label: "push",msg: can_push.then_some(FilteredMsg::EnterSubMenu(model::SubMenu::Push)),}let push_sub_menu = |can_push: bool| -> Binding {Binding {keys_str: "S-p",keys: ModKeys::One(ModKey {key: Key::Character("p".into()),mods: Mods::SHIFT,}),label: "push",msg: can_push.then_some(FilteredMsg::EnterSubMenu(model::SubMenu::Push)), - replacement in inflorescence_model/src/action.rs at line 661
let pull_sub_menu = |can_pull: bool| {move || -> Binding {Binding {keys_str: "S-f",keys: ModKeys::One(ModKey {key: Key::Character("f".into()),mods: Mods::SHIFT,}),label: "pull",msg: can_pull.then_some(FilteredMsg::EnterSubMenu(model::SubMenu::Pull)),}let pull_sub_menu = |can_pull: bool| -> Binding {Binding {keys_str: "S-f",keys: ModKeys::One(ModKey {key: Key::Character("f".into()),mods: Mods::SHIFT,}),label: "pull",msg: can_pull.then_some(FilteredMsg::EnterSubMenu(model::SubMenu::Pull)), - replacement in inflorescence_model/src/action.rs at line 715
push(push_sub_menu(can_push_pull), ma);push(pull_sub_menu(can_push_pull), ma);push(|| push_sub_menu(can_push_pull), ma);push(|| pull_sub_menu(can_push_pull), ma); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 54
SubmitInput, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 121
state.selection = Selection::Input;nav_scrollable::scroll_up_to_section(&mut state.right_nav, 0);nav_scrollable::scroll_up_to_section(&mut state.left_nav, 0); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 171
}}}Msg::SubmitInput => {if state.input.is_empty() {action = Some(Action::Picked(state.current_dir.as_path().to_path_buf(),));Task::none()} else {// Accept input only if there's an exact matchlet mut matches = if state.child_dirs.iter().any(|dir| {dir.file_name().map(|name| name.to_string_lossy())== Some(Cow::Borrowed(&state.input))}) {vec![state.input.clone()]} else {vec![]};// Change dir if there is only one matchif matches.len() == 1 {let matched =state.current_dir.join(matches.pop().unwrap());state.input = String::default();change_dir(state, matched)} else {Task::none() - edit in inflorescence_iced_widget/src/dir_picker.rs at line 174
- replacement in inflorescence_iced_widget/src/dir_picker.rs at line 247
*selection = Selection::SubDir(0);let new_ix = 0;*selection = Selection::SubDir(new_ix);nav_scrollable::scroll_up_to_section(&mut state.left_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 263
nav_scrollable::scroll_down_to_section(&mut state.left_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 269
nav_scrollable::scroll_up_to_section(&mut state.left_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 280
nav_scrollable::scroll_down_to_section(&mut state.right_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 286
nav_scrollable::scroll_down_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1),); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 295
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 301
if state.found_repos_dirs_git.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectGit(new_ix);} else {*selection = Selection::ProjectGit(0);}*selection = Selection::ProjectGit(0);nav_scrollable::scroll_up_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1),); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 308
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 319
nav_scrollable::scroll_down_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1)+ new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 329
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 335
nav_scrollable::scroll_down_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1),); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 344
if state.found_repos_dirs_pijul.len() - 1 > *ix {let new_ix = *ix + 1;*selection = Selection::ProjectPijul(new_ix);} else {*selection = Selection::ProjectPijul(0);}*selection = Selection::ProjectPijul(0);nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 351
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 363
nav_scrollable::scroll_down_to_section(&mut state.left_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 370
nav_scrollable::scroll_down_to_section(&mut state.left_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 383
nav_scrollable::scroll_up_to_section(&mut state.left_nav,new_ix,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 389
nav_scrollable::scroll_up_to_section(&mut state.left_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 400
nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix,); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 405
*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,let new_ix = state.found_repos_dirs_git.len() - 1;*selection = Selection::ProjectGit(new_ix);nav_scrollable::scroll_up_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1)+ new_ix, - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 416
*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,let new_ix = state.found_repos_dirs_pijul.len() - 1;*selection = Selection::ProjectPijul(new_ix);nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 427
nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix,); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 432
*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,let new_ix = state.found_repos_dirs_git.len() - 1;*selection = Selection::ProjectGit(new_ix);nav_scrollable::scroll_down_to_section(&mut state.right_nav,new_ix, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 441
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 452
nav_scrollable::scroll_up_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1)+ new_ix,); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 461
*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,let new_ix = state.found_repos_dirs_pijul.len() - 1;*selection = Selection::ProjectPijul(new_ix);nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix, - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 468
*selection = Selection::ProjectGit(state.found_repos_dirs_git.len() - 1,let new_ix = state.found_repos_dirs_git.len() - 1;*selection = Selection::ProjectGit(new_ix);nav_scrollable::scroll_down_to_section(&mut state.right_nav,state.found_repos_dirs_pijul.len().saturating_sub(1)+ new_ix, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 483
nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix,); - replacement in inflorescence_iced_widget/src/dir_picker.rs at line 488
*selection = Selection::ProjectPijul(state.found_repos_dirs_pijul.len() - 1,let new_ix = state.found_repos_dirs_pijul.len() - 1;*selection = Selection::ProjectPijul(new_ix);nav_scrollable::scroll_up_to_section(&mut state.right_nav,new_ix, - edit in inflorescence_iced_widget/src/dir_picker.rs at line 497
nav_scrollable::scroll_up_to_section(&mut state.right_nav,0,); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 511
nav_scrollable::scroll_up_to_section(&mut state.right_nav, 0); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 521
nav_scrollable::scroll_up_to_section(&mut state.left_nav, 0); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 531
nav_scrollable::scroll_up_to_section(&mut state.left_nav, 0); - edit in inflorescence_iced_widget/src/dir_picker.rs at line 537
pub fn confirm_input_or_selection(state: &mut State,) -> (Task<Msg>, Option<Action>) {let mut action = None;let task = match state.selection {Selection::Input => {if state.input.is_empty() {action = Some(Action::Picked(state.current_dir.as_path().to_path_buf(),));Task::none()} else {nav_scrollable::scroll_up_to_section(&mut state.right_nav, 0);nav_scrollable::scroll_up_to_section(&mut state.left_nav, 0);// Accept input only if there's an exact matchlet mut matches = if state.child_dirs.iter().any(|dir| {dir.file_name().map(|name| name.to_string_lossy())== Some(Cow::Borrowed(&state.input))}) {vec![state.input.clone()]} else {vec![]};// Change dir if there is only one matchif matches.len() == 1 {let matched =state.current_dir.join(matches.pop().unwrap());state.input = String::default();change_dir(state, matched)} else {Task::none()}}}Selection::SubDir(ix) => {if !state.matched_child_dirs.is_empty() {if let Some(dir) = state.matched_child_dirs.get(ix) {let path = state.current_dir.join(dir);change_dir(state, path)} else {Task::none()}} else if !state.child_dirs.is_empty() {if let Some(dir) = state.child_dirs.get(ix) {let path = state.current_dir.join(dir);change_dir(state, path)} else {Task::none()}} else {Task::none()}}Selection::ProjectPijul(ix) => {if let Some(path) = state.found_repos_dirs_pijul.get(ix) {action = Some(Action::Picked(path.clone()));}Task::none()}Selection::ProjectGit(ix) => {if let Some(path) = state.found_repos_dirs_git.get(ix) {action = Some(Action::Picked(path.clone()));}Task::none()}};state.selection = Selection::Input;(task, action)} - edit in inflorescence_iced_widget/src/dir_picker.rs at line 682
),Element::new(text_input("", input).on_input(Msg::Input).on_submit(Msg::SubmitInput), - edit in inflorescence_iced_widget/src/dir_picker.rs at line 683
Element::new(text_input("", input).on_input(Msg::Input)), - edit in inflorescence/src/main.rs at line 555
let mut handle_action = |action| {if let Some(dir_picker::Action::Picked(dir)) = action {// If it contains Pijul repo, init ManagingRepo state// TODO: If it contains Git, offer to migrate it// TODO: Otherwise, offer to init Pijul from scratchlet project = store::Project {last_closed_time: cmp::Reverse(None),path: dir.clone(),};let store_project_task = if repo::is_pijul(&project.path) {Task::perform(async move { store::upsert_project(project).await },Msg::UpsertProjectResult,)} else {Task::none()};let (sub, managing_repo, managing_repo_task) =init_managing_repo(dir);new_state = Some((sub, managing_repo));Task::batch([managing_repo_task, store_project_task])} else {Task::none()}}; - replacement in inflorescence/src/main.rs at line 586
inflorescence_model::selection::Msg::AltPressDir(dir) => {selection::Msg::AltPressDir(dir) => { - replacement in inflorescence/src/main.rs at line 592
action::FilteredMsg::Confirm| action::FilteredMsg::Cancelaction::FilteredMsg::Confirm => {let (task, action) =dir_picker::confirm_input_or_selection(picker);let dir_picker_task =task.map(view::Msg::PickingRepoDir).map(Msg::View);let action_task = handle_action(action);Task::batch([dir_picker_task, action_task])}action::FilteredMsg::Cancel - replacement in inflorescence/src/main.rs at line 624[7.22469]→[6.3615928:3616200](∅→∅),[6.3615928]→[6.3615928:3616200](∅→∅),[6.3616200]→[7.22470:22821](∅→∅),[7.22821]→[9.1171:1221](∅→∅),[9.1221]→[7.22866:22965](∅→∅),[7.22866]→[7.22866:22965](∅→∅),[7.22965]→[6.3616200:3616364](∅→∅),[6.3616200]→[6.3616200:3616364](∅→∅),[6.3616364]→[7.22966:23132](∅→∅),[7.23132]→[6.3616420:3616441](∅→∅),[6.3616420]→[6.3616420:3616441](∅→∅),[6.3616441]→[7.23133:23165](∅→∅),[7.23165]→[6.3616462:3616476](∅→∅),[6.3616462]→[6.3616462:3616476](∅→∅)
if let Some(dir_picker::Action::Picked(dir)) = action {// If it contains Pijul repo, init ManagingRepo state// TODO: If it contains Git, offer to migrate it// TODO: Otherwise, offer to init Pijul from scratchlet project = store::Project {last_closed_time: cmp::Reverse(None),path: dir.clone(),};let store_project_task = if repo::is_pijul(&project.path) {Task::perform(async move { store::upsert_project(project).await },Msg::UpsertProjectResult,)} else {Task::none()};let (sub, managing_repo, managing_repo_task) =init_managing_repo(dir);new_state = Some((sub, managing_repo));Task::batch([dir_picker_task,managing_repo_task,store_project_task,])} else {dir_picker_task}let action_task = handle_action(action);Task::batch([dir_picker_task, action_task])