Skip to content
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

3145 path selector error handling #3150

Merged
merged 5 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class PathSelectorTable {

async reloadTable(url) {
try {
$(`#${this.tableId}_wrapper`).hide();
$(this.tableWrapper()).hide();
$('#loading-icon').show();
const response = await fetch(url, { headers: { 'Accept': 'application/json' }, cache: 'no-store' });
const data = await this.dataFromJsonResponse(response);
Expand All @@ -92,15 +92,23 @@ export class PathSelectorTable {
this._table.rows.add(data.files);
this.setLastVisited(data.path);
this._table.draw();
$('#loading-icon').hide();
$(`#${this.tableId}_wrapper`).show();
this.resetTable();
} catch (err) {
$('#loading-icon').hide();
$(`#${this.tableId}_wrapper`).show();
this.resetTable();
if (err.message.match("Permission denied")) {
$('#forbidden-warning').removeClass('d-none')
$('#forbidden-warning').trigger('focus');
}
console.log(err);
}
}

resetTable() {
$('#loading-icon').hide();
$(this.tableWrapper()).show();
$('#forbidden-warning').addClass('d-none');
}

dataFromJsonResponse(response) {
return new Promise((resolve, reject) => {
Promise.resolve(response)
Expand Down Expand Up @@ -144,6 +152,10 @@ export class PathSelectorTable {
return `${this.tableId}_last_visited`;
}

tableWrapper() {
return `#${this.tableId}_wrapper`;
}

// note that this is storing the file system path, not the path of the URL
// i.e., '/home/annie' not '/pun/sys/dashboard/files/fs/home/annie'
getLastVisited() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<div>
<ol id="<%= breadcrumb_id %>" class="breadcrumb breadcrumb-no-delimiter">
</ol>

<div class="d-none alert alert-warning" role="alert" id="forbidden-warning">
<%= t('dashboard.batch_connect_sessions_path_selector_forbidden_error') %>
</div>

<div class="d-flex justify-content-center">
<div id="loading-icon" class="spinner-border rem-5" role="status">
<span class="sr-only">Loading...</span>
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ en:
take a few minutes.

batch_connect_sessions_status_completed: "For debugging purposes, this card will be retained for %{days} more days"
batch_connect_sessions_path_selector_forbidden_error: "You do not have permission to select that directory or file."
batch_connect_apps_menu_title: "Interactive Apps"
breadcrumbs_all_apps: "All Apps"
breadcrumbs_home: "Home"
Expand Down