pipedash_plugin_api/
defaults.rs

1use crate::schema::*;
2
3pub fn default_table_schema() -> TableSchema {
4    TableSchema::new()
5        .add_table(default_pipeline_runs_table())
6        .add_table(default_pipelines_table())
7}
8
9pub fn default_pipeline_runs_table() -> TableDefinition {
10    TableDefinition {
11        id: "pipeline_runs".to_string(),
12        name: "Pipeline Runs".to_string(),
13        description: Some("Build/run history for pipelines".to_string()),
14        columns: vec![
15            ColumnDefinition {
16                id: "run_number".to_string(),
17                label: "Run".to_string(),
18                description: Some("Run/build number".to_string()),
19                field_path: "run_number".to_string(),
20                data_type: ColumnDataType::Number,
21                renderer: CellRenderer::Text,
22                visibility: ColumnVisibility::Always,
23                default_visible: true,
24                width: Some(100),
25                sortable: true,
26                filterable: false,
27                align: Some("center".to_string()),
28            },
29            ColumnDefinition {
30                id: "status".to_string(),
31                label: "Status".to_string(),
32                description: None,
33                field_path: "status".to_string(),
34                data_type: ColumnDataType::Status,
35                renderer: CellRenderer::StatusBadge,
36                visibility: ColumnVisibility::Always,
37                default_visible: true,
38                width: Some(120),
39                sortable: true,
40                filterable: true,
41                align: None,
42            },
43            ColumnDefinition {
44                id: "branch".to_string(),
45                label: "Branch".to_string(),
46                description: None,
47                field_path: "branch".to_string(),
48                data_type: ColumnDataType::String,
49                renderer: CellRenderer::TruncatedText,
50                visibility: ColumnVisibility::WhenPresent,
51                default_visible: true,
52                width: Some(150),
53                sortable: true,
54                filterable: true,
55                align: None,
56            },
57            ColumnDefinition {
58                id: "started_at".to_string(),
59                label: "Started".to_string(),
60                description: None,
61                field_path: "started_at".to_string(),
62                data_type: ColumnDataType::DateTime,
63                renderer: CellRenderer::DateTime,
64                visibility: ColumnVisibility::Always,
65                default_visible: true,
66                width: Some(180),
67                sortable: true,
68                filterable: false,
69                align: None,
70            },
71            ColumnDefinition {
72                id: "duration_seconds".to_string(),
73                label: "Duration".to_string(),
74                description: None,
75                field_path: "duration_seconds".to_string(),
76                data_type: ColumnDataType::Duration,
77                renderer: CellRenderer::Duration,
78                visibility: ColumnVisibility::Always,
79                default_visible: true,
80                width: Some(120),
81                sortable: true,
82                filterable: false,
83                align: None,
84            },
85            ColumnDefinition {
86                id: "commit_sha".to_string(),
87                label: "Commit".to_string(),
88                description: None,
89                field_path: "commit_sha".to_string(),
90                data_type: ColumnDataType::String,
91                renderer: CellRenderer::Commit,
92                visibility: ColumnVisibility::WhenPresent,
93                default_visible: false,
94                width: Some(140),
95                sortable: false,
96                filterable: false,
97                align: None,
98            },
99            ColumnDefinition {
100                id: "actor".to_string(),
101                label: "Actor".to_string(),
102                description: Some("Who triggered the run".to_string()),
103                field_path: "actor".to_string(),
104                data_type: ColumnDataType::String,
105                renderer: CellRenderer::Text,
106                visibility: ColumnVisibility::WhenPresent,
107                default_visible: false,
108                width: Some(120),
109                sortable: true,
110                filterable: true,
111                align: None,
112            },
113        ],
114        default_sort_column: Some("run_number".to_string()),
115        default_sort_direction: Some("desc".to_string()),
116    }
117}
118
119pub fn default_pipelines_table() -> TableDefinition {
120    TableDefinition {
121        id: "pipelines".to_string(),
122        name: "Pipelines".to_string(),
123        description: Some("All pipelines/workflows".to_string()),
124        columns: vec![
125            ColumnDefinition {
126                id: "name".to_string(),
127                label: "Name".to_string(),
128                description: None,
129                field_path: "name".to_string(),
130                data_type: ColumnDataType::String,
131                renderer: CellRenderer::Text,
132                visibility: ColumnVisibility::Always,
133                default_visible: true,
134                width: Some(200),
135                sortable: true,
136                filterable: true,
137                align: None,
138            },
139            ColumnDefinition {
140                id: "status".to_string(),
141                label: "Status".to_string(),
142                description: None,
143                field_path: "status".to_string(),
144                data_type: ColumnDataType::Status,
145                renderer: CellRenderer::StatusBadge,
146                visibility: ColumnVisibility::Always,
147                default_visible: true,
148                width: Some(120),
149                sortable: true,
150                filterable: true,
151                align: None,
152            },
153            ColumnDefinition {
154                id: "repository".to_string(),
155                label: "Repository".to_string(),
156                description: None,
157                field_path: "repository".to_string(),
158                data_type: ColumnDataType::String,
159                renderer: CellRenderer::TruncatedText,
160                visibility: ColumnVisibility::Always,
161                default_visible: true,
162                width: Some(180),
163                sortable: true,
164                filterable: true,
165                align: None,
166            },
167            ColumnDefinition {
168                id: "branch".to_string(),
169                label: "Branch".to_string(),
170                description: None,
171                field_path: "branch".to_string(),
172                data_type: ColumnDataType::String,
173                renderer: CellRenderer::Badge,
174                visibility: ColumnVisibility::WhenPresent,
175                default_visible: true,
176                width: Some(120),
177                sortable: true,
178                filterable: true,
179                align: None,
180            },
181        ],
182        default_sort_column: Some("name".to_string()),
183        default_sort_direction: Some("asc".to_string()),
184    }
185}