Skip to content

Commit

Permalink
FS routes cleanup and fix component children key for breadcrumbs (key…
Browse files Browse the repository at this point in the history
…base#11331)

* fix popup routes for FilePreview; also fix children key for breadcrumbs

* review feedback from jzila

* revert breadcrumb route and routes cleanup
songgao authored Apr 14, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 48e59e2 commit f0769b0
Showing 6 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions shared/constants/types/fs.js
Original file line number Diff line number Diff line change
@@ -122,6 +122,7 @@ export type PathBreadcrumbItem = {
isTlfNameItem: boolean,
isLastItem: boolean,
name: string,
path: Path,
onOpenBreadcrumb: (evt?: SyntheticEvent<>) => void,
}

1 change: 1 addition & 0 deletions shared/fs/header/container.js
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ const mergeProps = (
isTlfNameItem: i === 2,
isLastItem: i === elems.length - 1,
name: e,
path: path,
onOpenBreadcrumb: (evt?: SyntheticEvent<>) => _onOpenBreadcrumb(path, evt),
}
})
2 changes: 1 addition & 1 deletion shared/fs/header/header.js
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ const FolderHeader = ({
</Box>
)}
{breadcrumbItems.map(i => (
<Box key={i.name} style={folderBreadcrumbStyle}>
<Box key={Types.pathToString(i.path)} style={folderBreadcrumbStyle}>
{i.isTlfNameItem &&
isTeamPath && <Avatar size={12} teamname={i.name} isTeam={true} style={styleTeamAvatar} />}
{i.isLastItem ? (
1 change: 1 addition & 0 deletions shared/fs/popups/breadcrumb-popup-container.js
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ const mergeProps = (stateProps, dispatchProps) => {
acc = Types.pathConcat(acc, elem)
const currentPath = acc
return {
path: currentPath,
name: elem,
styles: Constants.getItemStyles(currentElems, 'folder', _username),
onOpenBreadcrumb: () => _onOpenBreadcrumb(currentPath),
3 changes: 2 additions & 1 deletion shared/fs/popups/breadcrumb-popup.js
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import PathItemIcon from '../common/path-item-icon'

type PopupMenuProps = {
items: Array<{
path: Types.Path,
name: string,
styles: Types.ItemStyles,
onOpenBreadcrumb: (evt?: SyntheticEvent<>) => void,
@@ -19,7 +20,7 @@ type PopupMenuProps = {
const BreadcrumbPopupMenu = ({items, onHidden}: PopupMenuProps) => {
const popupItems = items.map(item => ({
onClick: item.onOpenBreadcrumb,
title: item.name,
title: Types.pathToString(item.path),
view: (
<Box style={stylesRow}>
<PathItemIcon spec={item.styles.iconSpec} style={pathItemIconStyle} small={true} />
15 changes: 7 additions & 8 deletions shared/fs/routes.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ import RowPopupMenu from './popups/row-action-popup-container'
import TransferPopup from './popups/transfer-container.js'

const _commonChildren = {
finderAction: {
component: RelativePopupHoc(FinderPopupMenu),
tags: makeLeafTags({layerOnTop: true}),
},
pathItemAction: {
component: RelativePopupHoc(RowPopupMenu),
tags: makeLeafTags({layerOnTop: true}),
@@ -20,9 +24,11 @@ const _commonChildren = {
tags: makeLeafTags({layerOnTop: true}),
},
}

const _folderRoute = {
children: {
folder: () => folderRoute,
..._commonChildren,
folder: () => makeRouteDefNode(_folderRoute),
preview: {
component: FilePreview,
children: _commonChildren,
@@ -36,17 +42,10 @@ const _folderRoute = {
component: RelativePopupHoc(SortBarPopupMenu),
tags: makeLeafTags({layerOnTop: true}),
},
finderAction: {
component: RelativePopupHoc(FinderPopupMenu),
tags: makeLeafTags({layerOnTop: true}),
},
..._commonChildren,
},
component: Files,
}

const folderRoute = makeRouteDefNode(_folderRoute)

const routeTree = makeRouteDefNode({
..._folderRoute,
initialState: {expandedSet: I.Set()},

0 comments on commit f0769b0

Please sign in to comment.