Skip to content

Conversation

@logonoff
Copy link
Member

Dependent on review from patternfly/patternfly-react#12113

after:

image image

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 17, 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 Nov 17, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Nov 17, 2025

@logonoff: This pull request references CONSOLE-4701 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.21.0" version, but no target version was set.

In response to this:

Dependent on review from patternfly/patternfly-react#12113

after:

image image

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.

@logonoff
Copy link
Member Author

/assign @sg00dwin

@openshift-ci openshift-ci bot added component/core Related to console core functionality component/shared Related to console-shared approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Nov 17, 2025
@logonoff logonoff changed the title [wip] CONSOLE-4701: Add fontsize+theme to YAML editor [wip] CONSOLE-4701: Add fontsize+theme control to YAML editor Nov 17, 2025
@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch 2 times, most recently from f57ad67 to 9e3915a Compare November 18, 2025 14:51
@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

Adds persistent YAML editor settings (theme and font size) with a new useEditYamlSettings hook, redesigns EditYamlSettingsModal and accessibility, updates Edit YAML integration and CodeEditor props, adjusts BasicCodeEditor typing and prop-spread precedence, and updates localization strings and minor UI text.

Changes

Cohort / File(s) Change Summary
Basic editor typing & context
frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx
Replaced import * as React with named FC and useContext imports; changed component signature to FC<BasicCodeEditorProps>; switched to useContext(ThemeContext); moved spreads so computed theme/fontFamily precede user editorProps/options, altering override precedence.
YAML editor settings constants
frontend/packages/console-shared/src/constants/common.ts
Added exported constants: OVERRIDE_YAML_EDITOR_THEME_USER_SETTING_KEY, OVERRIDE_YAML_EDITOR_THEME_LOCAL_STORAGE_KEY, CUSTOM_YAML_EDITOR_FONT_SIZE_USER_SETTING_KEY, CUSTOM_YAML_EDITOR_FONT_SIZE_LOCAL_STORAGE_KEY.
Settings modal & hook
frontend/public/components/modals/edit-yaml-settings-modal.tsx
Rewrote modal to use ConfigModalItem/ConfigModalSwitch layout, new icons, Theme and FontSize config items, accessibility IDs/ARIA, introduced useEditYamlSettings hook, and changed component signature to FC<AppendToProps>.
YAML editor integration
frontend/public/components/edit-yaml.tsx
Replaced useUserSettingsCompatibility usage with useEditYamlSettings; import/export of the hook; updated CodeEditor call to accept conditional editorProps (theme) and typed options as CodeEditorProps['options'].
Localization
frontend/public/locales/en/public.json
Removed legacy On/Off keys and updated/added keys for theme selection, font size controls, tooltip/scoping phrasing, “Changes apply immediately”, and Slack label keys.
Other UI text updates
frontend/public/components/modals/expand-pvc-modal.tsx, frontend/public/components/monitoring/receiver-forms/slack-receiver-form.tsx
Reworded PVC expansion explanatory text and shortened Slack receiver form labels.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Files needing extra attention:
    • frontend/public/components/modals/edit-yaml-settings-modal.tsx — large UI refactor, new hook, ARIA/ID changes and wiring.
    • frontend/public/components/edit-yaml.tsx — verify integration of useEditYamlSettings and CodeEditor editorProps/options typing and precedence.
    • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx — confirm prop spread/order change and impact on theme/fontFamily overrides.
    • frontend/packages/console-shared/src/constants/common.ts and frontend/public/locales/en/public.json — ensure new keys/constants are referenced consistently.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@krishagarwal278 krishagarwal278 left a comment

Choose a reason for hiding this comment

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

nit

@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch 2 times, most recently from 59fb5b4 to a2e37f3 Compare November 19, 2025 15:24
@logonoff
Copy link
Member Author

Docs Approver:
/assign @jseseCCS

PX Approver:
/assign @sferich888

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 19, 2025

@logonoff: GitHub didn't allow me to assign the following users: jseseCCS.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

Docs Approver:
/assign @jseseCCS

PX Approver:
/assign @sferich888

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.

@sferich888
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label Nov 19, 2025
@logonoff
Copy link
Member Author

/assign @yapei

