oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

1package home
2
3import "strings"
4
5type catalogApp struct {
6 Name, Href, Status, Icon string
7}
8
9// This display catalog grants no integration or provisioning capability.
10// Those remain governed by directoryApps and the destination checks.
11func directoryCatalog(cfg Runtime) []catalogApp {
12 docs := catalogApp{Name: "Docs", Icon: "/static/brand/docs.svg", Href: docsEntryPath, Status: "Choose a team"}
13 if cfg.docsPreviewOrigin != "" {
14 docs.Href = cfg.docsPreviewOrigin + "/signin"
15 docs.Status = "Open preview"
16 }
17 apps := []catalogApp{
18 docs,
19 {Name: "Sheets", Icon: "/static/brand/sheets.svg", Status: "Not connected to Oficina yet"},
20 {Name: "Slides", Icon: "/static/brand/slides.svg", Status: "Not connected to Oficina yet"},
21 {Name: "Calendar", Icon: "/static/brand/calendar.svg", Status: "Not connected to Oficina yet"},
22 {Name: "Calls", Icon: "/static/brand/calls.svg", Status: "Coming soon"},
23 {Name: "Memoria", Icon: "/static/brand/memoria.svg", Status: "Not connected to Oficina yet"},
24 {Name: "Mail", Icon: "/static/brand/mail.svg", Status: "Separate sign-in"},
25 {Name: "Files", Icon: "/static/brand/files.svg", Status: "Separate sign-in"},
26 }
27 for i := range apps {
28 for _, app := range directoryApps() {
29 if app.name == apps[i].Name && app.integrated && apps[i].Href == "" {
30 apps[i].Href = "/apps/" + app.slug
31 apps[i].Status = "Choose a team"
32 }
33 }
34 if origin := cfg.appPreviewOrigins[strings.ToLower(apps[i].Name)]; origin != "" {
35 apps[i].Href = origin + "/signin"
36 apps[i].Status = "Open preview"
37 }
38 }
39 for i := range apps {
40 apps[i].Icon = versioned(apps[i].Icon)
41 }
42 return apps
43}
44
45// Preview navigation is an operator choice, not an additional team route.
46// The destination must already have its own Home consumer registration.
47func (cfg Runtime) validAppPreviews() bool {
48 if cfg.docsPreviewOrigin != "" {
49 if !cfg.validPreviewOrigin(cfg.docsPreviewOrigin) || cfg.appPreviewOrigins["docs"] != "" {
50 return false
51 }
52 }
53 for app, origin := range cfg.appPreviewOrigins {
54 switch app {
55 case "docs", "sheets", "slides", "calendar", "calls", "memoria", "mail", "files":
56 default:
57 return false
58 }
59 if !cfg.validPreviewOrigin(origin) {
60 return false
61 }
62 }
63 return true
64}
65func (cfg Runtime) validPreviewOrigin(origin string) bool {
66 _, err := originHost(origin)
67 return cfg.role == "directory" && err == nil && origin != cfg.origins.Credential && origin != cfg.origins.Directory
68}
69