1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use iocraft::prelude::*;
use proto_core::PluginLocator;
use starbase_console::ui::{Entry, Style, StyledText};
#[derive(Default, Props)]
pub struct LocatorProps<'a> {
pub value: Option<&'a PluginLocator>,
}
#[component]
pub fn Locator<'a>(props: &LocatorProps<'a>) -> impl Into<AnyElement<'a>> + use<'a> {
match props.value.as_ref().expect("`value` prop is required!") {
PluginLocator::Data(_) => element! {
Entry(
name: "Source",
value: element! {
StyledText(
content: "(built-in plugin)",
)
}.into_any()
)
}
.into_any(),
PluginLocator::File(file) => element! {
Entry(
name: "Source file",
value: element! {
StyledText(
content: file.get_resolved_path().to_string_lossy(),
style: Style::Path
)
}.into_any()
)
}
.into_any(),
PluginLocator::Registry(path) => element! {
Entry(
name: "Registry image",
value: element! {
StyledText(
content: path.image.clone(),
style: Style::File
)
}.into_any()
)
}
.into_any(),
PluginLocator::GitHub(github) => element! {
Entry(
name: "Source",
content: "GitHub".to_owned()
) {
View(flex_direction: FlexDirection::Column) {
Entry(
name: "Repository",
value: element! {
StyledText(
content: &github.repo_slug,
style: Style::Id
)
}.into_any()
)
#(github.project_name.as_ref().map(|name| {
element! {
Entry(
name: "Project",
value: element! {
StyledText(
content: name,
style: Style::Label
)
}.into_any()
)
}
}))
Entry(
name: "Tag",
value: element! {
StyledText(
content: github.tag.as_deref().unwrap_or("latest"),
style: Style::Hash
)
}.into_any()
)
}
}
}
.into_any(),
PluginLocator::Url(url) => element! {
Entry(
name: "Source URL",
value: element! {
StyledText(
content: &url.url,
style: Style::Url
)
}.into_any()
)
}
.into_any(),
}
}