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

feat(ui): Added theme profile to log-viewer #21448

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

surajyadav1108
Copy link
Contributor

Closes #21426

The log viewer will now be set using the preferred theme.
By default, it adopts the global theme as the log viewer profile unless the user has already set a specific preference for that mode

logview-profile.mp4

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Signed-off-by: Surajyadav <[email protected]>
@surajyadav1108 surajyadav1108 requested a review from a team as a code owner January 10, 2025 08:07
Copy link

bunnyshell bot commented Jan 10, 2025

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@jsoref
Copy link
Member

jsoref commented Jan 10, 2025

lgtm

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests works beautifully! Had a couple questions on implementation.

Comment on lines 8 to 11
interface LogViewerTheme {
light: boolean;
dark: boolean;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This data structure is strange to me. What would be the meaning of {light: true, dark: true}?

Copy link
Member

@jsoref jsoref Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the structure is really

interface UseDarkModeInLogViewerForAppTheme {
  light: boolean;
  dark: boolean;
}

where light: false means "don't use dark mode in log viewer when in light mode app theme" and dark: true means "use dark mode in log viewer when in dark mode app theme".
and light: true means "use dark mode in log viewer when in light mode app theme" and dark: false means "use light mode in log viewer when in dark mode app theme".

Those last two settings exist to enable users to hurt their eyes, but apparently they're desirable modes, so here we are :)

-- I can't think of a particularly better way to structure the thing, but...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is what it represent my naming wasn't quite right

Comment on lines 23 to 27
LogViewerTheme: {
light: false,
dark: true
},
darkMode: currentTheme === 'dark'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we duplicating the theme params here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 yes, there is duplication happening here as both darkMode and LogViewerTheme are controlling the state and used to update and store preferences,

tried multiple ways to have the userpreference with the current darkMode controller without duplication coudn't get to a good solution without it, I am refactoring it with small change like using darkMode itself

LogViewerTheme: {
light: prefs.appDetails.darkMode,
dark: prefs.appDetails.darkMode
}
and if this is getting overly complicated or redundant we can just have the log-viewer darkMode toggle controlled by global theme instead with no saved preferences. let me know where can I improve if this is not quite right

Signed-off-by: Surajyadav <[email protected]>
Signed-off-by: Surajyadav <[email protected]>
Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but the logic is quite hard to understand. This might be caused by the variable naming such as profile and newDarkMode.

The behavior in the video LGTM. But if I read the code, I have no idea that it is doing that. I think the code should be a bit more self-explaining.

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 this pull request may close these issues.

Top level Dark Mode should set the default for logs to dark mode
4 participants