diff --git a/webpack/assets/javascripts/react_app/components/Editor/components/EditorSettings.js b/webpack/assets/javascripts/react_app/components/Editor/components/EditorSettings.js index 6d741b37e2..b332a4eeb3 100644 --- a/webpack/assets/javascripts/react_app/components/Editor/components/EditorSettings.js +++ b/webpack/assets/javascripts/react_app/components/Editor/components/EditorSettings.js @@ -1,16 +1,76 @@ -import React from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { Dropdown, MenuItem, Button } from 'patternfly-react'; import { CogIcon } from '@patternfly/react-icons'; import { + Button, + Checkbox, Icon, + MenuToggle, Popover, PopoverPosition, + Select, + SelectList, + SelectOption, Tooltip, TooltipPosition, } from '@patternfly/react-core'; import { translate as __ } from '../../../common/I18n'; +const SettingsSelect = ({ id, disabled, options, selected, onSelect }) => { + const [isOpen, setIsOpen] = useState(false); + + return ( +
+ +
+ ); +}; + +SettingsSelect.propTypes = { + id: PropTypes.string.isRequired, + disabled: PropTypes.bool, + options: PropTypes.arrayOf(PropTypes.string).isRequired, + selected: PropTypes.string.isRequired, + onSelect: PropTypes.func.isRequired, +}; + +SettingsSelect.defaultProps = { + disabled: false, +}; + const EditorSettings = ({ selectedView, changeSetting, @@ -34,94 +94,74 @@ const EditorSettings = ({
{__('Syntax')}
- - {mode} - - {modes.map((aceMode, i) => ( - changeSetting({ mode: aceMode })} - > - {aceMode} - - ))} - - + changeSetting({ mode: selection })} + />
{__('Keybind')}
- - {keyBinding} - - {keyBindings.map((keyBind, i) => ( - changeSetting({ keyBinding: keyBind })} - > - {keyBind} - - ))} - - + disabled={selectedView === 'preview'} + options={keyBindings} + selected={keyBinding} + onSelect={selection => changeSetting({ keyBinding: selection })} + />
{__('Theme')}
- - {theme} - - {themes.map((themeKey, i) => ( - changeSetting({ theme: themeKey })} - > - {themeKey} - - ))} - - + changeSetting({ theme: selection })} + />
{__('Autocompletion')}
-
- - changeSetting({ autocompletion: !autocompletion }) - } - /> -
+ + changeSetting({ autocompletion: !autocompletion }) + } + />
{__('Live Autocompletion')}
-
- - changeSetting({ liveAutocompletion: !liveAutocompletion }) - } - /> -
+ + changeSetting({ liveAutocompletion: !liveAutocompletion }) + } + />
} triggerRef={() => document.getElementById('cog-btn')} /> - - - -`; - -exports[`EditorSettings renders EditorSettings w/preview 1`] = ` - - -
-
- Syntax -
- - - Ruby - - - - Text - - - Json - - - Ruby - - - Html_ruby - - - Sh - - - Xml - - - Yaml - - - -
-
-
- Keybind -
- - - vim - - - - Default - - - Emacs - - - Vim - - - -
-
-
- Theme -
- - - Github - - - - Github - - - Monokai - - - -
-
-
- Autocompletion -
-
- -
-
-
-
- Live Autocompletion -
-
- -
-
- - } - enableFlip={false} - hasAutoWidth={true} - headerContent="Settings" - id="cog-popover" - position="bottom" - triggerRef={[Function]} - /> - - - -
-`; diff --git a/webpack/assets/javascripts/react_app/components/Editor/editor.scss b/webpack/assets/javascripts/react_app/components/Editor/editor.scss index 5c53958928..4a050acd9e 100644 --- a/webpack/assets/javascripts/react_app/components/Editor/editor.scss +++ b/webpack/assets/javascripts/react_app/components/Editor/editor.scss @@ -186,6 +186,8 @@ width: 40px !important; font-size: 16px; margin-bottom: 2px; + vertical-align: middle; + padding: 4px; } #import-btn, @@ -258,24 +260,15 @@ font-weight: 600; } - .dropdown { + .cog-popover-select { margin-left: auto; - .dropdown-menu { + .pf-v5-c-menu { min-width: 80px; } - #mode-dropdown, - #keybindings-dropdown, - #themes-dropdown { + .cog-popover-select-toggle { width: 80px; - text-align: left; - - .caret { - position: absolute; - right: 2px; - top: 7px; - } } } }