mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 06:28:33 +00:00
* Refactor dropdown components to use MenuDropdown for improved functionality and keyboard accessibility - Replaced Dropdown with MenuDropdown in various components including BodyModeSelector, AuthMode, and RequestBodyMode. - Updated styles and structure for better usability and accessibility. - Removed unused Dropdown component and its associated styles. - Enhanced action buttons in ResponsePane and Collection components with ActionIcon for better UI consistency. * fix: Update HttpMethodSelector styles and tests for improved accessibility - Changed the class name for the "Add Custom" button to include 'text-link' for better styling. - Updated tests to use role-based queries for dropdown items, enhancing accessibility checks. - Ensured the correct application of classes in tests to reflect the updated structure. * refactor: Improve component accessibility and consistency * fix: update hover behavior for collection actions menu in runner.ts * refactor: streamline hover interactions for collection actions across tests * refactor: enhance component structure and accessibility across response actions * fix: correct fill property syntax in StyledWrapper for consistent styling * refactor: simplify isDisabled logic in response components for clarity * fix: correct tabIndex logic in ResponseCopy component for improved accessibility * fix: update tabIndex logic in ResponseBookmark component for improved accessibility * fix: enable action buttons in ResponsePaneActions for improved usability * refactor: remove unnecessary tabIndex attributes in response components for improved accessibility * refactor: remove keyDown event handlers from response components for cleaner interaction * refactor: remove SidebarHeader component and related styles for improved structure
77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
import React, { useMemo } from 'react';
|
|
import { IconCaretDown, IconForms, IconBraces, IconCode, IconFileText, IconDatabase, IconFile, IconX } from '@tabler/icons';
|
|
import MenuDropdown from 'ui/MenuDropdown';
|
|
import { humanizeRequestBodyMode } from 'utils/collections';
|
|
import StyledWrapper from './StyledWrapper';
|
|
|
|
const DEFAULT_MODES = [
|
|
{
|
|
name: 'Form',
|
|
options: [
|
|
{ id: 'multipartForm', label: 'Multipart Form', leftSection: IconForms },
|
|
{ id: 'formUrlEncoded', label: 'Form URL Encoded', leftSection: IconForms }
|
|
]
|
|
},
|
|
{
|
|
name: 'Raw',
|
|
options: [
|
|
{ id: 'json', label: 'JSON', leftSection: IconBraces },
|
|
{ id: 'xml', label: 'XML', leftSection: IconCode },
|
|
{ id: 'text', label: 'TEXT', leftSection: IconFileText },
|
|
{ id: 'sparql', label: 'SPARQL', leftSection: IconDatabase }
|
|
]
|
|
},
|
|
{
|
|
name: 'Other',
|
|
options: [
|
|
{ id: 'file', label: 'File / Binary', leftSection: IconFile },
|
|
{ id: 'none', label: 'No Body', leftSection: IconX }
|
|
]
|
|
}
|
|
];
|
|
|
|
const BodyModeSelector = ({
|
|
currentMode,
|
|
onModeChange,
|
|
modes = DEFAULT_MODES,
|
|
disabled = false,
|
|
className = '',
|
|
wrapperClassName = '',
|
|
placement = 'bottom-end'
|
|
}) => {
|
|
// Add onClick handlers to mode options
|
|
const menuItems = useMemo(() => {
|
|
return modes.map((group) => ({
|
|
...group,
|
|
options: group.options.map((option) => ({
|
|
...option,
|
|
onClick: () => onModeChange(option.id)
|
|
}))
|
|
}));
|
|
}, [modes, onModeChange]);
|
|
|
|
return (
|
|
<StyledWrapper className={wrapperClassName}>
|
|
<div className={`inline-flex items-center body-mode-selector ${disabled ? 'cursor-default' : 'cursor-pointer'}`}>
|
|
<MenuDropdown
|
|
items={menuItems}
|
|
placement={placement}
|
|
disabled={disabled}
|
|
className={className}
|
|
selectedItemId={currentMode}
|
|
showGroupDividers={false}
|
|
groupStyle="select"
|
|
>
|
|
<div className="flex items-center justify-center pl-3 py-1 select-none selected-body-mode">
|
|
{humanizeRequestBodyMode(currentMode)}
|
|
{' '}
|
|
<IconCaretDown className="caret ml-2" size={14} strokeWidth={2} />
|
|
</div>
|
|
</MenuDropdown>
|
|
</div>
|
|
</StyledWrapper>
|
|
);
|
|
};
|
|
|
|
export default BodyModeSelector;
|