-
Notifications
You must be signed in to change notification settings - Fork 23
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
SWC-6910 - Entity Finder 'Selected' tab #1442
Conversation
@@ -66,7 +66,7 @@ export const EntityFileBrowser: React.FunctionComponent< | |||
}, | |||
} | |||
return ( | |||
<div className="EntityFinderReflexContainer"> | |||
<div className="EntityFileBrowser EntityFinderReflexContainer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added class name to apply cascaded styles
selectedCopy: count => { | ||
return `${count} Item${count > 1 ? 's' : ''} Selected` | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed now-unused selectedCopy
prop.
@@ -10,7 +10,6 @@ import { | |||
} from '../../../src/components/EntityFinder/details/EntityDetailsList' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this file so it is now type-checked
@@ -355,61 +361,24 @@ describe('EntityFinder tests', () => { | |||
}) | |||
|
|||
describe('Search', () => { | |||
it('Updates the search button text when only one type is selectable', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search input field is no longer hidden behind a button press, so many of these search tests are no longer relevant.
// In the map used to track selections, we use -1 to denote 'selected without version' | ||
// This is necessary because undefined is returned by map.get when the item is not in the map | ||
export const NO_VERSION_NUMBER = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the selected type from a map of (entityID, versionNumber) to a map of (entityID, Reference), so we can remove this hacky convention
/** The text to show before the list of selected entities */ | ||
selectedCopy?: string | ((count: number) => string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prop is no longer used after these changes
{searchActive ? ( | ||
<Button | ||
variant="outlined" | ||
color="primary" | ||
onClick={() => { | ||
setSearchActive(false) | ||
setSearchInput('') | ||
setSearchTerms(undefined) | ||
}} | ||
startIcon={<ArrowBackOutlinedIcon />} | ||
sx={{ flexShrink: 0, mr: 1 }} | ||
> | ||
Back to Browse | ||
</Button> | ||
) : ( | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
className="EntityFinder__Search__SearchButton" | ||
onClick={() => { | ||
setSearchActive(true) | ||
searchInputRef.current!.focus() | ||
}} | ||
startIcon={<SearchIcon />} | ||
sx={{ flexShrink: 0 }} | ||
> | ||
{searchButtonText} | ||
</Button> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed these buttons to show/hide search. The new design has the search input always visible.
endAdornment: searchTerms ? ( | ||
<InputAdornment position="end"> | ||
<IconButton | ||
size={'small'} | ||
onClick={() => { | ||
setSearchInput('') | ||
setSearchTerms(undefined) | ||
setSearchActive(false) | ||
}} | ||
aria-label="Clear Search" | ||
disabled={!searchInput && !searchActive} | ||
> | ||
<ClearIcon /> | ||
</IconButton> | ||
</InputAdornment> | ||
) : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still show a clear button to return to the file browser from the search state
<div | ||
role={'tabpanel'} | ||
style={{ | ||
display: currentTab === EntityFinderTab.SELECTED ? 'block' : 'none', | ||
}} | ||
> | ||
<EntityDetailsList | ||
{...entityDetailsListProps} | ||
configuration={{ | ||
type: EntityDetailsListDataConfigurationType.REFERENCE_LIST, | ||
referenceList: Array.from(selectedEntitiesSnapshot.values()), | ||
}} | ||
/> | ||
)} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show the selected items in an EntityDetailsList
references: Reference[] | ||
} | ||
|
||
export const ReferenceDetails: React.FunctionComponent<SearchDetailsProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selected items will be provided as Reference
s. This component translates the reference list to entity headers, which can be passed into DetailsView
to render the table.
@@ -1,40 +1,36 @@ | |||
import '@testing-library/jest-dom' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File is now type-checked
<option value={NO_VERSION_NUMBER_OPTION_VALUE}> | ||
{latestVersionText} | ||
</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place we have to maintain the "NO_VERSION_NUMBER" = -1 convention, because an <option value
cannot be null
useEffect(() => { | ||
if ( | ||
FinderScope.CURRENT_PROJECT === scope && | ||
projectId && | ||
!isLoadingProjectHeader && | ||
!projectHeader | ||
) { | ||
// The header wasn't returned, so the user doesn't have access to the current project | ||
// Let's change the scope to something else | ||
displayToast( | ||
`You don't have access to the current project (${projectId}).`, | ||
'warning', | ||
) | ||
setScope(FinderScope.CREATED_BY_ME) | ||
} | ||
}, [isLoadingProjectHeader, projectHeader, projectId, scope]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in an effect to prevent firing every render
<div className="Browse">Browse:</div> | ||
<div onClick={e => e.stopPropagation()}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed "Browse" copy
<Tooltip title={tooltipContent} placement="right"> | ||
<div className="EntityName" ref={ref}> | ||
{nodeText} | ||
</Tooltip> | ||
</div> | ||
</div> | ||
</Tooltip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap tooltip around the div so that it is positioned to the right of the visible text, not to the right of the overflowing & not visible text.
<> | ||
{isLoading ? ( | ||
<SynapseSpinner size={10} /> | ||
) : ( | ||
<button | ||
aria-label={isOpen ? 'Collapse' : 'Expand'} | ||
onClick={event => { | ||
event.stopPropagation() | ||
toggleExpand() | ||
}} | ||
> | ||
<ExpandIcon className="ExpandButton" /> | ||
</button> | ||
)} | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update icon
packages/synapse-react-client/src/components/EntityFinder/useEntitySelection.ts
Outdated
Show resolved
Hide resolved
- Update EntityFinder to show selected items in a tab instead of a lower pane - Updated EntityFinder selection to use a Map of entity ID -> Reference instead of entity ID -> version number. With this change, we can remove hacky behavior to store a fake 'null' version number in all places except one case where it is used as an <option> value - Update styles to more closely match design - Update EntityFinder tests to be type-checked
.MuiDialog-root { | ||
.EntityFinder { | ||
&__MainPanel.MainPanelDualPane, | ||
&__MainPanel.MainPanelSearch { | ||
// Hack to make the dialog responsive to the width of the entity finder | ||
// We may be able to remove this if we remove/replace the EntityFinder's `AutoSizer` component with something other | ||
// than the 'react-base-table' implementation | ||
width: 85vw; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this style to only apply it in a dialog. Otherwise, we can make the width of the entity finder 100%
--entity-finder-height: #{$-finder-height}; | ||
--entity-tree-header-height: 65px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix a calculation issue in the experimental EntityFileBrowser (where --entity-tree-header-height
should be 0px) by creating CSS variables with these values.
Without this change, the EntityFileBrowser appears to have empty space in the tree that overflowing content should be using
&__Search__Input { | ||
transition: flex-grow 250ms ease-in-out, width 250ms ease-in-out; | ||
&[data-active='true'] { | ||
flex-grow: 1; | ||
width: 100%; | ||
} | ||
&[data-active='false'] { | ||
flex-grow: 0.00001; | ||
overflow: hidden; | ||
width: 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interaction that used these styles was removed
.TreeView.BrowseTree { | ||
padding-left: 20px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not apply this padding to the EntityFileBrowser
.Node.BrowseNode { | ||
grid-template-columns: [toggle] 20px [name] auto; | ||
grid-template-columns: [toggle] 20px [name] minmax(0, max-content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes entity name overflow
grid-template-columns: [toggle] 15px [icon] 27px [name] minmax( | ||
0, | ||
max-content | ||
) [badge] auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes entity name overflow
selectColumnType: selectMultiple ? 'checkbox' : 'none', | ||
toggleSelection: toggleSelection, | ||
enableSelectAll: selectMultiple, | ||
setCurrentContainer: setCurrentContainer, | ||
} | ||
|
||
return ( | ||
<SynapseErrorBoundary> | ||
<div className="EntityFinder"> | ||
<Box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this flex container to include the tabs & the search input. This section is only styled using MUI, SCSS does not touch these
sx={{ | ||
flexWrap: { xs: 'wrap', md: 'nowrap' }, | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just kinda tweaked this responsive layout with the search bar until it felt good
2024-12-06.11-57-42.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but there may be some confusion on the scope of this search box (users may think this is searching the selected entities table, for example).
The real mobile responsive issue is the browse UX, which I think is out of scope for this ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point
onKeyDown={(event: any) => { | ||
if (event.key === 'Enter') { | ||
const trimmedInput = event.target.value.trim() | ||
setSearchActive(!!trimmedInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nickgros : On search, I think we should change to the Browse tab. When I'm on the Selected tab and do a search, the search results are not shown (I need to know to switch tabs to see the results)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, and that's a good idea--in general this is weird so I will probably follow-up with design about this.
from code review
See the EntityFinderModal story for a demo