1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(rename_all = "snake_case")]
11pub enum OperationType {
12 AddUser,
14 RemoveUser,
16 UpdateRole,
18 UpdateFolderRights,
20}
21
22impl std::fmt::Display for OperationType {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24 match self {
25 OperationType::AddUser => write!(f, "add_user"),
26 OperationType::RemoveUser => write!(f, "remove_user"),
27 OperationType::UpdateRole => write!(f, "update_role"),
28 OperationType::UpdateFolderRights => write!(f, "update_folder_rights"),
29 }
30 }
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
35#[serde(rename_all = "snake_case")]
36pub enum OperationStatus {
37 Pending,
39 InProgress,
41 Completed,
43 Cancelled,
45 Failed,
47}
48
49impl std::fmt::Display for OperationStatus {
50 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 match self {
52 OperationStatus::Pending => write!(f, "pending"),
53 OperationStatus::InProgress => write!(f, "in_progress"),
54 OperationStatus::Completed => write!(f, "completed"),
55 OperationStatus::Cancelled => write!(f, "cancelled"),
56 OperationStatus::Failed => write!(f, "failed"),
57 }
58 }
59}
60
61#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63#[serde(rename_all = "snake_case")]
64pub enum FolderType {
65 ProjectFiles,
67 Plans,
69 Custom(String),
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
75#[serde(rename_all = "snake_case")]
76pub enum PermissionLevel {
77 ViewOnly,
79 ViewDownload,
81 UploadOnly,
83 ViewDownloadUpload,
85 ViewDownloadUploadEdit,
87 FolderControl,
89}
90
91impl PermissionLevel {
92 pub fn to_actions(&self) -> Vec<&'static str> {
94 match self {
95 PermissionLevel::ViewOnly => vec!["VIEW", "COLLABORATE"],
96 PermissionLevel::ViewDownload => vec!["VIEW", "DOWNLOAD", "COLLABORATE"],
97 PermissionLevel::UploadOnly => vec!["PUBLISH"],
98 PermissionLevel::ViewDownloadUpload => {
99 vec!["PUBLISH", "VIEW", "DOWNLOAD", "COLLABORATE"]
100 }
101 PermissionLevel::ViewDownloadUploadEdit => {
102 vec!["PUBLISH", "VIEW", "DOWNLOAD", "COLLABORATE", "EDIT"]
103 }
104 PermissionLevel::FolderControl => {
105 vec![
106 "PUBLISH",
107 "VIEW",
108 "DOWNLOAD",
109 "COLLABORATE",
110 "EDIT",
111 "CONTROL",
112 ]
113 }
114 }
115 }
116}