-
Notifications
You must be signed in to change notification settings - Fork 245
chore(deps): update LG packages COMPASS-8611 #6569
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
Changes from all commits
ba6e9f6
06f18fd
5fe77d8
f7cc742
d4986fa
4238d83
8619613
e22179c
771fd71
9bb660d
acc8c52
671f5d4
a534b4d
963497c
444a1b7
4b20e81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useState } from 'react'; | ||
| import React, { useMemo, useState } from 'react'; | ||
| import { connect } from 'react-redux'; | ||
| import { | ||
| Menu, | ||
|
|
@@ -39,6 +39,51 @@ export const OptionMenu = ({ | |
| }) => { | ||
| const [menuOpen, setMenuOpen] = useState(false); | ||
|
|
||
| const menuItems = useMemo(() => { | ||
| return [ | ||
| { | ||
| label: 'Add stage after', | ||
| onClick: () => { | ||
| onAddStageClick(index); | ||
| setMenuOpen(false); | ||
| }, | ||
| icon: 'PlusWithCircle', | ||
| }, | ||
| { | ||
| label: 'Add stage before', | ||
| onClick: () => { | ||
| onAddStageClick(index - 1); | ||
| setMenuOpen(false); | ||
| }, | ||
| icon: 'PlusWithCircle', | ||
| }, | ||
| { | ||
| label: 'Delete stage', | ||
| onClick: () => { | ||
| onDeleteStageClick(index); | ||
| setMenuOpen(false); | ||
| }, | ||
| icon: 'Trash', | ||
| }, | ||
| { | ||
| label: 'Expand documents', | ||
| onClick: () => { | ||
| onExpand(index); | ||
| setMenuOpen(false); | ||
| }, | ||
| icon: 'ChevronDown', | ||
| }, | ||
| { | ||
| label: 'Collapse documents', | ||
| onClick: () => { | ||
| onCollapse(index); | ||
| setMenuOpen(false); | ||
| }, | ||
| icon: 'ChevronUp', | ||
| }, | ||
| ]; | ||
| }, [index, onAddStageClick, onDeleteStageClick, onExpand, onCollapse]); | ||
|
|
||
|
Comment on lines
+42
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen us doing this pattern elsewhere, but why do you see this being advantageous over simply rendering the children? I see possibilities of making the existing code more DRY without falling back on this pattern of building component trees from arrays of "data". In any case, would it make sense to separate this out into its own PR or does it have to be included in this work?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this to simply avoid adding |
||
| return ( | ||
| <Menu | ||
| open={menuOpen} | ||
|
|
@@ -60,69 +105,18 @@ export const OptionMenu = ({ | |
| ); | ||
| }} | ||
| > | ||
| <MenuItem | ||
| onClick={() => { | ||
| onAddStageClick(index); | ||
| setMenuOpen(false); | ||
| }} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon | ||
| color={palette.gray.dark2} | ||
| glyph="PlusWithCircle" | ||
| size="small" | ||
| /> | ||
| Add stage after | ||
| </div> | ||
| </MenuItem> | ||
| <MenuItem | ||
| onClick={() => { | ||
| onAddStageClick(index - 1); | ||
| setMenuOpen(false); | ||
| }} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon | ||
| color={palette.gray.dark2} | ||
| glyph="PlusWithCircle" | ||
| size="small" | ||
| /> | ||
| Add stage before | ||
| </div> | ||
| </MenuItem> | ||
| <MenuItem | ||
| onClick={() => { | ||
| onDeleteStageClick(index); | ||
| setMenuOpen(false); | ||
| }} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon color={palette.gray.dark2} glyph="Trash" size="small" /> | ||
| Delete stage | ||
| </div> | ||
| </MenuItem> | ||
| <MenuItem | ||
| onClick={() => { | ||
| onExpand(index); | ||
| setMenuOpen(false); | ||
| }} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon color={palette.gray.dark2} glyph="ChevronDown" size="small" /> | ||
| Expand documents | ||
| </div> | ||
| </MenuItem> | ||
| <MenuItem | ||
| onClick={() => { | ||
| onCollapse(index); | ||
| setMenuOpen(false); | ||
| }} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon color={palette.gray.dark2} glyph="ChevronUp" size="small" /> | ||
| Collapse documents | ||
| </div> | ||
| </MenuItem> | ||
| {menuItems.map((item) => ( | ||
| <MenuItem | ||
| key={item.label} | ||
| data-text={item.label} | ||
| onClick={item.onClick} | ||
| > | ||
| <div className={menuItemStyles}> | ||
| <Icon color={palette.gray.dark2} glyph={item.icon} size="small" /> | ||
| {item.label} | ||
| </div> | ||
| </MenuItem> | ||
| ))} | ||
| </Menu> | ||
| ); | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.