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

[WIP] CONSOLE-4062: add custom favicon #14770

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rhamilto
Copy link
Member

@rhamilto rhamilto commented Feb 13, 2025

POC demo

Screen.Recording.2025-02-13.at.4.38.04.PM.mov

To test WIP, start bridge as follows:
./bin/bridge -branding=ocp -statuspage-id="GitHub"

cc: @jhadvig

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Feb 13, 2025

@rhamilto: This pull request references CONSOLE-4062 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

POC demo

Screen.Recording.2025-02-13.at.4.38.04.PM.mov

cc: @jhadvig

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 13, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 13, 2025
@openshift-ci openshift-ci bot requested review from Mylanos and spadgett February 13, 2025 21:39
@openshift-ci openshift-ci bot added component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 13, 2025
Copy link
Contributor

openshift-ci bot commented Feb 17, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Feb 17, 2025

@rhamilto: This pull request references CONSOLE-4062 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

POC demo

Screen.Recording.2025-02-13.at.4.38.04.PM.mov

To test WIP, start bridge as follows:
./bin/bridge -branding=ocp -statuspage-id="GitHub"

cc: @jhadvig

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Feb 17, 2025

@rhamilto: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 8ff16de link false /test okd-scos-e2e-aws-ovn
ci/prow/images 28469e9 link true /test images
ci/prow/backend 28469e9 link true /test backend
ci/prow/frontend 28469e9 link true /test frontend
ci/prow/analyze 28469e9 link true /test analyze
ci/prow/e2e-gcp-console 28469e9 link true /test e2e-gcp-console
ci/prow/okd-scos-images 28469e9 link true /test okd-scos-images

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

window.SERVER_FLAGS = [[ .ServerFlags ]];
let theme = localStorage.getItem('bridge/theme') || 'systemDefault';
if (theme === 'systemDefault' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// update this condition to use the custom favicon serverflag
Copy link
Contributor

Choose a reason for hiding this comment

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

So far in my PR I'm not setting flags for favicon nor masthead as their presence is known only after the given configuration got parsed ( the new CLI argument/yaml field customLogoFiles is used both masthead and favicons, unlike e.g. statuspage-id and the user may only specify masthead). Only related information I currently provide console is the .ServerFlags.CustomLogoURL containing the custom-logo endpoint, which is not enough to determine favicon presence.

Settings favicon/masthead flag would require additional logic in bridge, but the resulting flag check on frontend would be somewhat simpler than confirming the existence of favicon through the API endpoint. WDYT @jhadvig

Copy link
Member Author

Choose a reason for hiding this comment

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

My assumption is that we'll add a flag or flags so that we can make use of them in index.html so we're consistent about where we're setting the favicon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right! previously thought there is some neat way of changing the favicon from the react app, but having the control within the index.html seems more intuitive because the favicon logic is right where it’s applied.

The flags seems like the way to go 👍 will take a look and try to come up how/when to set those.

link.href = e.matches ? faviconDark : '<%= require("./imgs/github.png") %>';
});
[[ end ]]
if (theme === 'systemDefault' && darkModeMediaQuery.matches) {
theme = 'dark';
}
if (theme === 'dark') {
document.documentElement.classList.add('pf-v6-theme-dark', 'pf-v5-theme-dark'); // legacy pf-theme-dark class needed for PF5 component styling
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the assignment of the 'pf-v6-theme-dark' / 'pf-v5-theme-dark' needed in the script tag of the html? Think the same logic is being handled by ThemeProvider

Copy link
Member Author

Choose a reason for hiding this comment

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

It is, but we can't use that code here since this is a go html template.

Copy link
Contributor

@Mylanos Mylanos Feb 20, 2025

Choose a reason for hiding this comment

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

Indeed, what I was just trying to point out is if this is not a repeated logic. Just asking since removing this part of code hasn't really affected the theming behavior, in my local testing testing atleast. I don't have strong opinions on this, so we can just as well keep it.

.then((newStatusPageData) => setStatusPageData(newStatusPageData));
}
}, [setStatusPageData]);
// DO NOT COMMIT
Copy link
Member Author

Choose a reason for hiding this comment

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

Temp hack until the new SERVER_FLAGS are available.

window.SERVER_FLAGS = [[ .ServerFlags ]];
let theme = localStorage.getItem('bridge/theme') || 'systemDefault';
if (theme === 'systemDefault' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// update this condition to use the custom favicon serverflag
Copy link
Member Author

Choose a reason for hiding this comment

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

My assumption is that we'll add a flag or flags so that we can make use of them in index.html so we're consistent about where we're setting the favicon.

link.href = e.matches ? faviconDark : '<%= require("./imgs/github.png") %>';
});
[[ end ]]
if (theme === 'systemDefault' && darkModeMediaQuery.matches) {
theme = 'dark';
}
if (theme === 'dark') {
document.documentElement.classList.add('pf-v6-theme-dark', 'pf-v5-theme-dark'); // legacy pf-theme-dark class needed for PF5 component styling
Copy link
Member Author

Choose a reason for hiding this comment

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

It is, but we can't use that code here since this is a go html template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants