[Code] adjust clone progress and not found rendering in source view page (#38213)

This commit is contained in:
Mengwei Ding 2019-06-06 17:29:48 -07:00 committed by GitHub
parent 358343b1e1
commit fee3a82bb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View file

@ -24,11 +24,11 @@ export const CloneStatus = (props: Props) => {
const { receivedObjects, totalObjects, indexedObjects } = cloneProgress;
if (receivedObjects === totalObjects) {
progress = `Indexing objects: ${(indexedObjects / totalObjects).toFixed(
progress = `Indexing objects: ${((indexedObjects * 100) / totalObjects).toFixed(
2
)}% (${indexedObjects}/${totalObjects})`;
} else {
progress = `Receiving objects: ${(receivedObjects / totalObjects).toFixed(
progress = `Receiving objects: ${((receivedObjects * 100) / totalObjects).toFixed(
2
)}% (${receivedObjects}/${totalObjects})`;
}

View file

@ -237,7 +237,7 @@ class CodeContent extends React.PureComponent<Props> {
);
}
public shouldRenderProgress() {
public shouldRenderCloneProgress() {
if (!this.props.repoStatus) {
return false;
}
@ -250,7 +250,7 @@ class CodeContent extends React.PureComponent<Props> {
);
}
public renderProgress() {
public renderCloneProgress() {
if (!this.props.repoStatus) {
return null;
}
@ -268,12 +268,15 @@ class CodeContent extends React.PureComponent<Props> {
public renderContent() {
const { file, match, tree, fileTreeLoadingPaths, isNotFound, notFoundDirs } = this.props;
const { path, pathType, resource, org, repo, revision } = match.params;
// The clone progress rendering should come before the NotFound rendering.
if (this.shouldRenderCloneProgress()) {
return this.renderCloneProgress();
}
if (isNotFound || notFoundDirs.includes(path || '')) {
return <NotFound />;
}
if (this.shouldRenderProgress()) {
return this.renderProgress();
}
const repoUri = `${resource}/${org}/${repo}`;
switch (pathType) {