Skip to content

Commit

Permalink
removed uneeded fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
framitdavid committed Jun 30, 2024
1 parent 9abcbc9 commit 70926dd
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ export const StudioDropdownMenu = ({
}: StudioDropdownMenuProps) => {
const [open, setOpen] = useState<boolean>(false);
return (
<>
<DropdownMenu portal {...rest} onClose={() => setOpen(false)} open={open}>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={open}
aria-haspopup='menu'
size={rest.size}
onClick={() => setOpen(!open)}
{...anchorButtonProps}
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<StudioDropdownMenuContext.Provider value={{ setOpen }}>
{children}
</StudioDropdownMenuContext.Provider>
</DropdownMenu.Content>
</DropdownMenu>
</>
<DropdownMenu portal {...rest} onClose={() => setOpen(false)} open={open}>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={open}
aria-haspopup='menu'
size={rest.size}
onClick={() => setOpen(!open)}
{...anchorButtonProps}
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<StudioDropdownMenuContext.Provider value={{ setOpen }}>
{children}
</StudioDropdownMenuContext.Provider>
</DropdownMenu.Content>
</DropdownMenu>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,32 @@ export const PolicyEditorDropdownMenu = ({
const { t } = useTranslation();

return (
<>
<DropdownMenu onClose={handleCloseMenu} placement='bottom-end' size='small' open={isOpen}>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={isOpen}
aria-haspopup='menu'
className={isError && classes.errorButton}
color={isError ? 'danger' : 'second'}
icon={<MenuElipsisVerticalIcon fontSize='1.8rem' />}
onClick={handleClickMoreIcon}
size='small'
title={t('policy_editor.more')}
variant='tertiary'
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group>
<DropdownMenu.Item onClick={handleClone}>
<TabsIcon className={classes.icon} />
{t('policy_editor.expandable_card_dropdown_copy')}
</DropdownMenu.Item>
<DropdownMenu.Item className={classes.deleteButton} onClick={handleDelete}>
<TrashIcon className={classes.icon} />
{t('general.delete')}
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
</>
<DropdownMenu onClose={handleCloseMenu} placement='bottom-end' size='small' open={isOpen}>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={isOpen}
aria-haspopup='menu'
className={isError && classes.errorButton}
color={isError ? 'danger' : 'second'}
icon={<MenuElipsisVerticalIcon fontSize='1.8rem' />}
onClick={handleClickMoreIcon}
size='small'
title={t('policy_editor.more')}
variant='tertiary'
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group>
<DropdownMenu.Item onClick={handleClone}>
<TabsIcon className={classes.icon} />
{t('policy_editor.expandable_card_dropdown_copy')}
</DropdownMenu.Item>
<DropdownMenu.Item className={classes.deleteButton} onClick={handleDelete}>
<TrashIcon className={classes.icon} />
{t('general.delete')}
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,32 @@ export const AddPropertyMenu = ({ pointer }: AddPropertyMenuProps) => {
const closeDropdown = () => setIsAddDropdownOpen(false);

return (
<>
<DropdownMenu open={isAddDropdownOpen} onClose={closeDropdown} size='small' portal>
<DropdownMenu.Trigger asChild>
<ActionButton
aria-expanded={isAddDropdownOpen}
aria-haspopup='menu'
icon={<PlusIcon />}
onClick={() => setIsAddDropdownOpen(true)}
titleKey='schema_editor.add_node_of_type'
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group>
<DropdownMenu.Item onClick={addField}>
<PropertyIcon />
{t('schema_editor.add_field')}
</DropdownMenu.Item>
<DropdownMenu.Item onClick={addCombination}>
<CombinationIcon />
{t('schema_editor.add_combination')}
</DropdownMenu.Item>
<DropdownMenu.Item onClick={addReference}>
<ReferenceIcon />
{t('schema_editor.add_reference')}
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
</>
<DropdownMenu open={isAddDropdownOpen} onClose={closeDropdown} size='small' portal>
<DropdownMenu.Trigger asChild>
<ActionButton
aria-expanded={isAddDropdownOpen}
aria-haspopup='menu'
icon={<PlusIcon />}
onClick={() => setIsAddDropdownOpen(true)}
titleKey='schema_editor.add_node_of_type'
/>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group>
<DropdownMenu.Item onClick={addField}>
<PropertyIcon />
{t('schema_editor.add_field')}
</DropdownMenu.Item>
<DropdownMenu.Item onClick={addCombination}>
<CombinationIcon />
{t('schema_editor.add_combination')}
</DropdownMenu.Item>
<DropdownMenu.Item onClick={addReference}>
<ReferenceIcon />
{t('schema_editor.add_reference')}
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,43 @@ export const NewExpressionButton = ({ options, onAddExpression }: NewExpressionB
const t = useText();

return (
<>
<DropdownMenu
onClose={() => setShowDropdown(false)}
open={showDropdown}
placement='top'
portal
size='small'
>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={showDropdown}
aria-haspopup='menu'
color='first'
fullWidth
icon={<PlusIcon />}
onClick={() => setShowDropdown(!showDropdown)}
size='small'
title={t('right_menu.expressions_add')}
variant='secondary'
>
{t('right_menu.expressions_add')}
</StudioButton>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group heading={t('right_menu.expressions_property')}>
{options.map((o) => (
<DropdownMenu.Item
key={o}
onClick={() => {
setShowDropdown(false);
onAddExpression(o);
}}
>
{expressionPropertyTexts(t)[o]}
</DropdownMenu.Item>
))}
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
</>
<DropdownMenu
onClose={() => setShowDropdown(false)}
open={showDropdown}
placement='top'
portal
size='small'
>
<DropdownMenu.Trigger asChild>
<StudioButton
aria-expanded={showDropdown}
aria-haspopup='menu'
color='first'
fullWidth
icon={<PlusIcon />}
onClick={() => setShowDropdown(!showDropdown)}
size='small'
title={t('right_menu.expressions_add')}
variant='secondary'
>
{t('right_menu.expressions_add')}
</StudioButton>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group heading={t('right_menu.expressions_property')}>
{options.map((o) => (
<DropdownMenu.Item
key={o}
onClick={() => {
setShowDropdown(false);
onAddExpression(o);
}}
>
{expressionPropertyTexts(t)[o]}
</DropdownMenu.Item>
))}
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -67,56 +67,54 @@ export const InputPopover = ({
};

return (
<>
<StudioPopover open={isEditDialogOpen} onClose={handleClose}>
<StudioPopover.Trigger asChild>
<DropdownMenu.Item
onClick={() => setIsEditDialogOpen(true)}
id='edit-page-button'
disabled={disabled}
ref={newNameRef}
aria-expanded={isEditDialogOpen}
<StudioPopover open={isEditDialogOpen} onClose={handleClose}>
<StudioPopover.Trigger asChild>
<DropdownMenu.Item
onClick={() => setIsEditDialogOpen(true)}
id='edit-page-button'
disabled={disabled}
ref={newNameRef}
aria-expanded={isEditDialogOpen}
>
<PencilIcon />
{t('ux_editor.page_menu_edit')}
</DropdownMenu.Item>
</StudioPopover.Trigger>
<StudioPopover.Content>
<Textfield
label={t('ux_editor.input_popover_label')}
size='small'
onChange={handleOnChange}
onKeyDown={handleKeyPress}
value={newName}
error={errorMessage !== null}
/>
<ErrorMessage className={classes.errorMessage} size='small'>
{errorMessage}
</ErrorMessage>
<div className={classes.buttonContainer}>
<StudioButton
color='first'
variant='primary'
onClick={() => saveNewName(newName)}
disabled={!shouldSavingBeEnabled}
size='small'
>
<PencilIcon />
{t('ux_editor.page_menu_edit')}
</DropdownMenu.Item>
</StudioPopover.Trigger>
<StudioPopover.Content>
<Textfield
label={t('ux_editor.input_popover_label')}
{t('ux_editor.input_popover_save_button')}
</StudioButton>
<StudioButton
color='second'
variant='tertiary'
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
handleClose();
}}
size='small'
onChange={handleOnChange}
onKeyDown={handleKeyPress}
value={newName}
error={errorMessage !== null}
/>
<ErrorMessage className={classes.errorMessage} size='small'>
{errorMessage}
</ErrorMessage>
<div className={classes.buttonContainer}>
<StudioButton
color='first'
variant='primary'
onClick={() => saveNewName(newName)}
disabled={!shouldSavingBeEnabled}
size='small'
>
{t('ux_editor.input_popover_save_button')}
</StudioButton>
<StudioButton
color='second'
variant='tertiary'
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
handleClose();
}}
size='small'
>
{t('general.cancel')}
</StudioButton>
</div>
</StudioPopover.Content>
</StudioPopover>
</>
>
{t('general.cancel')}
</StudioButton>
</div>
</StudioPopover.Content>
</StudioPopover>
);
};

0 comments on commit 70926dd

Please sign in to comment.