#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Focus {
#[default]
Dashboard,
FirstRun,
Detail,
RepoPicker,
Help,
Confirm,
Composer,
ThemePicker,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FirstRunSuggestion {
pub repo: String,
pub count: usize,
pub selected: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RepoPickerMode {
#[default]
List,
Input,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DetailKind {
Pr,
Issue,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DetailRef {
pub repo: String,
pub number: u32,
pub kind: DetailKind,
}
#[derive(Debug, Clone, Default)]
pub struct PerTabState {
pub detail_ref: Option<DetailRef>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommentSubjectKind {
PullRequest,
Issue,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CommentComposerTarget {
TopLevel {
repo: String,
number: u32,
subject_id: String,
kind: CommentSubjectKind,
},
ReviewThreadReply {
repo: String,
number: u32,
thread_id: String,
path: String,
line: Option<u32>,
},
}
impl CommentComposerTarget {
pub fn label(&self) -> &'static str {
match self {
Self::TopLevel { kind: CommentSubjectKind::PullRequest, .. } => "PR comment",
Self::TopLevel { kind: CommentSubjectKind::Issue, .. } => "Issue comment",
Self::ReviewThreadReply { .. } => "Thread reply",
}
}
pub fn detail_ref(&self) -> DetailRef {
match self {
Self::TopLevel { repo, number, kind, .. } => DetailRef {
repo: repo.clone(),
number: *number,
kind: match kind {
CommentSubjectKind::PullRequest => DetailKind::Pr,
CommentSubjectKind::Issue => DetailKind::Issue,
},
},
Self::ReviewThreadReply { repo, number, .. } => {
DetailRef { repo: repo.clone(), number: *number, kind: DetailKind::Pr }
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CommentComposer {
pub target: CommentComposerTarget,
pub body: String,
}
impl CommentComposer {
pub fn new(target: CommentComposerTarget) -> Self {
Self { target, body: String::new() }
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PendingMutation {
MergePullRequest {
repo: String,
number: u32,
method: crate::github::mutations::MergeMethod,
},
SubmitComment {
target: CommentComposerTarget,
},
}
impl PendingMutation {
pub fn label(&self) -> String {
match self {
Self::MergePullRequest { repo, number, method } => {
format!("{} {repo}#{number}", method.label())
}
Self::SubmitComment { target } => match target {
CommentComposerTarget::TopLevel { repo, number, .. } => {
format!("comment {repo}#{number}")
}
CommentComposerTarget::ReviewThreadReply { repo, number, .. } => {
format!("reply {repo}#{number}")
}
},
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MutationRefresh {
pub detail_ref: DetailRef,
pub message: String,
}