@@ -74,11 +74,11 @@ type Model struct {
7474 ttl string
7575 match string
7676 textInput textinput.Model
77+ wasPreset bool
7778}
7879
79- func New (parentModel tea.Model , rdb * redis.Client , rule * RedisCommon.Rule , confirm bool , applicationName string ) Model {
80+ func New (parentModel tea.Model , rdb * redis.Client , rule * RedisCommon.Rule , confirm bool , applicationName string , ruleType RedisCommon. RuleType ) Model {
8081 items := []list.Item {
81- item {RedisCommon .QueryIds },
8282 item {RedisCommon .Tables },
8383 item {RedisCommon .TablesAll },
8484 item {RedisCommon .TablesAny },
@@ -93,6 +93,7 @@ func New(parentModel tea.Model, rdb *redis.Client, rule *RedisCommon.Rule, confi
9393 ti .Focus ()
9494 ti .CharLimit = 30
9595 ti .Width = 30
96+ wasPreset := ruleType != RedisCommon .Unknown
9697
9798 m := Model {
9899 parentModel : parentModel ,
@@ -101,9 +102,10 @@ func New(parentModel tea.Model, rdb *redis.Client, rule *RedisCommon.Rule, confi
101102 isNew : rule == nil ,
102103 applicationName : applicationName ,
103104 typeSelectorList : typeSelectList ,
104- ruleType : RedisCommon . Unknown ,
105+ ruleType : ruleType ,
105106 textInput : ti ,
106107 ttl : "" ,
108+ wasPreset : wasPreset ,
107109 }
108110
109111 return m
@@ -166,7 +168,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
166168 if m .match != "" {
167169 m .match = ""
168170 return m , nil
169- } else if m .ruleType != RedisCommon .Unknown {
171+ } else if m .ruleType != RedisCommon .Unknown && ! m . wasPreset {
170172 m .ruleType = RedisCommon .Unknown
171173 return m , nil
172174 }
@@ -241,16 +243,22 @@ func (m Model) View() string {
241243 var b strings.Builder
242244
243245 if m .ruleType == RedisCommon .Unknown {
244- b .WriteString ("Select the type of rule you want to create.\n Press [CTRL+B] to return to the previous screen.\n " )
246+ b .WriteString (" == Create rule menu == \n \n Select the type of rule you want to create.\n Press [CTRL+B] to return to the previous screen.\n \n " )
245247 b .WriteString (m .typeSelectorList .View ())
246248 return b .String ()
247249 } else if m .match == "" && m .ruleType != RedisCommon .All {
248250 b .WriteString (m .ruleSoFar ())
249- b .WriteString ("Enter the string to match against (e.g., table names, regular expression, etc.): " )
251+ if m .ruleType == RedisCommon .Regex {
252+ b .WriteString ("Enter a regular expression to match against:" )
253+ } else if m .ruleType == RedisCommon .QueryIds {
254+ b .WriteString ("Enter a comma-separated list of Query IDs to match against:" )
255+ } else {
256+ b .WriteString ("Enter a comma-separated list of tables to match against:" )
257+ }
250258 b .WriteString (m .textInput .View ())
251259 } else {
252260 b .WriteString (m .ruleSoFar ())
253- b .WriteString ("Enter a TTL in the form of a duration (e.g. 1h, 300s, 5m): " )
261+ b .WriteString ("Enter a TTL in the form of a duration (e.g. 1h, 300s, 5m):" )
254262 b .WriteString (m .textInput .View ())
255263 }
256264
0 commit comments