v0.3.4 fc39bd9

reload_ext.go RawHistoryFolder

1package modes
2
3import (
4	"context"
5	"fmt"
6	"strings"
7	"time"
8
9	"github.com/patriceckhart/zot/packages/agent/extensions"
10)
11
12const reloadStatusDuration = 5 * time.Second
13
14func formatReloadStatus(stats extensions.ReloadStats) (string, bool) {
15	msg := fmt.Sprintf("reloaded: %d stopped, %d loaded (%d ready)", stats.Stopped, stats.Loaded, stats.Ready)
16	if len(stats.Errors) == 0 {
17		return msg, false
18	}
19	details := make([]string, 0, len(stats.Errors))
20	for _, err := range stats.Errors {
21		if err != nil {
22			details = append(details, err.Error())
23		}
24	}
25	msg += fmt.Sprintf(", %d error(s)", len(stats.Errors))
26	if len(details) > 0 {
27		msg += ": " + strings.Join(details, "; ")
28	}
29	return msg, true
30}
31
32func (i *Interactive) setReloadStatus(msg string, failed bool) uint64 {
33	i.mu.Lock()
34	defer i.mu.Unlock()
35	i.reloadStatusSeq++
36	if failed {
37		i.statusOK = ""
38		i.statusErr = msg
39		return i.reloadStatusSeq
40	}
41	i.statusOK = msg
42	i.statusErr = ""
43	return i.reloadStatusSeq
44}
45
46func (i *Interactive) clearReloadStatus(seq uint64, msg string, failed bool) bool {
47	i.mu.Lock()
48	defer i.mu.Unlock()
49	if i.reloadStatusSeq != seq {
50		return false
51	}
52	if failed {
53		if i.statusErr != msg {
54			return false
55		}
56		i.statusErr = ""
57		return true
58	}
59	if i.statusOK != msg {
60		return false
61	}
62	i.statusOK = ""
63	return true
64}
65
66func (i *Interactive) dismissReloadStatus(ctx context.Context, seq uint64, msg string, failed bool) {
67	timer := time.NewTimer(reloadStatusDuration)
68	defer timer.Stop()
69	select {
70	case <-ctx.Done():
71		return
72	case <-timer.C:
73		if i.clearReloadStatus(seq, msg, failed) {
74			i.invalidate()
75		}
76	}
77}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close