-
Notifications
You must be signed in to change notification settings - Fork 687
CONSOLE-4656, CONSOLE-4499, CONSOLE-4654, CONSOLE-4657: Implement some CodeEditor RFEs #15254
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
Merged
openshift-merge-bot
merged 7 commits into
openshift:main
from
logonoff:CONSOLE-4499-codeeditor-electric-boogaloo
Jul 16, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c487a2
CONSOLE-4657: Refactor `edit-yaml` to TypeScript
logonoff 26adf84
CONSOLE-4654: Add "Copy to clipboard" button for YAML
logonoff 7f6806e
CONSOLE-4499: Add option to toggle sticky headers
logonoff 47cc8c1
CONSOLE-4656: Add fullscreen EditYaml
logonoff 664a8be
CONSOLE-4499: Change toolbar switches to buttons
logonoff 32f481b
CONSOLE-4657: Explicitly type `EditYAML` props
logonoff 0eb4740
style(CodeEditor): address some comments
logonoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 18 additions & 27 deletions
45
frontend/packages/console-shared/src/components/editor/CodeEditorToolbar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 28 additions & 25 deletions
53
frontend/packages/console-shared/src/components/editor/ShortcutsPopover.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,36 @@ | ||
| import { useMemo } from 'react'; | ||
| import { PopoverProps } from '@patternfly/react-core'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { ShortcutTable, Shortcut } from '../shortcuts'; | ||
| import { isMac } from '../shortcuts/Shortcut'; | ||
|
|
||
| export const useShortcutPopover = (onHideShortcuts?: () => {}): PopoverProps => { | ||
| export const useShortcutPopover = (shortcutsPopoverProps?: Partial<PopoverProps>): PopoverProps => { | ||
| const { t } = useTranslation('console-shared'); | ||
|
|
||
| return { | ||
| 'aria-label': t('Shortcuts'), | ||
| bodyContent: ( | ||
| <ShortcutTable> | ||
| <Shortcut keyName="F1">{t('View all editor shortcuts')}</Shortcut> | ||
| <Shortcut ctrl keyName="space"> | ||
| {t('Activate auto complete')} | ||
| </Shortcut> | ||
| <Shortcut ctrl shift={isMac} keyName="m"> | ||
| {t('Toggle Tab action between insert Tab character and move focus out of editor')} | ||
| </Shortcut> | ||
| <Shortcut ctrlCmd shift keyName="o"> | ||
| {t('View document outline')} | ||
| </Shortcut> | ||
| <Shortcut hover>{t('View property descriptions')}</Shortcut> | ||
| <Shortcut ctrlCmd keyName="s"> | ||
| {t('Save')} | ||
| </Shortcut> | ||
| </ShortcutTable> | ||
| ), | ||
| maxWidth: '25rem', | ||
| distance: 18, | ||
| onHide: onHideShortcuts, | ||
| }; | ||
| return useMemo((): PopoverProps => { | ||
| return { | ||
| 'aria-label': t('Shortcuts'), | ||
| bodyContent: ( | ||
| <ShortcutTable> | ||
| <Shortcut keyName="F1">{t('View all editor shortcuts')}</Shortcut> | ||
| <Shortcut ctrl keyName="space"> | ||
| {t('Activate auto complete')} | ||
| </Shortcut> | ||
| <Shortcut ctrl shift={isMac} keyName="m"> | ||
| {t('Toggle Tab action between insert Tab character and move focus out of editor')} | ||
| </Shortcut> | ||
| <Shortcut ctrlCmd shift keyName="o"> | ||
| {t('View document outline')} | ||
| </Shortcut> | ||
| <Shortcut hover>{t('View property descriptions')}</Shortcut> | ||
| <Shortcut ctrlCmd keyName="s"> | ||
| {t('Save')} | ||
| </Shortcut> | ||
| </ShortcutTable> | ||
| ), | ||
| maxWidth: '25rem', | ||
| distance: 18, | ||
| ...shortcutsPopoverProps, | ||
| }; | ||
| }, [t, shortcutsPopoverProps]); | ||
| }; |
48 changes: 48 additions & 0 deletions
48
frontend/packages/console-shared/src/components/editor/ToggleSidebarButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { CodeEditorControl, CodeEditorControlProps } from '@patternfly/react-code-editor'; | ||
| import { createIcon } from '@patternfly/react-icons/dist/esm/createIcon'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| export const SidebarOffIcon = createIcon({ | ||
| name: 'SidebarOffIcon', | ||
| width: 512, | ||
| height: 512, | ||
| svgPath: | ||
| 'M463.98 31.958H48.02C21.5 31.958 0 53.458 0 79.98v352.042c0 26.52 21.5 48.02 48.02 48.02h415.96c26.52 0 48.02-21.5 48.02-48.02V79.979c0-26.52-21.5-48.02-48.02-48.02zm-239.938 384H64V96.042h159.958v320ZM448 315.398v100.56H288.042V96.042H448zm-29.867-78.473h-98.3a8.426 8.426 0 0 0-8.45 8.45v21.25a8.426 8.426 0 0 0 8.45 8.45h98.3a8.426 8.426 0 0 0 8.45-8.45v-21.25a8.426 8.426 0 0 0-8.45-8.45zm0-84.83h-98.3a8.426 8.426 0 0 0-8.45 8.449v21.25a8.426 8.426 0 0 0 8.45 8.45h98.3a8.426 8.426 0 0 0 8.45-8.45v-21.25a8.426 8.426 0 0 0-8.45-8.45zm0 169.662h-98.3a8.426 8.426 0 0 0-8.45 8.45v21.25a8.426 8.426 0 0 0 8.45 8.449h98.3a8.426 8.426 0 0 0 8.45-8.45v-21.25a8.426 8.426 0 0 0-8.45-8.45z', | ||
| }); | ||
|
|
||
| export const SidebarOnIcon = createIcon({ | ||
| name: 'SidebarOnIcon', | ||
| width: 512, | ||
| height: 512, | ||
| svgPath: | ||
| 'M463.98 31.958H48.02C21.5 31.958 0 53.458 0 79.98v352.042c0 26.52 21.5 48.02 48.02 48.02h415.96c26.52 0 48.02-21.5 48.02-48.02V79.979c0-26.52-21.5-48.02-48.02-48.02zm-239.938 384H64V96.042h159.958v320ZM448 315.398v100.56H288.042V96.042H448zM248.638 66.929v369.443h214.84V66.928Zm177.945 284.528a8.426 8.426 0 0 1-8.45 8.45h-98.3a8.426 8.426 0 0 1-8.45-8.45v-21.25a8.426 8.426 0 0 1 8.45-8.45h98.3a8.426 8.426 0 0 1 8.45 8.45zm0-84.831a8.426 8.426 0 0 1-8.45 8.45h-98.3a8.426 8.426 0 0 1-8.45-8.45v-21.25a8.426 8.426 0 0 1 8.45-8.45h98.3a8.426 8.426 0 0 1 8.45 8.45zm0-84.832a8.426 8.426 0 0 1-8.45 8.45h-98.3a8.426 8.426 0 0 1-8.45-8.45v-21.25a8.426 8.426 0 0 1 8.45-8.449h98.3a8.426 8.426 0 0 1 8.45 8.45z', | ||
| }); | ||
|
|
||
| interface ToggleSidebarButtonProps extends Partial<CodeEditorControlProps> { | ||
| isSidebarOpen: boolean; | ||
| toggleSidebar: () => void; | ||
| /** Adds a div with `flex-grow: 1` so that the button is aligned to the end of the toolbar */ | ||
| alignToEnd?: boolean; | ||
| } | ||
|
|
||
| export const ToggleSidebarButton: React.FCC<ToggleSidebarButtonProps> = ({ | ||
| isSidebarOpen, | ||
| toggleSidebar, | ||
| alignToEnd = false, | ||
| ...props | ||
| }) => { | ||
| const { t } = useTranslation('console-shared'); | ||
|
|
||
| return ( | ||
| <> | ||
| {alignToEnd && <div style={{ flexGrow: 1 }} />} | ||
| <CodeEditorControl | ||
| aria-label={isSidebarOpen ? t('Hide sidebar') : t('Show sidebar')} | ||
| onClick={toggleSidebar} | ||
| icon={isSidebarOpen ? <SidebarOnIcon /> : <SidebarOffIcon />} | ||
| tooltipProps={{ content: isSidebarOpen ? t('Hide sidebar') : t('Show sidebar') }} | ||
| {...props} | ||
| /> | ||
| </> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vojtechszocs This is the API change. previously,
shortcutsPopoverPropsdid nothing, because our props take priority.now, when
shortcutsPopoverPropsis passed to ourCodeEditor, it will be spread into the ourshortcutsPopoverPropsthat we ultimately pass to the PatternFlyCodeEditor'sshortcutsPopoverProps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So after these changes plugins utilizing
CodeEditorare affected only in a positive way, as we have made theshortcutsPopoverPropscustomizable now. Only case where this affects plugins is if they used theshortcutsPopoverPropswithout realizing its has no effect, but now they will function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly!