1use std::collections::HashMap;
2
3use serde::{
4 Deserialize,
5 Serialize,
6};
7
8use crate::types::{
9 PipelineStatus,
10 ResourceState,
11};
12
13mod defaults;
14
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16pub struct DisplayField {
17 pub label: String,
18 pub value: String,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22pub struct Notice {
23 pub title: String,
24 pub message: String,
25}
26
27#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
28pub struct StatusOption {
29 pub value: PipelineStatus,
30 pub label: String,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
34pub struct PipelineTerminology {
35 pub item: String,
36 pub items: String,
37 pub group: String,
38 pub groups: String,
39 pub group_title: String,
40 pub source_title: String,
41 pub sources_title: String,
42 pub history: String,
43 pub trigger: String,
44 pub run: String,
45 pub runs: String,
46 pub organization_label: String,
47 pub section_count_label: String,
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
51pub struct WizardCopy {
52 pub credentials_description: String,
53 pub name_placeholder: String,
54 pub permissions_title: String,
55}
56
57#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
58pub struct ActionCopy {
59 pub label: String,
60 pub compact_label: String,
61 pub title: String,
62 pub success: Notice,
63 pub error_title: String,
64 pub note: Option<String>,
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
68pub struct ViewCopy {
69 pub title: String,
70 pub list_title: String,
71 pub search_placeholder: String,
72 pub matching_empty: Notice,
73 pub hidden_empty: Notice,
74 pub empty: Notice,
75 pub pinned_empty: Notice,
76}
77
78#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
79pub struct PluginPresentation {
80 pub terminology: PipelineTerminology,
81 pub status_options: Vec<StatusOption>,
82 pub wizard: WizardCopy,
83 pub view: ViewCopy,
84 pub trigger: ActionCopy,
85 pub rerun: ActionCopy,
86 pub history_note: Option<String>,
87 pub empty_history_description: String,
88 pub run_details_title: String,
89 pub progress_title: String,
90 pub archived_notice: Option<Notice>,
91 pub force_cancel_confirmation: String,
92}
93
94impl PluginPresentation {
95 pub fn new(provider_name: &str) -> Self {
96 defaults::presentation(provider_name)
97 }
98}
99
100#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
101pub struct RunDisplay {
102 pub title: String,
103 pub message: Option<String>,
104 pub context: Vec<DisplayField>,
105 pub started_label: String,
106}
107
108#[derive(Debug, Clone, Copy)]
109pub struct PipelineFacts<'a> {
110 pub id: &'a str,
111 pub status: PipelineStatus,
112 pub branch: Option<&'a str>,
113 pub workflow_file: Option<&'a str>,
114 pub resource_state: Option<&'a ResourceState>,
115 pub metadata: &'a HashMap<String, serde_json::Value>,
116}
117
118#[derive(Debug, Clone, Copy)]
119pub struct RunFacts<'a> {
120 pub run_number: i64,
121 pub status: PipelineStatus,
122 pub branch: Option<&'a str>,
123 pub actor: Option<&'a str>,
124 pub commit_message: Option<&'a str>,
125 pub inputs: Option<&'a serde_json::Value>,
126 pub metadata: &'a HashMap<String, serde_json::Value>,
127}