@logonoff logonoff changed the title [wip] CONSOLE-4701: Add fontsize+theme control to YAML editor CONSOLE-4701: Add fontsize+theme control to YAML editor Nov 20, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 20, 2025
@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch from a2e37f3 to bee7f06 Compare November 20, 2025 13:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (1)

237-271: Guard against invalid numeric input for font size

onChange parses the input with Number(...) and writes it directly to fontSize. If the user types something non-numeric, this can become NaN and be propagated into the editor options.

Consider clamping and ignoring invalid values, e.g.:

-          onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}
+          onChange={(event) => {
+            const value = Number((event.target as HTMLInputElement).value);
+            if (Number.isNaN(value)) {
+              return;
+            }
+            setFontSize(Math.max(5, value));
+          }}

This keeps the stored value sane and respects the minimum.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 86c7b34 and bee7f06.

📒 Files selected for processing (5)
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (3 hunks)
  • frontend/packages/console-shared/src/constants/common.ts (1 hunks)
  • frontend/public/components/edit-yaml.tsx (6 hunks)
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx (3 hunks)
  • frontend/public/locales/en/public.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/console-shared/src/constants/common.ts
  • frontend/public/locales/en/public.json
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx
  • frontend/public/components/edit-yaml.tsx
🔇 Additional comments (5)
frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (1)

23-56: BasicCodeEditor theme and options merge look correct

Using ThemeContext for theme and moving ...props.editorProps / ...props.options after the defaults gives sensible overrides while preserving the console theme and mono font. No issues spotted here.

frontend/public/locales/en/public.json (1)

913-925: New editor-settings i18n strings are consistent and scoped

The added strings for colour scheme, font size, and the “applied immediately” notice align with the new settings modal usage and are consistent with existing public.json patterns.

Also applies to: 931-931

frontend/packages/console-shared/src/constants/common.ts (1)

49-52: YAML editor theme/font-size setting keys are well-structured

The new user-setting and localStorage keys for theme override and custom font size follow the existing naming and prefixing conventions and should be easy to reuse across components.

frontend/public/components/edit-yaml.tsx (1)

185-187: YAML editor settings integration is coherent

Using useEditYamlSettings to drive fontSize, theme, tooltips, and sticky scroll, plus wiring those via options, editorProps, and the updateOptions effect, keeps the editor behavior in sync with user settings and the new modal. The fullscreen appendTo handling for the modal also looks correct.

Also applies to: 766-769, 786-786, 805-812, 860-873

frontend/public/components/modals/edit-yaml-settings-modal.tsx (1)

316-360: Centralized useEditYamlSettings hook is a good abstraction

Exposing useEditYamlSettings to aggregate theme, font size, tooltips, and sticky scroll from useUserSettingsCompatibility simplifies consumers like edit-yaml.tsx and keeps the settings model in one place. The modal + hook arrangement should scale if additional YAML editor options are added later.

Also applies to: 362-389

Comment on lines 51 to 132
interface ConfigModalItemProps {
title: string;
/** Icon rendered inside the configuration modal. */
icon?: ReactNode;
/** Description of the configuration option. */
description: string;
checked?: boolean;
setChecked: (checked: boolean) => void;
Icon?: React.ComponentType;
/** Title of the configuration option. We assume that titles are unique. */
title: string;
/**
* Optional ID of the configuration option. Also used as a prefix for the ids of inner elements and the OUIA id.
* - `${ouiaId}-title` for the element which contains the title
* - `${ouiaId}-description` for the element which contains the description
*/
id?: string;
/**
* Slot to render inside the configuration modal. Remember to add `aria-labelledby` and `aria-describedby` props
* to the control inside the slot, pointing to the title and description ids respectively.
*/
slot?: ReactNode;
}

