use std::rc::Rc; use gpui::{ App, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, Styled, Window, div, }; use crate::{ buttons::{ButtonVariant, IconButton}, data_display::color_mark, forms::{ColorPalette, Enter, FormError, InlineEdit, Input, OnValue, Run, TextInput}, mail::Label, overlays::Popover, primitives::{Icon, IconName}, theme::{ActiveTheme, ControlSize, HUE_NAMES, IconSize, Radius}, }; type OnRename = Rc; type OnRecolor = Rc; /// Why `name` cannot name a label, if it cannot: blank, or another label's already, whatever the case. pub(crate) fn refusal( name: &str, labels: &[Label], except: Option<&SharedString>, ) -> Option<&'static str> { let name = name.trim().to_lowercase(); if name.is_empty() { return Some("A label needs a name."); } let taken = labels .iter() .any(|label| Some(&label.key) != except && label.name.to_lowercase() == name); taken.then_some("That name is taken.") } /// A team's labels to tend: each wears its hue, which a press on it changes, and its name, which edits in place; a label can go, and a field at the end makes a new one. Names stay unique, whatever their case. #[derive(IntoElement)] pub struct LabelManager { id: ElementId, labels: Vec