Skip to content

Commit 8ba2c9c

Browse files
authored
Add button to open ToS approval page (#256)
* Add button to open ToS approval page * workflow: Switch from ubuntu-18.04 to ubuntu-latest as runner
1 parent 0712161 commit 8ba2c9c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [pull_request]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-18.04
7+
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
1010
- run: |
@@ -14,7 +14,7 @@ jobs:
1414
#sudo gem install --no-document fpm -v 1.13.1
1515
- uses: actions/setup-go@v3
1616
with:
17-
go-version: '^1.19'
17+
go-version: "^1.19"
1818
- name: Test and Build
1919
run: |
2020
make local

pkg/systray/gui.go

+18
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Gui struct {
6262
Tenant *systray.MenuItem
6363
TenantItems []*TenantItem
6464
GatewayItems []*GatewayItem
65+
AcceptableUse *systray.MenuItem
6566
}
6667
Config Config
6768
}
@@ -77,6 +78,7 @@ const (
7778
LogClicked
7879
AutoConnectClicked
7980
BlackAndWhiteClicked
81+
AcceptableUseClicked
8082

8183
maxTenants = 10
8284
maxGateways = 30
@@ -102,6 +104,8 @@ func NewGUI(ctx context.Context, client pb.DeviceAgentClient, cfg Config) *Gui {
102104
gui.MenuItems.StateInfo = systray.AddMenuItem("", "")
103105
gui.MenuItems.StateInfo.Hide()
104106
gui.MenuItems.State.Disable()
107+
gui.MenuItems.AcceptableUse = systray.AddMenuItem("Acceptable use policy", "")
108+
gui.MenuItems.AcceptableUse.Hide()
105109
gui.MenuItems.Logs = systray.AddMenuItem("Logs", "")
106110
gui.MenuItems.Settings = systray.AddMenuItem("Settings", "")
107111
gui.MenuItems.AutoConnect = gui.MenuItems.Settings.AddSubMenuItemCheckbox("Connect automatically on startup", "", false)
@@ -202,6 +206,8 @@ func (gui *Gui) handleButtonClicks(ctx context.Context) {
202206
accessPrivilegedGateway(name)
203207
case name := <-gui.TenantItemClicked:
204208
gui.activateTenant(ctx, name)
209+
case <-gui.MenuItems.AcceptableUse.ClickedCh:
210+
gui.Events <- AcceptableUseClicked
205211
case <-ctx.Done():
206212
return
207213
}
@@ -302,6 +308,9 @@ func (gui *Gui) handleAgentStatus(agentStatus *pb.AgentStatus) {
302308

303309
tenants := agentStatus.GetTenants()
304310
if len(tenants) <= 1 {
311+
if len(tenants) == 1 && (tenants[0].Name == "NAV" || tenants[0].Name == "nav.no") {
312+
gui.MenuItems.AcceptableUse.Show()
313+
}
305314
return
306315
}
307316

@@ -310,6 +319,7 @@ func (gui *Gui) handleAgentStatus(agentStatus *pb.AgentStatus) {
310319
return tenants[i].GetName() < tenants[j].GetName()
311320
})
312321

322+
gui.MenuItems.AcceptableUse.Hide()
313323
for i, tenant := range tenants {
314324
gui.MenuItems.TenantItems[i].Tenant = tenant
315325

@@ -318,6 +328,9 @@ func (gui *Gui) handleAgentStatus(agentStatus *pb.AgentStatus) {
318328
menuItem.Show()
319329
menuItem.Enable()
320330
if tenant.Active {
331+
if tenant.Name == "NAV" || tenant.Name == "nav.no" {
332+
gui.MenuItems.AcceptableUse.Show()
333+
}
321334
menuItem.Check()
322335
} else {
323336
menuItem.Uncheck()
@@ -441,6 +454,11 @@ func (gui *Gui) handleGuiEvent(guiEvent GuiEvent) {
441454
log.Warn("opening device agent log: %w", err)
442455
}
443456

457+
case AcceptableUseClicked:
458+
err := open.Open("https://naisdevice-approval.nais.io/")
459+
if err != nil {
460+
log.Warn("opening device agent log: %w", err)
461+
}
444462
case QuitClicked:
445463
_, err := gui.DeviceAgentClient.Logout(context.Background(), &pb.LogoutRequest{})
446464
if err != nil {

0 commit comments

Comments
 (0)