diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts b/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts index 2e1f3decbd9..32900b5367b 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts @@ -659,8 +659,10 @@ export type CodeEditorToolbarProps = { // Omit the ref as we have our own ref type, which is completely different export type BasicCodeEditorProps = Partial>; -export type CodeEditorProps = Omit & +export type CodeEditorProps = Omit & CodeEditorToolbarProps & { + /** Additional props to override the default popover properties */ + shortcutsPopoverProps?: Partial; /** Code displayed in code editor. */ value?: string; /** Minimum editor height in valid CSS height values. */ diff --git a/frontend/packages/console-shared/locales/en/console-shared.json b/frontend/packages/console-shared/locales/en/console-shared.json index 0a720d3fe7c..37237ca57e4 100644 --- a/frontend/packages/console-shared/locales/en/console-shared.json +++ b/frontend/packages/console-shared/locales/en/console-shared.json @@ -124,6 +124,8 @@ "View document outline": "View document outline", "View property descriptions": "View property descriptions", "Save": "Save", + "Hide sidebar": "Hide sidebar", + "Show sidebar": "Show sidebar", "Restricted access": "Restricted access", "You don't have access to this section due to cluster policy": "You don't have access to this section due to cluster policy", "Error details": "Error details", diff --git a/frontend/packages/console-shared/src/components/editor/CodeEditor.tsx b/frontend/packages/console-shared/src/components/editor/CodeEditor.tsx index 29015c0ee4e..0ab8ec7e549 100644 --- a/frontend/packages/console-shared/src/components/editor/CodeEditor.tsx +++ b/frontend/packages/console-shared/src/components/editor/CodeEditor.tsx @@ -15,7 +15,7 @@ const CodeEditor = React.forwardRef((props, ref) const [monacoRef, setMonacoRef] = React.useState(null); const [usesValue] = React.useState(value !== undefined); - const shortcutPopover = useShortcutPopover(); + const shortcutPopover = useShortcutPopover(props.shortcutsPopoverProps); const editorDidMount: EditorDidMount = React.useCallback( (editor, monaco) => { @@ -55,7 +55,7 @@ const CodeEditor = React.forwardRef((props, ref) // do not render toolbar if the component is null const ToolbarLinks = React.useMemo(() => { return showShortcuts || toolbarLinks?.length ? ( - + ) : undefined; }, [toolbarLinks, showShortcuts]); @@ -80,11 +80,11 @@ const CodeEditor = React.forwardRef((props, ref)
diff --git a/frontend/packages/console-shared/src/components/editor/CodeEditorToolbar.tsx b/frontend/packages/console-shared/src/components/editor/CodeEditorToolbar.tsx index 3d91ef5a26f..b2e7549bdb3 100644 --- a/frontend/packages/console-shared/src/components/editor/CodeEditorToolbar.tsx +++ b/frontend/packages/console-shared/src/components/editor/CodeEditorToolbar.tsx @@ -1,49 +1,40 @@ -import * as React from 'react'; -import { Button, Flex, FlexItem } from '@patternfly/react-core'; +import { Button, Tooltip } from '@patternfly/react-core'; import { MagicIcon } from '@patternfly/react-icons'; import { useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; import { action } from 'typesafe-actions'; import { CodeEditorToolbarProps } from '@console/dynamic-plugin-sdk'; import { ActionType } from '@console/internal/reducers/ols'; -import { useOLSConfig } from '../../hooks/ols-hook'; +import { useOLSConfig } from '@console/shared/src/hooks/ols-hook'; +import { useIsFullscreen } from '@console/shared/src/hooks/useFullscreen'; -export const AskOpenShiftLightspeedButton: React.FC = () => { +export const AskOpenShiftLightspeedButton: React.FCC = () => { const { t } = useTranslation('console-shared'); const openOLS = () => action(ActionType.OpenOLS); const showLightspeedButton = useOLSConfig(); const dispatch = useDispatch(); + const isFullscreen = useIsFullscreen(); return showLightspeedButton ? ( - + +