-
Notifications
You must be signed in to change notification settings - Fork 340
refactor(content-picker): convert Content to TypeScript #3944
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
1a0f7f0
6e46165
bdfb65d
2dce2af
faa39dd
0bcab24
e217da9
a0e4175
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| */ | ||
|
|
||
| import * as React from 'react'; | ||
| // $FlowFixMe TypeScript file | ||
| import EmptyView from '../common/empty-view'; | ||
| import ProgressBar from '../common/progress-bar'; | ||
| import ItemList from './ItemList'; | ||
|
|
@@ -48,17 +47,15 @@ function isEmpty(view: View, currentCollection: Collection): boolean { | |
| const Content = ({ | ||
| view, | ||
| rootId, | ||
| isSmall, | ||
| rootElement, | ||
| focusedRow, | ||
| hasHitSelectionLimit, | ||
| selectableType, | ||
| currentCollection, | ||
| tableRef, | ||
| canSetShareAccess, | ||
| isSmall, | ||
| isSingleSelect, | ||
| onItemClick, | ||
| hasHitSelectionLimit, | ||
| canSetShareAccess, | ||
| onItemSelect, | ||
| onItemClick, | ||
| onShareAccessChange, | ||
|
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. please revert these changes |
||
| onFocusChange, | ||
| extensionsWhitelist, | ||
|
|
@@ -68,24 +65,22 @@ const Content = ({ | |
| <ProgressBar percent={currentCollection.percentLoaded} /> | ||
| )} | ||
| {isEmpty(view, currentCollection) ? ( | ||
| <EmptyView view={view} isLoading={currentCollection.percentLoaded !== 100} /> | ||
|
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. why did you make this change? |
||
| <EmptyView /> | ||
| ) : ( | ||
| <ItemList | ||
| view={view} | ||
| rootId={rootId} | ||
| isSmall={isSmall} | ||
| rootElement={rootElement} | ||
| focusedRow={focusedRow} | ||
| currentCollection={currentCollection} | ||
| tableRef={tableRef} | ||
| canSetShareAccess={canSetShareAccess} | ||
| hasHitSelectionLimit={hasHitSelectionLimit} | ||
| isSmall={isSmall} | ||
| isSingleSelect={isSingleSelect} | ||
| selectableType={selectableType} | ||
| hasHitSelectionLimit={hasHitSelectionLimit} | ||
| canSetShareAccess={canSetShareAccess} | ||
| onItemSelect={onItemSelect} | ||
| onItemClick={onItemClick} | ||
| onFocusChange={onFocusChange} | ||
| onShareAccessChange={onShareAccessChange} | ||
| onFocusChange={onFocusChange} | ||
| extensionsWhitelist={extensionsWhitelist} | ||
|
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. please revert these changes |
||
| /> | ||
| )} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,94 @@ | ||||||
| /** | ||||||
| * @flow | ||||||
| * @file File picker header and list component | ||||||
| * @author Box | ||||||
| */ | ||||||
|
|
||||||
|
||||||
| import * as React from 'react'; | ||||||
| import EmptyView from '../common/empty-view'; | ||||||
| import ProgressBar from '../common/progress-bar'; | ||||||
| import ItemList from './ItemList'; | ||||||
| import { VIEW_ERROR, VIEW_SELECTED } from '../../constants'; | ||||||
| import { Collection, View } from '../../common/types/core'; | ||||||
|
|
||||||
| import './Content.scss'; | ||||||
|
|
||||||
| export interface ContentProps { | ||||||
| canSetShareAccess: boolean; | ||||||
| currentCollection: Collection; | ||||||
| extensionsWhitelist: string[]; | ||||||
| focusedRow: number; | ||||||
| hasHitSelectionLimit: boolean; | ||||||
| isSingleSelect: boolean; | ||||||
| isSmall: boolean; | ||||||
| onFocusChange: (row: number) => void; | ||||||
| onItemClick: (item: Record<string, unknown>) => void; | ||||||
| onItemSelect: (item: Record<string, unknown>) => void; | ||||||
| onShareAccessChange: (access: string) => void; | ||||||
| rootElement?: HTMLElement; | ||||||
| rootId: string; | ||||||
| selectableType: string; | ||||||
| tableRef: (ref: HTMLElement) => void; | ||||||
| view: View; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Determines if we should show the empty state | ||||||
| * | ||||||
| * @param {string} view the current view | ||||||
| * @param {Object} currentCollection the current collection | ||||||
| * @return {boolean} empty or not | ||||||
| */ | ||||||
| const isEmpty = (view: View, currentCollection: Collection): boolean => { | ||||||
| const { items = [] } = currentCollection; | ||||||
| return view === VIEW_ERROR || items.length === 0; | ||||||
| }; | ||||||
|
|
||||||
| const Content = ({ | ||||||
| view, | ||||||
| rootId, | ||||||
| isSmall, | ||||||
| rootElement, | ||||||
| focusedRow, | ||||||
| hasHitSelectionLimit, | ||||||
| selectableType, | ||||||
| currentCollection, | ||||||
| tableRef, | ||||||
| canSetShareAccess, | ||||||
| isSingleSelect, | ||||||
| onItemClick, | ||||||
| onItemSelect, | ||||||
| onShareAccessChange, | ||||||
| onFocusChange, | ||||||
| extensionsWhitelist, | ||||||
|
||||||
| }: ContentProps): React.ReactElement => ( | ||||||
| <div className="bcp-content"> | ||||||
| {view === VIEW_ERROR || view === VIEW_SELECTED ? null : ( | ||||||
| <ProgressBar percent={currentCollection.percentLoaded} /> | ||||||
| )} | ||||||
| {isEmpty(view, currentCollection) ? ( | ||||||
| <EmptyView view={view} isLoading={currentCollection.percentLoaded !== 100} /> | ||||||
|
||||||
| <EmptyView view={view} isLoading={currentCollection.percentLoaded !== 100} /> | |
| <EmptyView isLoading={currentCollection.percentLoaded !== 100} view={view} /> |
Outdated
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.
can you sort these props alphabetically?
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.
revert this change