data exports: Keep deleted export in UI table.

It makes sense to keep a deleted export in the table,
along with the time of deletion, for auditing reasons.
This commit is contained in:
Wyatt Hoodes
2020-04-20 11:02:45 -10:00
committed by Tim Abbott
parent 2204f33936
commit 5a58b7c549
4 changed files with 27 additions and 17 deletions

View File

@@ -29,28 +29,34 @@ exports.populate_exports_table = function (exports) {
name: "admin_exports_list",
modifier: function (data) {
let failed_timestamp = data.failed_timestamp;
let deleted_timestamp = data.deleted_timestamp;
if (failed_timestamp !== null) {
failed_timestamp = timerender.last_seen_status_from_date(
new XDate(failed_timestamp * 1000)
);
}
if (data.deleted_timestamp === null) {
return render_admin_export_list({
realm_export: {
id: data.id,
acting_user: people.get_full_name(data.acting_user_id),
// Convert seconds -> milliseconds
event_time: timerender.last_seen_status_from_date(
new XDate(data.export_time * 1000)
),
url: data.export_url,
time_failed: failed_timestamp,
pending: data.pending,
},
});
if (deleted_timestamp !== null) {
deleted_timestamp = timerender.last_seen_status_from_date(
new XDate(deleted_timestamp * 1000)
);
}
return "";
return render_admin_export_list({
realm_export: {
id: data.id,
acting_user: people.get_full_name(data.acting_user_id),
// Convert seconds -> milliseconds
event_time: timerender.last_seen_status_from_date(
new XDate(data.export_time * 1000)
),
url: data.export_url,
time_failed: failed_timestamp,
pending: data.pending,
time_deleted: deleted_timestamp,
},
});
},
filter: {
element: exports_table.closest(".settings-section").find(".search"),

View File

@@ -13,12 +13,16 @@
<span class="export_status">{{t 'Failed' }}: {{time_failed}}</span>
{{else if pending}}
<div class="export_url_spinner"></div>
{{else if time_deleted}}
<span class="export_status">{{t 'Deleted' }}: {{time_deleted}}</span>
{{/if}}
</td>
<td class="actions">
{{#unless time_deleted}}
<button class="button rounded small delete btn-danger" data-export-id="{{id}}">
<i class="fa fa-trash-o" aria-hidden="true"></i>
</button>
{{/unless}}
</td>
</tr>
{{/with}}

View File

@@ -1776,7 +1776,7 @@ def get_realm_exports_serialized(user: UserProfile) -> List[Dict[str, Any]]:
failed_timestamp = export_data.get('failed_timestamp')
export_path = export_data.get('export_path')
if export_path:
if export_path and not deleted_timestamp:
export_url = zerver.lib.upload.upload_backend.get_export_tarball_url(
user.realm, export_path)

View File

@@ -2864,7 +2864,7 @@ class EventsRegisterTest(ZulipTestCase):
('id', check_int),
('export_time', check_float),
('acting_user_id', check_int),
('export_url', check_string),
('export_url', equals(None)),
('deleted_timestamp', check_float),
('failed_timestamp', equals(None)),
('pending', check_bool),