Skip to content

Commit 08fc2ec

Browse files
committed
Small UX adjustments
1 parent 7a5dddb commit 08fc2ec

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

internal/usercommands/admin.server.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ var (
2222
errValueLocked = errors.New("This config value is locked. You must edit the config file directly.")
2323
)
2424

25+
const (
26+
newValuePrompt = `New value for <ansi fg="6">%s</ansi>`
27+
)
28+
2529
/*
2630
* Role Permissions:
2731
* server (All)
@@ -321,7 +325,7 @@ func server_Config(_ string, user *users.UserRecord, room *rooms.Room, flags eve
321325
return true, nil
322326
}
323327

324-
question := cmdPrompt.Ask(`New Value for `+configPrefix, []string{fmt.Sprintf("%v", configVal)}, fmt.Sprintf("%v", configVal))
328+
question := cmdPrompt.Ask(fmt.Sprintf(newValuePrompt, configPrefix), []string{fmt.Sprintf("%v", configVal)}, fmt.Sprintf("%v", configVal))
325329
if !question.Done {
326330
return true, nil
327331
}
@@ -330,7 +334,10 @@ func server_Config(_ string, user *users.UserRecord, room *rooms.Room, flags eve
330334

331335
err := configs.SetVal(configPrefix, question.Response)
332336
if err == nil {
333-
user.SendText(configPrefix + " has been set to: " + question.Response)
337+
allConfigData := configs.GetConfig().AllConfigData()
338+
user.SendText(``)
339+
user.SendText(fmt.Sprintf(`<ansi fg="6">%s</ansi> has been set to: <ansi fg="9">%s<ansi>`, configPrefix, allConfigData[configPrefix]))
340+
user.SendText(``)
334341
return true, nil
335342
}
336343
user.SendText(err.Error())
@@ -365,6 +372,7 @@ func server_Config(_ string, user *users.UserRecord, room *rooms.Room, flags eve
365372
if !ok {
366373
question.RejectResponse()
367374
menuOptions, _ = getConfigOptions("")
375+
fullPath = strings.ToLower(configPrefix)
368376
} else {
369377

370378
if len(menuOptions) == 1 {
@@ -380,14 +388,20 @@ func server_Config(_ string, user *users.UserRecord, room *rooms.Room, flags eve
380388

381389
allConfigData := configs.GetConfig().AllConfigData()
382390
if configVal, ok := allConfigData[fullPath]; ok {
383-
cmdPrompt.Ask(`New Value for `+fullPath, []string{fmt.Sprintf("%v", configVal)}, fmt.Sprintf("%v", configVal))
391+
392+
cmdPrompt.Ask(fmt.Sprintf(newValuePrompt, fullPath), []string{fmt.Sprintf("%v", configVal)}, fmt.Sprintf("%v", configVal))
384393
return true, nil
385394
}
386395
}
387396

388397
cmdPrompt.Store("config-selected", fullPath)
389398
}
390399

400+
if fullPath != "" {
401+
user.SendText(``)
402+
user.SendText(` [<ansi fg="6">` + fullPath + `</ansi>]`)
403+
}
404+
391405
tplTxt, _ := templates.Process("tables/numbered-list", menuOptions, user.UserId)
392406
user.SendText(tplTxt)
393407

0 commit comments

Comments
 (0)