Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table for permissions doesn't use same colors other tables do #1951

Closed
MaienM opened this issue Feb 4, 2023 · 3 comments · Fixed by #2150
Closed

Table for permissions doesn't use same colors other tables do #1951

MaienM opened this issue Feb 4, 2023 · 3 comments · Fixed by #2150

Comments

@MaienM
Copy link

MaienM commented Feb 4, 2023




Describe the bug

The colors of the permission table for (clustter)roles don't use the views.table/frame.status colors like other tables do.

(The n/a in the info for CPU/MEM also seem to not be affected by any color option in the config, but this isn't nearly as bothersome.)

To Reproduce

I've made a skin that sets every color option to black (using internal/config/styles.go as a guide for what options are available), just to make sure I wasn't just setting changing the wrong option:

Henry Ford's personal skin
k9s:
  body:
    fgColor: black
    bgColor: black
    logoColor: black
    logoColorMsg: black
    logoColorInfo: black
    logoColorWarn: black
    logoColorError: black
  prompt:
    fgColor: black
    bgColor: black
    suggestColor: black
    border:
      default: black
      command: black
  help:
    fgColor: black
    bgColor: black
    selectionColor: black
    keyColor: black
    numKeyColor: black
  frame:
    title:
      fgColor: black
      bgColor: black
      highlightColor: black
      counterColor: black
      filterColor: black
    border:
      fgColor: black
      focusColor: black
    menu:
      fgColor: black
      keyColor: black
      numKeyColor: black
    crumbs:
      fgColor: black
      bgColor: black
      activeColor: black
    status:
      newColor: black
      modifyColor: black
      addColor: black
      pendingColor: black
      errorColor: black
      highlightColor: black
      killColor: black
      completedColor: black
  info:
    fgColor: black
    sectionColor: black
  views:
    table:
      fgColor: black
      bgColor: black
      cursorFgColor: black
      cursorBgColor: black
      markColor: black
      header:
        fgColor: black
        bgColor: black
        sorterColor: black
    xray:
      fgColor: black
      bgColor: black
      cursorColor: black
      cursorTextColor: black
      graphicColor: black
    charts:
      bgColor: black
      dialBgColor: black
      chartBgColor: black
      defaultDialColors:
        - black
      defaultChartColors:
        - black
    yaml:
      keyColor: black
      valueColor: black
      colonColor: black
    picker:
      mainColor: black
      focusColor: black
      shortcutColor: black
    logs:
      fgColor: black
      bgColor: black
      indicator:
        fgColor: black
        bgColor: black
        toggleOnColor: black
        toggleOffColor: black
  dialog:
    fgColor: black
    bgColor: black
    buttonFgColor: black
    buttonBgColor: black
    buttonFocusFgColor: black
    buttonFocusBgColor: black
    labelFgColor: black
    fieldFgColor: black

Steps to reproduce the behavior:

  1. Navigate to roles.
  2. Press enter on a role.
  3. Use the skin shown above.
  4. Note that (some) of the table colors are unchanged.

Expected behavior

I would expect the colors of this table to be either affected by the same color options that other tables use, or to have its own set of options.

Screenshots

2023-02-04T12:49:26+0100-1271x1065

Versions (please complete the following information):

  • OS: Linux (NixOS)
  • K9s: 0.27.2
  • K8s: 1.25.4
@placintaalexandru
Copy link
Contributor

placintaalexandru commented Mar 23, 2023

Hello @MaienM

Can you confirm that this is the expected output? I also tested with my skin and the colour is maintained.

image

@MaienM
Copy link
Author

MaienM commented Apr 26, 2023

It's an improvement for sure, thanks! Looks like the checks and crosses are still using fixed colors though, and as you mention in your PR there are some other places that do as well. Perhaps it's worth to - as you suggest in the linked comment - keep this issue open as an overview of work that remains to be done to get all colors adjustable from the skin?

I did a quick search on the codebase to get an idea of how many more such places there might be, and it looks like there are actually quite a few (67)! There's a few false positives in this list, but at a glance most of these look to be real. I wonder how many of these could be easily converted to use an existing color from the skin, and how many (if any) would need new categories added to the skins.

> rg 'tcell.Color[A-Z]' --glob '!*_test.go' --line-number --no-heading

internal/render/pv.go:37:			return tcell.ColorGreen
internal/render/policy.go:35:		return tcell.ColorMediumSpringGreen
internal/render/popeye.go:30:			c = tcell.ColorOrange
internal/render/ofaas.go:36:// 		return tcell.ColorPaleTurquoise
internal/render/dir.go:23:		return tcell.ColorCadetBlue
internal/tchart/gauge.go:78:	style = style.Foreground(tcell.ColorYellow)
internal/tchart/gauge.go:103:		tview.Print(sc, legend, rect.Min.X, o.Y+3, rect.Dx(), tview.AlignCenter, tcell.ColorWhite)
internal/render/portforward.go:39:		return tcell.ColorSkyblue
internal/render/helm.go:30:		return tcell.ColorMediumSpringGreen
internal/render/reference.go:20:		return tcell.ColorCadetBlue
internal/tchart/sparkline.go:116:		tview.Print(screen, legend, rect.Min.X, rect.Max.Y, rect.Dx(), tview.AlignCenter, tcell.ColorWhite)
internal/config/styles.go:243:		return tcell.ColorDefault
internal/tchart/component.go:12:	okColor, faultColor         = tcell.ColorPaleGreen, tcell.ColorOrangeRed
internal/tchart/component.go:34:		noColor:      tcell.ColorDefault,
internal/tchart/component.go:36:		dimmed:       tcell.StyleDefault.Background(tview.Styles.PrimitiveBackgroundColor).Foreground(tcell.ColorGray).Dim(true),
internal/tchart/component.go:104:		for name, co := range tcell.ColorNames {
internal/render/subject.go:19:		return tcell.ColorMediumSpringGreen
internal/render/benchmark.go:37:		return tcell.ColorPaleGreen
internal/render/screen_dump.go:22:		return tcell.ColorNavajoWhite
internal/ui/tree.go:43:	t.SetGraphicsColor(tcell.ColorCadetBlue)
internal/view/details.go:59:	d.text.SetHighlightColor(tcell.ColorOrange)
internal/view/details.go:60:	d.SetTitleColor(tcell.ColorAqua)
internal/view/image_extender.go:150:		SetLabelColor(tcell.ColorAqua).
internal/view/image_extender.go:151:		SetFieldTextColor(tcell.ColorOrange)
internal/ui/flash.go:33:	f.SetTextColor(tcell.ColorAqua)
internal/ui/flash.go:105:		return tcell.ColorOrange
internal/ui/flash.go:107:		return tcell.ColorOrangeRed
internal/ui/flash.go:109:		return tcell.ColorNavajoWhite
internal/view/reference.go:21:	r.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen)
internal/view/reference.go:22:	r.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediumSpringGreen).Attributes(tcell.AttrNone))
internal/view/alias.go:25:	a.GetTable().SetBorderFocusColor(tcell.ColorAliceBlue)
internal/view/alias.go:26:	a.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorAliceBlue).Attributes(tcell.AttrNone))
internal/view/logger.go:40:	l.SetHighlightColor(tcell.ColorOrange)
internal/view/logger.go:41:	l.SetTitleColor(tcell.ColorAqua)
internal/view/benchmark.go:27:	b.GetTable().SetBorderFocusColor(tcell.ColorSeaGreen)
internal/view/benchmark.go:28:	b.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorSeaGreen).Attributes(tcell.AttrNone))
internal/ui/dialog/error.go:21:		SetFieldTextColor(tcell.ColorIndianRed)
internal/ui/dialog/error.go:32:	modal.SetTextColor(tcell.ColorOrangeRed)
internal/view/scale_extender.go:140:		SetLabelColor(tcell.ColorAqua).
internal/view/scale_extender.go:141:		SetFieldTextColor(tcell.ColorOrange)
internal/view/screen_dump.go:26:	s.GetTable().SetBorderFocusColor(tcell.ColorSteelBlue)
internal/view/screen_dump.go:27:	s.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorRoyalBlue).Attributes(tcell.AttrNone))
internal/view/picker.go:36:	p.SetMainTextColor(tcell.ColorWhite)
internal/view/picker.go:38:	p.SetShortcutColor(tcell.ColorAqua)
internal/view/picker.go:39:	p.SetSelectedBackgroundColor(tcell.ColorAqua)
internal/view/pf.go:34:	p.GetTable().SetBorderFocusColor(tcell.ColorDodgerBlue)
internal/view/pf.go:35:	p.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorDodgerBlue).Attributes(tcell.AttrNone))
internal/view/pf.go:195:		SetTextColor(tcell.ColorFuchsia).
internal/view/cow.go:39:	c.SetHighlightColor(tcell.ColorOrange)
internal/view/cow.go:40:	c.SetTitleColor(tcell.ColorAqua)
internal/view/rs.go:84:		SetTextColor(tcell.ColorFuchsia).
internal/view/context.go:90:		SetLabelColor(tcell.ColorAqua).
internal/view/context.go:91:		SetFieldTextColor(tcell.ColorOrange)
internal/view/popeye.go:26:	p.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen)
internal/view/popeye.go:27:	p.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediumSpringGreen).Attributes(tcell.AttrNone))
internal/ui/table.go:74:	t.SetBackgroundColor(tcell.ColorDefault)
internal/ui/prompt.go:266:		return tcell.ColorAqua
internal/ui/prompt.go:268:		return tcell.ColorSeaGreen
internal/view/live_view.go:64:	v.text.SetHighlightColor(tcell.ColorOrange)
internal/view/live_view.go:65:	v.SetTitleColor(tcell.ColorAqua)
internal/view/helm.go:26:	c.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen)
internal/view/helm.go:27:	c.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediurg 'tcell.Color[A-Z]' --glob '!*_test.go' --line-number --no-headingmSpringGreen).Attributes(tcell.AttrNone))
internal/view/cronjob.go:187:		SetLabelColor(tcell.ColorAqua).
internal/view/cronjob.go:188:		SetFieldTextColor(tcell.ColorOrange)
internal/ui/indicator.go:33:	s.SetTextColor(tcell.ColorWhite)
internal/view/dir.go:40:	d.GetTable().SetBorderFocusColor(tcell.ColorAliceBlue)
internal/view/dir.go:41:	d.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorAliceBlue).Attributes(tcell.AttrNone))

@placintaalexandru
Copy link
Contributor

placintaalexandru commented May 8, 2023

After some digging it seems that ticks and crosses colour from permissions are hardcoded here.
From my understanding, to make these colours obey the skin.yaml file, the Renderer interface must be updated: change signature of Render function to receive at least a pointer to a Style struct which is not hard to do, but before diving into it I would need to know if this behaviour is desired.

Perhaps @derailed or @slimus or someone else could tell if this is worth doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants