web: add full-screen toggle to YAML viewer dialog#110
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @ddc-baiye, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a new full-screen toggle functionality for the YAML viewer dialog. The primary goal is to significantly improve the user experience when dealing with extensive YAML configurations by providing an expanded view, making it easier to read and interact with the content. This is a front-end only enhancement, ensuring no impact on the application's core logic or data handling. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a useful full-screen toggle feature to the YAML viewer dialog, enhancing usability for large manifests. The implementation is clean and directly addresses the goal. I have a couple of suggestions to further improve the code. One is a performance optimization to memoize the YAML conversion, preventing unnecessary recalculations. The other is a maintainability improvement to replace a magic number in the height calculation with a named constant, making the code clearer and more robust against future UI changes.
|
|
||
| const YAMLViewerDialog = (props?: YAMLViewerDialogProps) => { | ||
| const [fullScreen, setFullScreen] = React.useState(false); | ||
| const yamlText = stringify(props?.content); |
There was a problem hiding this comment.
To improve performance, it's a good practice to memoize the result of stringify using React.useMemo. This prevents re-running the potentially expensive stringification process on every component render, such as when toggling the full-screen mode. This is especially beneficial for large YAML content.
| const yamlText = stringify(props?.content); | |
| const yamlText = React.useMemo(() => stringify(props?.content), [props?.content]); |
| <DialogTitle>YAML</DialogTitle> | ||
| <DialogContent> | ||
| <Box sx={{ height: '400px', overflowY: 'auto' }}> | ||
| <Box sx={{ height: fullScreen ? 'calc(100vh - 160px)' : '400px', overflowY: 'auto' }}> |
There was a problem hiding this comment.
The value 160px is a magic number, which can make the code difficult to understand and maintain. It's presumably calculated from the heights of the dialog title, actions, and content padding. Using a named constant instead would improve readability and make it easier to adjust if the dialog's layout changes.
For example, you could define a constant at the top of the component:
const FULL_SCREEN_VERTICAL_OFFSET = 160; // Combined height for DialogTitle, DialogActions, and paddingsAnd then use it in the sx prop:
height: fullScreen ? `calc(100vh - ${FULL_SCREEN_VERTICAL_OFFSET}px)` : '400px'09a91ec to
73864ca
Compare
4f40fa1 to
54a1425
Compare
|
New changes are detected. LGTM label has been removed. |
a857712 to
43814f4
Compare
5409920 to
b5356e4
Compare
9175ca5 to
21b96a3
Compare
Signed-off-by: ddc-baiye <dongdong.chen@bluedotai.cn>
21b96a3 to
f25233d
Compare
Type
/kind feature
What this PR does / why we need it
Introduces a full-screen toggle in the YAML viewer dialog to improve readability of large manifests. This helps operators review and copy content more comfortably without changing existing data flow or backend behavior.
Special notes for your reviewer
UI-only change in YAML viewer; no backend or global request/middleware behavior is modified. Scope limited to modules/web/src/component/Dialog/YAMLViewerDialog/index.tsx.
Which issue(s) this PR fixes
NONE
Does this PR introduce a user-facing change?