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 empty_history_description: String,
87 pub run_details_title: String,
88 pub progress_title: String,
89 pub archived_notice: Option<Notice>,
90 pub force_cancel_confirmation: String,
91}
92
93impl PluginPresentation {
94 pub fn new(provider_name: &str) -> Self {
95 defaults::presentation(provider_name)
96 }
97}
98
99#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
100pub struct RunDisplay {
101 pub title: String,
102 pub context: Vec<DisplayField>,
103 pub started_label: String,
104}
105
106#[derive(Debug, Clone, Copy)]
107pub struct PipelineFacts<'a> {
108 pub id: &'a str,
109 pub status: PipelineStatus,
110 pub branch: Option<&'a str>,
111 pub workflow_file: Option<&'a str>,
112 pub resource_state: Option<&'a ResourceState>,
113 pub metadata: &'a HashMap<String, serde_json::Value>,
114}
115
116#[derive(Debug, Clone, Copy)]
117pub struct RunFacts<'a> {
118 pub run_number: i64,
119 pub status: PipelineStatus,
120 pub branch: Option<&'a str>,
121 pub actor: Option<&'a str>,
122 pub inputs: Option<&'a serde_json::Value>,
123 pub metadata: &'a HashMap<String, serde_json::Value>,
124}