Add API policy pickers and contextual search labels
This commit is contained in:
@@ -384,6 +384,9 @@ type ui struct {
|
||||
disableAPIToken widget.Clickable
|
||||
revokeAPIToken widget.Clickable
|
||||
deleteAPIToken widget.Clickable
|
||||
useCurrentGroupForPolicy widget.Clickable
|
||||
useSelectedEntryForPolicy widget.Clickable
|
||||
clearAPIPolicyTarget widget.Clickable
|
||||
addAPIPolicyRule widget.Clickable
|
||||
phoneSplit widget.Float
|
||||
splitDrag gesture.Drag
|
||||
@@ -669,6 +672,19 @@ func (u *ui) visibleEntrySnapshot() ([]entry, []*widget.Clickable) {
|
||||
return visible, clicks
|
||||
}
|
||||
|
||||
func (u *ui) searchPlaceholder() string {
|
||||
switch u.state.Section {
|
||||
case appstate.SectionAPITokens:
|
||||
return "Search API tokens"
|
||||
case appstate.SectionAPIAudit:
|
||||
return "Search audit log"
|
||||
case appstate.SectionRecycleBin:
|
||||
return "Search recycle bin"
|
||||
default:
|
||||
return "Search vault"
|
||||
}
|
||||
}
|
||||
|
||||
func defaultStatePaths(stateDir string) statePaths {
|
||||
baseDir := strings.TrimSpace(stateDir)
|
||||
if baseDir == "" {
|
||||
@@ -2592,7 +2608,7 @@ func (u *ui) listEmptyState() emptyState {
|
||||
case appstate.SectionAPITokens:
|
||||
return emptyState{
|
||||
Title: "No matching API tokens",
|
||||
Body: fmt.Sprintf("No API tokens match %q. Clear or refine Search vault to find a token by name, client, or expiration.", query),
|
||||
Body: fmt.Sprintf("No API tokens match %q. Clear or refine Search API tokens to find a token by name, client, or expiration.", query),
|
||||
}
|
||||
case appstate.SectionAPIAudit:
|
||||
return emptyState{
|
||||
@@ -2664,7 +2680,7 @@ func (u *ui) detailPlaceholderMessage() string {
|
||||
case appstate.SectionAPITokens:
|
||||
return "Select an API token, issue a new one, or search to narrow the list."
|
||||
case appstate.SectionAPIAudit:
|
||||
return "Select an audit event to inspect it, or use Search vault or the quick filters above."
|
||||
return "Select an audit event to inspect it, or use Search audit log or the quick filters above."
|
||||
case appstate.SectionTemplates:
|
||||
return "Select a template or start a reusable entry."
|
||||
case appstate.SectionRecycleBin:
|
||||
@@ -2996,6 +3012,15 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
|
||||
for u.addAPIPolicyRule.Clicked(gtx) {
|
||||
u.runAction("add API policy rule", u.addAPIPolicyRuleAction)
|
||||
}
|
||||
for u.useCurrentGroupForPolicy.Clicked(gtx) {
|
||||
u.runAction("use current group for API policy", u.useCurrentGroupForPolicyAction)
|
||||
}
|
||||
for u.useSelectedEntryForPolicy.Clicked(gtx) {
|
||||
u.runAction("use selected entry for API policy", u.useSelectedEntryForPolicyAction)
|
||||
}
|
||||
for u.clearAPIPolicyTarget.Clicked(gtx) {
|
||||
u.runAction("clear API policy target", u.clearAPIPolicyTargetAction)
|
||||
}
|
||||
for i := range u.apiPolicyRemoves {
|
||||
for u.apiPolicyRemoves[i].Clicked(gtx) {
|
||||
index := i
|
||||
@@ -4169,7 +4194,7 @@ func (u *ui) listPanel(gtx layout.Context) layout.Dimensions {
|
||||
rows = append(rows, func(gtx layout.Context) layout.Dimensions {
|
||||
gtx.Constraints.Min.X = gtx.Constraints.Max.X
|
||||
return u.outlinedFieldState(gtx, u.isFocused(focusSearch), func(gtx layout.Context) layout.Dimensions {
|
||||
editor := material.Editor(u.theme, &u.search, "Search vault")
|
||||
editor := material.Editor(u.theme, &u.search, u.searchPlaceholder())
|
||||
editor.Color = u.theme.Palette.Fg
|
||||
editor.HintColor = mutedColor
|
||||
return layout.UniformInset(unit.Dp(10)).Layout(gtx, editor.Layout)
|
||||
@@ -4275,7 +4300,7 @@ func (u *ui) listPanel(gtx layout.Context) layout.Dimensions {
|
||||
gtx.Constraints.Min.X = gtx.Constraints.Max.X
|
||||
}
|
||||
return u.outlinedFieldState(gtx, u.isFocused(focusSearch), func(gtx layout.Context) layout.Dimensions {
|
||||
editor := material.Editor(u.theme, &u.search, "Search vault")
|
||||
editor := material.Editor(u.theme, &u.search, u.searchPlaceholder())
|
||||
editor.Color = u.theme.Palette.Fg
|
||||
editor.HintColor = mutedColor
|
||||
return layout.UniformInset(unit.Dp(10)).Layout(gtx, editor.Layout)
|
||||
|
||||
Reference in New Issue
Block a user