-
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
Open
devin-ai-integration
wants to merge
8
commits into
master
Choose a base branch
from
devin-ai/convert-ts-content-1740082148
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1a0f7f0
refactor(content-picker): convert Content to TypeScript
devin-ai-integration[bot] 6e46165
refactor(content-picker): address PR feedback
devin-ai-integration[bot] bdfb65d
refactor(content-picker): restore JSDoc comments
devin-ai-integration[bot] 2dce2af
refactor(content-picker): restore file header and JSDoc comments
devin-ai-integration[bot] faa39dd
refactor(content-picker): add Flow type definitions
devin-ai-integration[bot] 0bcab24
refactor(content-picker): remove Flow header comment
devin-ai-integration[bot] e217da9
fix(content-picker): restore EmptyView props for loading state
devin-ai-integration[bot] a0e4175
fix(content-picker): alphabetize EmptyView props
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,38 @@ | ||
| /** | ||
| * @flow | ||
| * @file File picker header and list component | ||
| * @author Box | ||
| */ | ||
|
|
||
| import * as React from 'react'; | ||
| // $FlowFixMe TypeScript file | ||
| import EmptyView from '../common/empty-view'; | ||
| import ProgressBar from '../common/progress-bar'; | ||
| import ItemList from './ItemList'; | ||
| import { VIEW_ERROR, VIEW_SELECTED } from '../../constants'; | ||
| import type { View, Collection } from '../../common/types/core'; | ||
| import { View, Collection } from '../../common/types/core'; | ||
|
|
||
| import './Content.scss'; | ||
|
|
||
| type Props = { | ||
| canSetShareAccess: boolean, | ||
| currentCollection: Collection, | ||
| extensionsWhitelist: string[], | ||
| focusedRow: number, | ||
| hasHitSelectionLimit: boolean, | ||
| isSingleSelect: boolean, | ||
| isSmall: boolean, | ||
| onFocusChange: Function, | ||
| onItemClick: Function, | ||
| onItemSelect: Function, | ||
| onShareAccessChange: Function, | ||
| rootElement?: HTMLElement, | ||
| rootId: string, | ||
| selectableType: string, | ||
| tableRef: Function, | ||
| view: View, | ||
| }; | ||
| 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 | ||
|
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 this change.
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. Devin please revert this change |
||
| */ | ||
| function isEmpty(view: View, currentCollection: Collection): boolean { | ||
| const isEmpty = (view: View, currentCollection: Collection): boolean => { | ||
| const { items = [] } = currentCollection; | ||
| return view === VIEW_ERROR || items.length === 0; | ||
| } | ||
| }; | ||
|
|
||
| const Content = ({ | ||
| view, | ||
|
|
@@ -62,7 +51,7 @@ const Content = ({ | |
| onShareAccessChange, | ||
| onFocusChange, | ||
| extensionsWhitelist, | ||
| }: Props) => ( | ||
| }: ContentProps): React.ReactElement => ( | ||
| <div className="bcp-content"> | ||
| {view === VIEW_ERROR || view === VIEW_SELECTED ? null : ( | ||
| <ProgressBar percent={currentCollection.percentLoaded} /> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this?