repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
0c9b6a0
parent
2bc909f
author
Eric Bower
date
2024-12-15 15:53:40 +0000 UTC
chore(pico): added services section to settings page

This will hopefully make it easier to understand what services a user
can access
2 files changed,  +42, -1
M tui/createaccount/create.go
+1, -0
1@@ -201,6 +201,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2 func (m Model) View() string {
3 	s := common.LogoView() + "\n\n"
4 	pubkey := fmt.Sprintf("pubkey: %s", utils.KeyForSha256(m.shared.Session.PublicKey()))
5+	s += "\nWelcome to pico.sh's management TUI.  By creating an account you get access to our pico services.  We have free and paid services.  After you create an account, you can go to the Settings page to see which services you can access.\n\n"
6 	s += m.shared.Styles.Label.SetString(pubkey).String()
7 	s += "\n\n" + m.input.View() + "\n\n"
8 
M tui/settings/settings.go
+41, -1
 1@@ -80,7 +80,7 @@ func (m Model) View() string {
 2 	if m.state == stateLoading {
 3 		return "Loading ..."
 4 	}
 5-	return m.featuresView() + "\n" + m.analyticsView()
 6+	return m.servicesView() + "\n" + m.featuresView() + "\n" + m.analyticsView()
 7 }
 8 
 9 func (m Model) findAnalyticsFeature() *db.FeatureFlag {
10@@ -116,6 +116,46 @@ We will only store usage statistics for 1 year from when the event was created.`
11 	return m.shared.Styles.RoundedBorder.Width(maxWidth).SetString(str).String()
12 }
13 
14+func (m Model) servicesView() string {
15+	headers := []string{
16+		"Name",
17+		"Status",
18+	}
19+
20+	hasPlus := m.shared.PlusFeatureFlag != nil
21+
22+	data := [][]string{
23+		{"prose", "active"},
24+		{"pipe", "active"},
25+		{"pastes", "active"},
26+		{"rss-to-email", "active"},
27+	}
28+
29+	if hasPlus {
30+		data = append(
31+			data,
32+			[]string{"pages", "active"},
33+			[]string{"tuns", "active"},
34+			[]string{"irc bouncer", "active"},
35+		)
36+	} else {
37+		data = append(
38+			data,
39+			[]string{"pages", "free tier"},
40+			[]string{"tuns", "requires pico+"},
41+			[]string{"IRC bouncer", "requires pico+"},
42+		)
43+	}
44+
45+	t := table.New().
46+		Border(lipgloss.RoundedBorder()).
47+		BorderStyle(m.shared.Styles.Renderer.NewStyle().BorderForeground(common.Indigo)).
48+		Width(maxWidth).
49+		Headers(headers...).
50+		Rows(data...)
51+	return "Services\n" + t.String()
52+}
53+
54 func (m Model) featuresView() string {
55 	headers := []string{
56 		"Name",