Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as React from 'react';
// $FlowFixMe TypeScript file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this change

import EmptyView from '../common/empty-view';
import ProgressBar from '../common/progress-bar';
import ItemList from './ItemList';
Expand Down Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert these changes

onFocusChange,
extensionsWhitelist,
Expand All @@ -68,24 +65,22 @@ const Content = ({
<ProgressBar percent={currentCollection.percentLoaded} />
)}
{isEmpty(view, currentCollection) ? (
<EmptyView view={view} isLoading={currentCollection.percentLoaded !== 100} />
Copy link
Contributor

Choose a reason for hiding this comment

The 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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert these changes

/>
)}
Expand Down
94 changes: 94 additions & 0 deletions src/elements/content-picker/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @flow
* @file File picker header and list component
* @author Box
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete this comment, you don't need the header comment at the top of the file

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you sort this list alphabetically?

}: 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} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you sort the props alphabetically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<EmptyView view={view} isLoading={currentCollection.percentLoaded !== 100} />
<EmptyView isLoading={currentCollection.percentLoaded !== 100} view={view} />

) : (
<ItemList
view={view}
rootId={rootId}
isSmall={isSmall}
rootElement={rootElement}
focusedRow={focusedRow}
currentCollection={currentCollection}
tableRef={tableRef}
canSetShareAccess={canSetShareAccess}
hasHitSelectionLimit={hasHitSelectionLimit}
isSingleSelect={isSingleSelect}
selectableType={selectableType}
onItemSelect={onItemSelect}
onItemClick={onItemClick}
onFocusChange={onFocusChange}
onShareAccessChange={onShareAccessChange}
extensionsWhitelist={extensionsWhitelist}
Copy link
Contributor

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?

/>
)}
</div>
);

export default Content;