Add pull request and repository browsing
This commit is contained in:
82
crates/app/src/domain.rs
Normal file
82
crates/app/src/domain.rs
Normal file
@@ -0,0 +1,82 @@
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use gotcha_gitea::models;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct Server {
|
||||
pub name: String,
|
||||
pub url: String,
|
||||
#[serde(skip)]
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Preferences {
|
||||
#[serde(default)]
|
||||
pub servers: Vec<Server>,
|
||||
#[serde(default)]
|
||||
pub favorites: BTreeSet<String>,
|
||||
#[serde(default)]
|
||||
pub last_server: Option<usize>,
|
||||
#[serde(default = "open_status")]
|
||||
pub issue_status: String,
|
||||
#[serde(default = "open_status")]
|
||||
pub pull_status: String,
|
||||
}
|
||||
|
||||
impl Default for Preferences {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
servers: Vec::new(),
|
||||
favorites: BTreeSet::new(),
|
||||
last_server: None,
|
||||
issue_status: open_status(),
|
||||
pull_status: open_status(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RepositoryData {
|
||||
pub owner: String,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub language: String,
|
||||
pub open_issues: i64,
|
||||
pub updated: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct State {
|
||||
pub preferences: Preferences,
|
||||
pub active_server: Option<usize>,
|
||||
pub active_repository: Option<(String, String)>,
|
||||
pub active_issue: Option<i64>,
|
||||
pub active_pull: Option<(String, String, i64)>,
|
||||
pub active_commit: Option<String>,
|
||||
pub opened_from_home: bool,
|
||||
pub repositories: Vec<RepositoryData>,
|
||||
pub issues: Vec<models::Issue>,
|
||||
pub pulls: Vec<models::Issue>,
|
||||
pub commits: Vec<models::Commit>,
|
||||
}
|
||||
|
||||
pub struct HomeData {
|
||||
pub activities: Vec<models::Activity>,
|
||||
pub heatmap: Vec<models::UserHeatmapData>,
|
||||
}
|
||||
|
||||
pub struct IssueDetails {
|
||||
pub issue: models::Issue,
|
||||
pub comments: Vec<models::Comment>,
|
||||
}
|
||||
|
||||
pub struct PullDetails {
|
||||
pub pull: models::PullRequest,
|
||||
pub comments: Vec<models::Comment>,
|
||||
}
|
||||
|
||||
pub fn open_status() -> String {
|
||||
"open".into()
|
||||
}
|
||||
Reference in New Issue
Block a user