const ConfigModalItem: React.FCC<ConfigModalItemProps> = ({
const ConfigModalItem: React.FunctionComponent<ConfigModalItemProps> = ({
icon = <CogIcon />,
description,
title,
id = `ConfigModalItem-${title.replace(/\s+/g, '-').toLowerCase()}`,
slot,
}) => (
<Flex
alignItems={{ default: 'alignItemsCenter' }}
justifyContent={{ default: 'justifyContentSpaceBetween' }}
spaceItems={{ default: 'spaceItemsMd' }}
id={id}
>
<FlexItem flex={{ default: 'flex_1' }}>
<Flex spaceItems={{ default: 'spaceItemsSm' }}>
<Icon isInline>{icon}</Icon>
<strong id={`${id}-title`} className="pf-v6-u-font-weight-bold">
{title}
</strong>
</Flex>

<div id={`${id}-description`}>{description}</div>
</FlexItem>
<FlexItem alignSelf={{ default: 'alignSelfCenter' }}>{slot}</FlexItem>
</Flex>
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix unsupported ouia-id prop on ConfigModalItem

ConfigModalItemProps doesn’t define an ouia-id prop, and ConfigModalItem doesn’t forward unknown props, so the ouia-id usage in ThemeConfigItem and FontSizeConfigItem is both a TypeScript error and a no-op at runtime.

Either drop the prop or add a typed ouiaId prop and forward it to the root container. For example:

 interface ConfigModalItemProps {
   /** Icon rendered inside the configuration modal. */
   icon?: ReactNode;
   /** Description of the configuration option. */
   description: string;
   /** Title of the configuration option. We assume that titles are unique. */
   title: string;
-  /**
+  /**
    * Optional ID of the configuration option. Also used as a prefix for the ids of inner elements and the OUIA id.
    * - `${ouiaId}-title` for the element which contains the title
    * - `${ouiaId}-description` for the element which contains the description
    */
   id?: string;
+  /** Optional OUIA id forwarded to the root container. */
+  ouiaId?: string;
   /**
@@
-const ConfigModalItem: React.FunctionComponent<ConfigModalItemProps> = ({
-  icon = <CogIcon />,
-  description,
-  title,
-  id = `ConfigModalItem-${title.replace(/\s+/g, '-').toLowerCase()}`,
-  slot,
-}) => (
+const ConfigModalItem: React.FunctionComponent<ConfigModalItemProps> = ({
+  icon = <CogIcon />,
+  description,
+  title,
+  id = `ConfigModalItem-${title.replace(/\s+/g, '-').toLowerCase()}`,
+  ouiaId,
+  slot,
+}) => (
   <Flex
@@
-    id={id}
+    id={id}
+    ouiaId={ouiaId}
   >

And then update usages:

-    <ConfigModalItem
+    <ConfigModalItem
       key="colour-scheme"
       title={t('Colour scheme')}
       description={t('Select the colour scheme of the code editor')}
-      ouia-id="ConfigModalItem-colour-scheme"
+      ouiaId="ConfigModalItem-colour-scheme"
@@
-    <ConfigModalItem
+    <ConfigModalItem
       key="font-size"
       title={t('Font size')}
       description={t('Adjust the font size of the code editor')}
-      ouia-id="ConfigModalItem-font-size"
+      ouiaId="ConfigModalItem-font-size"

Also applies to: 215-233, 247-271

🤖 Prompt for AI Agents
In frontend/public/components/modals/edit-yaml-settings-modal.tsx around lines
87-132 (and similarly for the other occurrences at 215-233 and 247-271),
ConfigModalItem currently lacks an ouiaId prop and does not forward unknown
props, so passing `ouia-id` is a TypeScript error and a no-op; add an optional
typed prop `ouiaId?: string` to ConfigModalItemProps and forward it to the root
container (the Flex element) as `ouiaId={ouiaId}` (or the prop name your OUIA
helper expects), then update any callers (ThemeConfigItem, FontSizeConfigItem,
etc.) to pass `ouiaId` (camelCase) instead of `ouia-id`. Ensure the prop is
optional and does not change existing behavior when omitted.

@jseseCCS
Copy link

jseseCCS commented Nov 20, 2025

@logonoff I'd like to see one more time after changes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between bee7f06 and efafc08.

📒 Files selected for processing (5)
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (3 hunks)
  • frontend/packages/console-shared/src/constants/common.ts (1 hunks)
  • frontend/public/components/edit-yaml.tsx (6 hunks)
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx (3 hunks)
  • frontend/public/locales/en/public.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/public/components/edit-yaml.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/console-shared/src/constants/common.ts
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx
  • frontend/public/locales/en/public.json
🔇 Additional comments (6)
frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (2)

1-1: LGTM: Modern React import practices.

The changes to import FC and useContext directly from React (rather than using React.FC and React.useContext) follow current React best practices and improve code conciseness without any functional impact.

Also applies to: 23-23, 25-25


44-56: LGTM: Props spreading order enables theme/fontsize overrides.

The reordering of default properties before the spread operators (theme and fontFamily now precede ...props?.editorProps and ...props?.options) is an intentional change that allows consumers to override the default theme and font family. This directly supports the PR objective of adding fontsize and theme control to the YAML editor.

The beforeMount composition remains correct, ensuring that console themes are always defined while allowing consumers to extend with their own setup logic.

frontend/packages/console-shared/src/constants/common.ts (1)

49-52: YAML editor setting keys look consistent and correct

The new user setting and local storage keys follow the existing prefix and naming patterns for editor-related settings; no issues spotted.

frontend/public/locales/en/public.json (1)

913-925: New editor preference strings align with the settings UI

The added strings for color scheme, font size, and the immediate-apply notice are clear, consistent in tone with surrounding copy, and correctly keyed for reuse.

Also applies to: 931-931

frontend/public/components/modals/edit-yaml-settings-modal.tsx (2)

181-235: Overall YAML editor settings wiring and accessibility look solid

  • Theme selection via SimpleSelect and persisted useUserSettingsCompatibility state is straightforward, and options are localized correctly.
  • Tooltip and sticky scroll switches reuse the shared ConfigModalSwitch pattern with ARIA labels and descriptions tied to the item title/description.
  • The modal is correctly labeled/described via aria-labelledby/aria-describedby, and the CodeEditorControl trigger advertises aria-haspopup="dialog".
  • useEditYamlSettings centralizes retrieval of theme, font size, tooltips, and sticky scroll flags, which should simplify integration in the YAML editor.

Aside from the font-size and labels typing nits already noted, this structure is clean and maintainable.

Also applies to: 274-312, 316-360, 362-389


134-172: The review comment is based on incorrect assumptions and should be disregarded.

The review claims the code violates TypeScript's strictNullChecks, but the project's tsconfig.json has "strict": false, which disables null checking. Additionally, PatternFly's Switch component's label prop is typed as React.ReactNode, which accepts undefined. The code compiles without error and functions correctly at runtime.

While the interface design could be cleaner (declaring the fields as optional enabled?: string), there is no actual type error to fix.

Likely an incorrect or invalid review comment.

@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch from efafc08 to 04d03a5 Compare November 20, 2025 15:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (1)

237-272: Add input validation to onChange handler.

The onChange handler on line 265 does not validate input, allowing NaN or 0 to be set when users clear the field or enter invalid text. This was previously flagged and marked as addressed, but the validation is still missing.

Apply the recommended fix from the previous review:

-          onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}
+          onChange={(event) => {
+            const raw = (event.target as HTMLInputElement).value;
+            const next = Number(raw);
+            if (!Number.isNaN(next)) {
+              setFontSize(Math.max(5, next));
+            }
+          }}
🧹 Nitpick comments (1)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (1)

362-389: Consider memoizing the return value of useEditYamlSettings.

The hook returns a new object on every render, which could cause unnecessary re-renders in consuming components. While not critical (since useUserSettingsCompatibility likely prevents excessive updates), memoizing the return value would be more efficient:

+import { useMemo } from 'react';

 export const useEditYamlSettings = () => {
   const [theme] = useUserSettingsCompatibility<'default' | 'dark' | 'light'>(
     OVERRIDE_YAML_EDITOR_THEME_USER_SETTING_KEY,
     OVERRIDE_YAML_EDITOR_THEME_LOCAL_STORAGE_KEY,
     'default',
     true,
   );
   const [fontSize] = useUserSettingsCompatibility<number>(
     CUSTOM_YAML_EDITOR_FONT_SIZE_USER_SETTING_KEY,
     CUSTOM_YAML_EDITOR_FONT_SIZE_LOCAL_STORAGE_KEY,
     14,
     true,
   );
   const [showTooltips] = useUserSettingsCompatibility<boolean>(
     SHOW_YAML_EDITOR_TOOLTIPS_USER_SETTING_KEY,
     SHOW_YAML_EDITOR_TOOLTIPS_LOCAL_STORAGE_KEY,
     true,
     true,
   );
   const [stickyScrollEnabled] = useUserSettingsCompatibility<boolean>(
     SHOW_YAML_EDITOR_STICKY_SCROLL_USER_SETTING_KEY,
     SHOW_YAML_EDITOR_STICKY_SCROLL_LOCAL_STORAGE_KEY,
     true,
     true,
   );
-  return { theme, fontSize, showTooltips, stickyScrollEnabled };
+  return useMemo(
+    () => ({ theme, fontSize, showTooltips, stickyScrollEnabled }),
+    [theme, fontSize, showTooltips, stickyScrollEnabled],
+  );
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between efafc08 and 04d03a5.

📒 Files selected for processing (5)
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (3 hunks)
  • frontend/packages/console-shared/src/constants/common.ts (1 hunks)
  • frontend/public/components/edit-yaml.tsx (6 hunks)
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx (3 hunks)
  • frontend/public/locales/en/public.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/public/components/edit-yaml.tsx
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/console-shared/src/constants/common.ts
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx
  • frontend/public/locales/en/public.json
🔇 Additional comments (2)
frontend/public/locales/en/public.json (1)

913-931: LGTM! Locale strings are clear and consistent.

The new YAML editor settings strings are well-written and align with previous review feedback. The wording is concise and follows established patterns.

frontend/packages/console-shared/src/constants/common.ts (1)

49-52: LGTM! Constants follow established patterns.

The new YAML editor constants are well-named and consistent with existing user settings and local storage keys in the file.

@logonoff
Copy link
Member Author

after after:

image image

cc @jseseCCS

@openshift-ci openshift-ci bot added the component/monitoring Related to monitoring label Nov 20, 2025
Copy link

@jseseCCS jseseCCS left a comment

Choose a reason for hiding this comment

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

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Nov 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (1)

237-271: Harden FontSizeConfigItem against invalid/empty numeric input

The NumberInput onChange at Line 265 currently does:

onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}

If the user clears the field or types non-numeric text, Number(...) can yield 0 or NaN, which may get persisted via useUserSettingsCompatibility and then used as the editor font size, producing invalid styles or a near-invisible font size.

Clamp and validate before updating state, e.g.:

-          onChange={(event) => setFontSize(Number((event.target as HTMLInputElement).value))}
+          onChange={(event) => {
+            const raw = (event.target as HTMLInputElement).value;
+            const next = Number(raw);
+            if (!Number.isNaN(next)) {
+              setFontSize(Math.max(5, next));
+            }
+          }}

This keeps fontSize sane and aligned with the min={5} constraint while still allowing free typing.

🧹 Nitpick comments (2)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (2)

174-180: Theme configuration component is sound; consider centralizing theme type

ThemeConfigItem correctly wires useUserSettingsCompatibility to the theme user/local-storage keys and uses SimpleSelect with accessible aria-labelledby/aria-describedby pointing at ConfigModalItem content. This looks good.

For maintainability, you’re duplicating the 'default' | 'dark' | 'light' theme union here (implicitly) and again in useEditYamlSettings (Line 364). Consider introducing a shared type YamlEditorTheme = 'default' | 'dark' | 'light'; and using it both in useEditYamlSettings and in the settings hooks so they stay in sync over time.

Also applies to: 181-235


316-360: Use explicit close behavior instead of toggling modal state in onClose

In Line 332, onClose={() => setIsModalOpen(!isModalOpen)} toggles the modal state rather than unconditionally closing. This works today but is brittle: if onClose ever fires while isModalOpen is already false (or if multiple close events race), it can reopen the modal unexpectedly.

Safer to set the state explicitly:

-        onClose={() => setIsModalOpen(!isModalOpen)}
+        onClose={() => setIsModalOpen(false)}

Everything else in the modal wiring (IDs, ARIA attributes, composition of the config items, and the CodeEditorControl trigger) looks solid.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 2dae413 and 62e7c8e.

📒 Files selected for processing (2)
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx (3 hunks)
  • frontend/public/locales/en/public.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/public/locales/en/public.json
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/modals/edit-yaml-settings-modal.tsx
🔇 Additional comments (4)
frontend/public/components/modals/edit-yaml-settings-modal.tsx (4)

1-80: Icons and imports look consistent and low-risk

Imports and the four Font Awesome–based icons created via createIcon are scoped and used appropriately in the config items; licensing headers are present and the setup is straightforward with no apparent performance or correctness concerns.


274-312: Tooltip and sticky-scroll switches are wired correctly

TooltipConfigItem and StickyScrollConfigItem consistently use ConfigModalSwitch and useUserSettingsCompatibility with the correct user/local-storage keys, and the switch onChange handlers simply forward the boolean checked value to the corresponding setters. The icon choices and descriptions are clear and the a11y setup (via ConfigModalSwitch) looks fine.


362-389: useEditYamlSettings hook cleanly centralizes editor settings

useEditYamlSettings neatly aggregates theme, fontSize, showTooltips, and stickyScrollEnabled via useUserSettingsCompatibility, with appropriate generics and defaults. This should simplify consumers like the YAML editor by providing a single, typed source of truth for configuration. No issues spotted here.


87-132: Fix ConfigModalSwitchProps.labels typing mismatch

The interface requires enabled and disabled as string type (lines 140-142), but the default value at line 153 assigns undefined to both, causing a TypeScript type error. The Switch component's label prop accepts ReactNode, so relaxing the type to optional ReactNode is appropriate.

Update the interface and default as suggested:

interface ConfigModalSwitchProps extends Omit<ConfigModalItemProps, 'slot'> {
  /** Flag indicating whether the option is enabled or disabled. */
  isChecked?: SwitchProps['isChecked'];
  /** onChange handler for the switch. */
  onChange?: SwitchProps['onChange'];
-  /** Labels for the enabled and disabled states of the switch. */
+  /** Labels for the enabled and disabled states of the switch (optional). */
  labels?: {
-    enabled: string;
-    disabled: string;
+    enabled?: ReactNode;
+    disabled?: ReactNode;
  };
}

const ConfigModalSwitch: React.FunctionComponent<ConfigModalSwitchProps> = ({
  icon = <CogIcon />,
  description,
  title,
  id = `ConfigModalSwitch-${title.replace(/\s+/g, '-').toLowerCase()}`,
  isChecked = false,
  onChange,
-  labels = { enabled: undefined, disabled: undefined },
+  labels = {},
}) => (

This eliminates the type violation while maintaining safety for all call sites (TooltipConfigItem, StickyScrollConfigItem) which omit the labels prop entirely.

Likely an incorrect or invalid review comment.

@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch from 62e7c8e to 18d3dc7 Compare November 20, 2025 16:06
@logonoff logonoff force-pushed the CONSOLE-4701-codeeditor branch from 18d3dc7 to 0043dd4 Compare November 20, 2025 16:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 62e7c8e and 0043dd4.

📒 Files selected for processing (7)
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (3 hunks)
  • frontend/packages/console-shared/src/constants/common.ts (1 hunks)
  • frontend/public/components/edit-yaml.tsx (6 hunks)
  • frontend/public/components/modals/edit-yaml-settings-modal.tsx (3 hunks)
  • frontend/public/components/modals/expand-pvc-modal.tsx (1 hunks)
  • frontend/public/components/monitoring/receiver-forms/slack-receiver-form.tsx (2 hunks)
  • frontend/public/locales/en/public.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/public/components/monitoring/receiver-forms/slack-receiver-form.tsx
  • frontend/public/components/edit-yaml.tsx
  • frontend/packages/console-shared/src/constants/common.ts
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/modals/edit-yaml-settings-modal.tsx
  • frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx
  • frontend/public/components/modals/expand-pvc-modal.tsx
  • frontend/public/locales/en/public.json
🔇 Additional comments (15)
frontend/packages/console-shared/src/components/editor/BasicCodeEditor.tsx (2)

1-1: LGTM: Modern React conventions applied.

The refactoring from namespace import (import * as React) to named imports (FC, useContext) is a good practice that aligns with modern React conventions and improves tree-shaking.

Also applies to: 23-23, 25-25


44-56: No concerns to address—this is a feature enablement, not a breaking change.

Based on verification of all BasicCodeEditor consumers in the codebase:

  • resource-sidebar-samples.tsx only passes options with lineHeight and UI settings, not theme overrides
  • CodeEditor wrapper merges options with spread pattern for consumer overrides, and editorProps are spread via {...props}
  • edit-yaml.tsx attempts to override theme via editorProps, which now works correctly with the new precedence
  • No existing consumers are relying on enforced defaults

The precedence change—moving theme and fontFamily before the spread—enables the new capability to customize these values rather than blocking it. This aligns with the git history showing CONSOLE-4701: Add fontsize+theme to YAML editor as a new feature. All consumers are compatible with this change.

frontend/public/components/modals/expand-pvc-modal.tsx (1)

62-63: LGTM! UI text improvements align with style guidelines.

The wording changes improve clarity and follow documentation best practices: using positive phrasing ("must be at least" instead of "can't be less than") and setting clearer expectations ("might take some time to complete" instead of "can be a time-consuming process").

frontend/public/components/modals/edit-yaml-settings-modal.tsx (8)

35-79: LGTM! Custom icons properly implemented.

The custom icon components follow the PatternFly createIcon pattern correctly and include proper Font Awesome Free license attribution.


87-132: LGTM! ConfigModalItem component is well-structured.

The component provides a clean, reusable layout for configuration items with proper ID generation and accessibility support through aria-labelledby and aria-describedby patterns.


134-172: LGTM! ConfigModalSwitch provides good abstraction.

The component properly wraps ConfigModalItem with Switch-specific functionality and maintains accessibility through correct ARIA attribute forwarding.


183-237: LGTM! ThemeConfigItem correctly implements theme selection.

The component properly uses useUserSettingsCompatibility for persistence, useMemo for performance, and maintains accessibility with appropriate ARIA attributes.


276-294: LGTM! Clean refactor to ConfigModalSwitch.

The component correctly migrates to the new ConfigModalSwitch abstraction while maintaining the same functionality.


296-314: LGTM! Consistent refactor with improved naming.

The component correctly uses ConfigModalSwitch and the variable naming (stickyScrollEnabled) addresses previous review feedback.


316-362: LGTM! Modal component properly structured.

The modal correctly implements accessibility patterns, state management, and composes all configuration items cleanly.


364-391: LGTM! Hook provides clean API for settings access.

The useEditYamlSettings hook correctly aggregates all YAML editor settings into a single, consumable interface, avoiding prop drilling and providing a clear API for consumers.

frontend/public/locales/en/public.json (4)

913-921: LGTM! Theme strings are clear and approved.

The theme-related strings correctly reflect the in-app setting behavior (as clarified in past reviews) and maintain consistency with the rest of the UI.


922-931: LGTM! Editor strings follow documentation best practices.

All updates align with previous documentation review feedback: comma series for clarity in the tooltip description, standard UI verb "Pin" instead of "Stick", and present tense "Changes apply immediately" per style guidelines.


934-934: LGTM! PVC message improvements match UI changes.

The updated text uses positive phrasing and sets clearer expectations, consistent with the corresponding modal component changes and documentation style guidelines.


1072-1074: LGTM! Slack label improvements follow style guidelines.

The updated labels are more concise and direct, removing periods from noun phrase labels per documentation standards.

@Leo6Leo
Copy link
Contributor

Leo6Leo commented Nov 20, 2025

Review Request
/assign @Leo6Leo

@Leo6Leo
Copy link
Contributor

Leo6Leo commented Nov 20, 2025

/lgtm
/retest-required

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jseseCCS, Leo6Leo, logonoff

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

@yapei
Copy link
Contributor

yapei commented Nov 21, 2025

Only one minor issue found during testing, the Theme dropdown list got cut at right on Safari
Screenshot 2025-11-21 at 3 39 51 PM

@yapei
Copy link
Contributor

yapei commented Nov 21, 2025

/verified by @yapei

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 21, 2025
@openshift-ci-robot
Copy link
Contributor

@yapei: This PR has been marked as verified by @yapei.

In response to this:

/verified by @yapei

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
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 057ffde and 2 for PR HEAD 0043dd4 in total

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 569b5f4 and 1 for PR HEAD 0043dd4 in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 21, 2025

@logonoff: all tests passed!

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.

@openshift-merge-bot openshift-merge-bot bot merged commit ee40939 into openshift:main Nov 22, 2025
8 checks passed
@logonoff logonoff deleted the CONSOLE-4701-codeeditor branch November 22, 2025 12:30
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 component/monitoring Related to monitoring component/shared Related to console-shared docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants