1use gpui_shared_string::SharedString;
4
5#[derive(Clone, Debug)]
7pub struct PathPromptOptions {
8 pub files: bool,
10 pub directories: bool,
12 pub multiple: bool,
14 pub prompt: Option<SharedString>,
16}
17
18#[derive(Copy, Clone, Debug, PartialEq)]
21pub enum PromptLevel {
22 Info,
24
25 Warning,
27
28 Critical,
30}
31
32#[derive(Clone, Debug, PartialEq)]
34pub enum PromptButton {
35 Ok(SharedString),
37 Cancel(SharedString),
39 Other(SharedString),
41}
42
43impl PromptButton {
44 pub fn new(label: impl Into<SharedString>) -> Self {
46 PromptButton::Other(label.into())
47 }
48
49 pub fn ok(label: impl Into<SharedString>) -> Self {
51 PromptButton::Ok(label.into())
52 }
53
54 pub fn cancel(label: impl Into<SharedString>) -> Self {
56 PromptButton::Cancel(label.into())
57 }
58
59 #[allow(dead_code)]
61 pub fn is_cancel(&self) -> bool {
62 matches!(self, PromptButton::Cancel(_))
63 }
64
65 pub fn label(&self) -> &SharedString {
67 match self {
68 PromptButton::Ok(label) => label,
69 PromptButton::Cancel(label) => label,
70 PromptButton::Other(label) => label,
71 }
72 }
73}
74
75impl From<&str> for PromptButton {
76 fn from(value: &str) -> Self {
77 match value.to_lowercase().as_str() {
78 "ok" => PromptButton::Ok("OK".into()),
79 "cancel" => PromptButton::Cancel("Cancel".into()),
80 _ => PromptButton::Other(SharedString::from(value.to_owned())),
81 }
82 }
83}