Skip to main content

pipedash_plugin_api/
defaults.rs

1use crate::schema::*;
2
3pub fn table_schema(runs: TableDefinition, pipelines: TableDefinition) -> TableSchema {
4    TableSchema::new().add_table(runs).add_table(pipelines)
5}
6
7fn status_column() -> ColumnDefinition {
8    ColumnDefinition::new(
9        "status",
10        "Status",
11        "status",
12        ColumnDataType::Status,
13        CellRenderer::StatusBadge,
14    )
15    .with_width(120)
16    .sortable()
17    .filterable()
18}
19
20pub fn default_pipeline_runs_table() -> TableDefinition {
21    TableDefinition::new(
22        "pipeline_runs",
23        "Pipeline Runs",
24        "Build/run history for pipelines",
25        ("run_number", "desc"),
26        vec![
27            ColumnDefinition::new(
28                "run_number",
29                "Run",
30                "run_number",
31                ColumnDataType::Number,
32                CellRenderer::Text,
33            )
34            .described("Run/build number")
35            .with_width(100)
36            .sortable(),
37            status_column(),
38            ColumnDefinition::new(
39                "branch",
40                "Branch",
41                "branch",
42                ColumnDataType::String,
43                CellRenderer::TruncatedText,
44            )
45            .when_present()
46            .with_width(150)
47            .sortable()
48            .filterable(),
49            ColumnDefinition::new(
50                "started_at",
51                "Started",
52                "started_at",
53                ColumnDataType::DateTime,
54                CellRenderer::DateTime,
55            )
56            .with_width(180)
57            .sortable(),
58            ColumnDefinition::new(
59                "duration_seconds",
60                "Duration",
61                "duration_seconds",
62                ColumnDataType::Duration,
63                CellRenderer::Duration,
64            )
65            .with_width(120)
66            .sortable(),
67            ColumnDefinition::new(
68                "commit_sha",
69                "Commit",
70                "commit_sha",
71                ColumnDataType::String,
72                CellRenderer::Commit,
73            )
74            .when_present()
75            .hidden()
76            .with_width(140),
77            ColumnDefinition::new(
78                "actor",
79                "Actor",
80                "actor",
81                ColumnDataType::String,
82                CellRenderer::Text,
83            )
84            .described("Who triggered the run")
85            .when_present()
86            .hidden()
87            .with_width(120)
88            .sortable()
89            .filterable(),
90        ],
91    )
92}
93
94pub fn default_pipelines_table() -> TableDefinition {
95    TableDefinition::new(
96        "pipelines",
97        "Pipelines",
98        "All pipelines/workflows",
99        ("name", "asc"),
100        vec![
101            ColumnDefinition::new(
102                "name",
103                "Name",
104                "name",
105                ColumnDataType::String,
106                CellRenderer::Text,
107            )
108            .with_width(200)
109            .sortable()
110            .filterable(),
111            status_column(),
112            ColumnDefinition::new(
113                "repository",
114                "Repository",
115                "repository",
116                ColumnDataType::String,
117                CellRenderer::TruncatedText,
118            )
119            .with_width(180)
120            .sortable()
121            .filterable(),
122            ColumnDefinition::new(
123                "branch",
124                "Branch",
125                "branch",
126                ColumnDataType::String,
127                CellRenderer::Badge,
128            )
129            .when_present()
130            .with_width(120)
131            .sortable()
132            .filterable(),
133        ],
134    )
135}