-
Notifications
You must be signed in to change notification settings - Fork 305
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
New: version history in details tab #220
Conversation
Verified that @DanDeMicco has signed the CLA. Thanks for the pull request! |
src/flowTypes.js
Outdated
@@ -338,3 +339,19 @@ export type MultiputPart = { | |||
export type MultiputData = { | |||
part?: MultiputPart | |||
}; | |||
|
|||
export type Version = { |
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.
There is a BoxItemVersion
Can you check if its duped.
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.
It is similar, but it appears the BoxItemVersion has an incomplete type definition and also includes less fields, according to the sample api docs
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 would refactor and make them the same, you would just need to add ? to properties that are optional and not needed for the object to be partial and just null check them. Should ideally not have two definitions of versions.
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.
Combined the types. As far as I could tell from the api docs only 3 properties were mandatory
src/constants.js
Outdated
@@ -25,6 +25,7 @@ export const VIEW_UPLOAD_SUCCESS: 'upload-success' = 'upload-success'; | |||
export const TYPE_FOLDER: 'folder' = 'folder'; | |||
export const TYPE_FILE: 'file' = 'file'; | |||
export const TYPE_WEBLINK: 'web_link' = 'web_link'; | |||
export const TYPE_VERSIONS: 'versions' = 'versions'; |
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.
There shouldn't be a type versions, since thats item type, and thats only the above 3.
If you are looking for a cache prefix, then see CACHE_PREFIX_* below
src/flowTypes.js
Outdated
@@ -58,7 +59,7 @@ export type ClassComponent<P, S> = Class<React$Component<P, S>>; | |||
export type StringMap = { [string]: string }; | |||
export type StringAnyMap = { [string]: any }; | |||
export type StringBooleanMap = { [string]: boolean }; | |||
export type ItemAPI = FolderAPI | FileAPI | WebLinkAPI; | |||
export type ItemAPI = FolderAPI | FileAPI | WebLinkAPI | VersionsAPI; |
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.
VersionsAPI should be separate from ItemAPI
src/api/APIFactory.js
Outdated
@@ -145,6 +162,9 @@ class APIFactory { | |||
case TYPE_WEBLINK: | |||
api = this.getWebLinkAPI(); | |||
break; | |||
case TYPE_VERSIONS: |
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.
Should not be here, as thats for item type only
src/api/Item.js
Outdated
* making file based XHRs where auth token | ||
* can be per file as used by Preview. | ||
* | ||
* @return {string} typed id for file |
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.
This should be in File.js as before
src/api/Versions.js
Outdated
// We only need the total_count for now | ||
return this.xhr | ||
.get({ | ||
id: this.getTypedFileId(id), |
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.
Should be referenced from FileAPI.
Can maybe make it a static function and update other places calling it.
@@ -43,11 +43,13 @@ type Props = { | |||
sharedLinkPassword?: string, | |||
requestInterceptor?: Function, | |||
responseInterceptor?: Function, | |||
onInteraction: Function | |||
onInteraction: Function, | |||
onVersionHistoryClick?: Function |
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.
hasVersions: boolean needs to be added like other has* above
@@ -324,9 +352,10 @@ class ContentSidebar extends PureComponent<Props, State> { | |||
<Internationalize language={language} messages={messages}> | |||
<div id={this.id} className={`be bcs ${className}`}> | |||
<div className='be-app-element'> | |||
{file ? ( | |||
{file && versions ? ( |
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.
Check should ideally not needed here, sidebar should render before versions is got
<Sidebar | ||
file={file} | ||
versions={versions} |
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.
pass in hasVersions too
@@ -56,6 +61,12 @@ const DetailsSidebar = ({ | |||
|
|||
return ( | |||
<SidebarContent hasTitle={hasTitle} title={<FormattedMessage {...messages.sidebarDetailsTitle} />}> | |||
{versions && |
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.
Should be inside its own file, say SidebarVersions
and here it will be
{hasVersions && <SidebarVersions versions={versions} onVersionHistoryClick={onVersionHistoryClick}>}
src/api/APIFactory.js
Outdated
/** | ||
* API for versions | ||
*/ | ||
getVersionsAPI(): VersionsAPI { |
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.
We may have to extend/improve these get*API calls to optionally take a flag that prevents calling this.destroy(). Until now it wasn't really needed because most API calls were not really called in parallel. Called one at a time. But versions will be called in parallel to say the File api call. So calling destroy will destroy the other. Likewise I didn't want two API calls to muck with the same cached object, but in versions case its a diff cache object, so not a big deal from that perspective.
Either that, or the call to getVersionAPI() should come in the fetch success callback of the file, so that its a serial call and not parallel.
this.rootElement = ((document.getElementById(this.id): any): HTMLElement); | ||
this.appElement = ((this.rootElement.firstElementChild: any): HTMLElement); | ||
|
||
if (fileId) { | ||
this.fetchFile(fileId); | ||
if (hasVersions) { |
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.
componentWillReceiveProps also has fetchFile(), this will likely need to be replicated there.
OR maybe have this.fetchVersions() inside fetchFile()
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.
Refactoring componentWillReceiveProps a bit
@@ -56,6 +63,7 @@ const DetailsSidebar = ({ | |||
|
|||
return ( | |||
<SidebarContent hasTitle={hasTitle} title={<FormattedMessage {...messages.sidebarDetailsTitle} />}> | |||
{hasVersions && <SidebarVersions onClick={onVersionHistoryClick} versions={versions} />} |
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.
onClick is fine for now, but may need a more descriptive name in the future if/when we pull in version switching and other on* actions.
} | ||
|
||
return ( | ||
<section className='bcs-section'> |
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 other commit from jeremy has some improvements of <SidebarSection>
without need of a title, perhaps see if that works well here.
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.
👍
); | ||
}; | ||
|
||
SidebarVersions.defaultProps = { |
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.
Not the pattern we use, causes side effects for uglifyjs cleanup.
Assign the defaults within the props.
{ onVersionHistoryClick, versions = { total_count: 0 } }
Also will total count not be there?
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.
total_count would not be there if API hasn't responded by time the component has rendered
src/flowTypes.js
Outdated
@@ -338,3 +339,19 @@ export type MultiputPart = { | |||
export type MultiputData = { | |||
part?: MultiputPart | |||
}; | |||
|
|||
export type Version = { |
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 would refactor and make them the same, you would just need to add ? to properties that are optional and not needed for the object to be partial and just null check them. Should ideally not have two definitions of versions.
Webpack Bundle Size Github Bot
Compared against previously merged PR #206 |
This adds the versions API, and version history to the details tab. Relies on box-react-ui 22.6.0