-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -203,11 +203,6 @@ class EndpointBrowser { | |
// Fetch directory listing | ||
api.epDirList(this.props.endpoint.id, this.state.path, false, (data) => { | ||
this.updateTree(data); | ||
// this.handleApiResponse(data); | ||
|
||
// // Reset loading state | ||
// this.state.loading = false; | ||
// $("#file_tree").fancytree("enable"); | ||
}); | ||
} | ||
|
||
|
@@ -216,71 +211,85 @@ class EndpointBrowser { | |
* @param {Object} data - The data to update the tree with | ||
Check failure on line 211 in web/static/components/endpoint-browse/index.js
|
||
*/ | ||
updateTree(data) { | ||
let source; | ||
const source = this.getTreeSource(data); | ||
$.ui.fancytree.getTree("#file_tree").reload(source); | ||
this.state.loading = false; | ||
$("#file_tree").fancytree("enable"); | ||
|
||
} | ||
|
||
/** | ||
* Get tree source data | ||
* @param {Object} data - API response data | ||
Check failure on line 223 in web/static/components/endpoint-browse/index.js
|
||
* @returns {Array} Tree source data | ||
*/ | ||
getTreeSource(data) { | ||
if (data.code) { | ||
if (data.code === "ConsentRequired") { | ||
api.getGlobusAuthorizeURL(data.required_scopes, (ok, data) => { | ||
source = [ | ||
{ | ||
title: `<span class='ui-state-error'>Consent Required: Please provide <a href="${data.authorize_url}">consent</a>.</span>`, | ||
icon: false, | ||
is_dir: true, | ||
}, | ||
]; | ||
return this.handleApiError(data); | ||
} | ||
return [ | ||
{ | ||
title: CONFIG.PATH.CURRENT, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: CONFIG.PATH.CURRENT, | ||
is_dir: true, | ||
}, | ||
{ | ||
title: CONFIG.PATH.UP, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: CONFIG.PATH.UP, | ||
is_dir: true, | ||
}, | ||
...data.DATA.map((entry) => | ||
entry.type === "dir" | ||
? { | ||
title: entry.name, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: entry.name, | ||
is_dir: true, | ||
} | ||
: { | ||
title: entry.name, | ||
icon: CONFIG.UI.ICONS.FILE, | ||
key: entry.name, | ||
is_dir: false, | ||
size: util.sizeToString(entry.size), | ||
date: new Date(entry.last_modified.replace(" ", "T")).toLocaleString(), | ||
}, | ||
), | ||
]; | ||
} | ||
|
||
$.ui.fancytree.getTree("#file_tree").reload(source); | ||
this.state.loading = false; | ||
$("#file_tree").fancytree("enable"); | ||
}); | ||
} else { | ||
source = [ | ||
/** | ||
* Handle API error responses | ||
* @param {Object} data - API response data | ||
Check failure on line 265 in web/static/components/endpoint-browse/index.js
|
||
* @returns {Array} Error message source | ||
*/ | ||
handleApiError(data) { | ||
if (data.code === "ConsentRequired") { | ||
api.getGlobusAuthorizeURL((ok, data) => { | ||
const source = [ | ||
{ | ||
title: `<span class='ui-state-error'>Error: ${data.message}</span>`, | ||
title: `<span class='ui-state-error'>Consent Required: Please provide <a href="${data.authorize_url}">consent</a>.</span>`, | ||
icon: false, | ||
is_dir: true, | ||
}, | ||
]; | ||
} | ||
|
||
$.ui.fancytree.getTree("#file_tree").reload(source); | ||
this.state.loading = false; | ||
$("#file_tree").fancytree("enable"); | ||
}, this.props.endpoint.id, data.required_scopes); | ||
} else { | ||
source = [ | ||
{ | ||
title: CONFIG.PATH.CURRENT, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: CONFIG.PATH.CURRENT, | ||
is_dir: true, | ||
}, | ||
return [ | ||
{ | ||
title: CONFIG.PATH.UP, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: CONFIG.PATH.UP, | ||
title: `<span class='ui-state-error'>Error: ${data.message}</span>`, | ||
icon: false, | ||
is_dir: true, | ||
}, | ||
...data.DATA.map((entry) => | ||
entry.type === "dir" | ||
? { | ||
title: entry.name, | ||
icon: CONFIG.UI.ICONS.FOLDER, | ||
key: entry.name, | ||
is_dir: true, | ||
} | ||
: { | ||
title: entry.name, | ||
icon: CONFIG.UI.ICONS.FILE, | ||
key: entry.name, | ||
is_dir: false, | ||
size: util.sizeToString(entry.size), | ||
date: new Date( | ||
entry.last_modified.replace(" ", "T"), | ||
).toLocaleString(), | ||
}, | ||
), | ||
]; | ||
} | ||
|
||
$.ui.fancytree.getTree("#file_tree").reload(source); | ||
this.state.loading = false; | ||
$("#file_tree").fancytree("enable"); | ||
} | ||
|
||
/** | ||
|