consolidate shared helpers into utils crate
This commit is contained in:
@@ -30,6 +30,7 @@ use signed_state::{
|
||||
Backend, CheckoutsStore, RepoListStore, RepoStore, ensure_repo_mirror, repo_mirror_path,
|
||||
};
|
||||
use signed_ui::{CountBadge, placeholder, ref_selector_trigger};
|
||||
use utils::middle_truncate;
|
||||
|
||||
use crate::views::commit_diff::{COMMIT_ROW_HEIGHT, CommitDiffView, DiffPane, commit_row};
|
||||
use crate::views::{repo_tab_avatar, tab_title};
|
||||
@@ -104,17 +105,8 @@ fn shorten_owner(owner: &PublicKey) -> String {
|
||||
hex.chars().take(10).collect()
|
||||
}
|
||||
|
||||
/// Truncate a label for the fixed-width controls of the compare bar.
|
||||
fn truncate_label(label: &str) -> SharedString {
|
||||
const MAX: usize = 18;
|
||||
let mut chars = label.chars();
|
||||
let (prefix, rest) = (chars.by_ref().take(MAX).collect::<String>(), chars.next());
|
||||
let label = if rest.is_some() {
|
||||
format!("{}…", &prefix[..prefix.len().saturating_sub(1)])
|
||||
} else {
|
||||
prefix
|
||||
};
|
||||
SharedString::from(label)
|
||||
SharedString::from(middle_truncate(label, 18, 0))
|
||||
}
|
||||
|
||||
fn checkout_source_item(
|
||||
|
||||
@@ -5,7 +5,8 @@ use gpui_component::{ActiveTheme, StyledExt, WindowExt, h_flex, v_flex};
|
||||
use nostr::prelude::PublicKey;
|
||||
use signed_core::Announcement;
|
||||
use signed_state::ProfileStore;
|
||||
use signed_ui::{Avatar, middle_truncate};
|
||||
use signed_ui::Avatar;
|
||||
use utils::middle_truncate;
|
||||
|
||||
pub(super) fn open_about_dialog(announcement: Announcement, window: &mut Window, cx: &mut App) {
|
||||
window.open_dialog(cx, move |dialog, _window, cx| {
|
||||
|
||||
@@ -31,9 +31,9 @@ use signed_state::{
|
||||
pr_proposes_checkout,
|
||||
};
|
||||
use signed_ui::{
|
||||
Avatar, CountBadge, DropdownButton, PixelAvatar, copy_row, menu_copy_row, middle_truncate,
|
||||
ref_selector_trigger,
|
||||
Avatar, CountBadge, DropdownButton, PixelAvatar, copy_row, menu_copy_row, ref_selector_trigger,
|
||||
};
|
||||
use utils::middle_truncate;
|
||||
|
||||
mod about;
|
||||
mod actions;
|
||||
|
||||
Reference in New Issue
Block a user