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 },
28 ColumnDefinition {
29 id: "status".to_string(),
30 label: "Status".to_string(),
31 description: None,
32 field_path: "status".to_string(),
33 data_type: ColumnDataType::Status,
34 renderer: CellRenderer::StatusBadge,
35 visibility: ColumnVisibility::Always,
36 default_visible: true,
37 width: Some(120),
38 sortable: true,
39 filterable: true,
40 },
41 ColumnDefinition {
42 id: "branch".to_string(),
43 label: "Branch".to_string(),
44 description: None,
45 field_path: "branch".to_string(),
46 data_type: ColumnDataType::String,
47 renderer: CellRenderer::TruncatedText,
48 visibility: ColumnVisibility::WhenPresent,
49 default_visible: true,
50 width: Some(150),
51 sortable: true,
52 filterable: true,
53 },
54 ColumnDefinition {
55 id: "started_at".to_string(),
56 label: "Started".to_string(),
57 description: None,
58 field_path: "started_at".to_string(),
59 data_type: ColumnDataType::DateTime,
60 renderer: CellRenderer::DateTime,
61 visibility: ColumnVisibility::Always,
62 default_visible: true,
63 width: Some(180),
64 sortable: true,
65 filterable: false,
66 },
67 ColumnDefinition {
68 id: "duration_seconds".to_string(),
69 label: "Duration".to_string(),
70 description: None,
71 field_path: "duration_seconds".to_string(),
72 data_type: ColumnDataType::Duration,
73 renderer: CellRenderer::Duration,
74 visibility: ColumnVisibility::Always,
75 default_visible: true,
76 width: Some(120),
77 sortable: true,
78 filterable: false,
79 },
80 ColumnDefinition {
81 id: "commit_sha".to_string(),
82 label: "Commit".to_string(),
83 description: None,
84 field_path: "commit_sha".to_string(),
85 data_type: ColumnDataType::String,
86 renderer: CellRenderer::Commit,
87 visibility: ColumnVisibility::WhenPresent,
88 default_visible: false,
89 width: Some(140),
90 sortable: false,
91 filterable: false,
92 },
93 ColumnDefinition {
94 id: "actor".to_string(),
95 label: "Actor".to_string(),
96 description: Some("Who triggered the run".to_string()),
97 field_path: "actor".to_string(),
98 data_type: ColumnDataType::String,
99 renderer: CellRenderer::Text,
100 visibility: ColumnVisibility::WhenPresent,
101 default_visible: false,
102 width: Some(120),
103 sortable: true,
104 filterable: true,
105 },
106 ],
107 default_sort_column: Some("run_number".to_string()),
108 default_sort_direction: Some("desc".to_string()),
109 }
110}
111
112pub fn default_pipelines_table() -> TableDefinition {
113 TableDefinition {
114 id: "pipelines".to_string(),
115 name: "Pipelines".to_string(),
116 description: Some("All pipelines/workflows".to_string()),
117 columns: vec![
118 ColumnDefinition {
119 id: "name".to_string(),
120 label: "Name".to_string(),
121 description: None,
122 field_path: "name".to_string(),
123 data_type: ColumnDataType::String,
124 renderer: CellRenderer::Text,
125 visibility: ColumnVisibility::Always,
126 default_visible: true,
127 width: Some(200),
128 sortable: true,
129 filterable: true,
130 },
131 ColumnDefinition {
132 id: "status".to_string(),
133 label: "Status".to_string(),
134 description: None,
135 field_path: "status".to_string(),
136 data_type: ColumnDataType::Status,
137 renderer: CellRenderer::StatusBadge,
138 visibility: ColumnVisibility::Always,
139 default_visible: true,
140 width: Some(120),
141 sortable: true,
142 filterable: true,
143 },
144 ColumnDefinition {
145 id: "repository".to_string(),
146 label: "Repository".to_string(),
147 description: None,
148 field_path: "repository".to_string(),
149 data_type: ColumnDataType::String,
150 renderer: CellRenderer::TruncatedText,
151 visibility: ColumnVisibility::Always,
152 default_visible: true,
153 width: Some(180),
154 sortable: true,
155 filterable: true,
156 },
157 ColumnDefinition {
158 id: "branch".to_string(),
159 label: "Branch".to_string(),
160 description: None,
161 field_path: "branch".to_string(),
162 data_type: ColumnDataType::String,
163 renderer: CellRenderer::Badge,
164 visibility: ColumnVisibility::WhenPresent,
165 default_visible: true,
166 width: Some(120),
167 sortable: true,
168 filterable: true,
169 },
170 ],
171 default_sort_column: Some("name".to_string()),
172 default_sort_direction: Some("asc".to_string()),
173 }
174}