gui: Disable Restore Versions filters when no versioned files exist (fixes #5408) (#8539)

Currently, the name and date filters in the Restore Versions modal are
always enabled, even if there are no versioned files present. With this
change, they are enabled only when there are no errors and versioned
files actually exist.

In addition to disabling the filters, also completely skip date picker
generation, as it serves no function while still displaying a non-sense
date range, which starts today and ends in the past.

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
tomasz1986 2023-03-10 13:41:15 +01:00 committed by GitHub
parent b00976781c
commit b53c1b9a04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -2686,6 +2686,8 @@ angular.module('syncthing.core')
if (closed) {
resetRestoreVersions();
return;
} else if ($scope.sizeOf($scope.restoreVersions.versions) === '0') {
return;
}
$scope.restoreVersions.tree = $("#restoreTree").fancytree({
@ -2702,7 +2704,7 @@ angular.module('syncthing.core')
indentation: 24,
},
strings: {
loading: $translate.instant("Loading..."),
loading: $translate.instant("Loading data..."),
loadError: $translate.instant("Failed to load file versions."),
noData: $translate.instant("There are no file versions to restore.")
},

View File

@ -1,12 +1,14 @@
<modal id="restoreVersions" status="default" icon="fas fa-undo" heading="{{'Restore Versions' | translate}} ({{folderLabel(restoreVersions.folder)}})" large="yes" closeable="yes">
<div class="modal-body">
<span translate ng-if="!restoreVersions.versions && !restoreVersions.errors">Loading data...</span>
<div ng-if="restoreVersions.versions">
<div ng-if="restoreVersions.versions && !restoreVersions.errors">
<div id="restoreTree-container">
<table id="restoreTree">
<tbody>
<tr>
<td></td>
<td>
<span ng-if="sizeOf(restoreVersions.versions) > 0" translate>Loading data...</span>
<span ng-if="sizeOf(restoreVersions.versions) == 0" translate>There are no file versions to restore.</span>
</td>
<td></td>
</tr>
</tbody>
@ -17,13 +19,13 @@
<div class="col-md-6">
<div class="form-group">
<label for="restoreVersionSearch"><span translate>Filter by name</span>:&nbsp</label>
<input id="restoreVersionSearch" class="form-control" type="text" ng-model="restoreVersions.filters.text">
<input id="restoreVersionSearch" class="form-control" type="text" ng-model="restoreVersions.filters.text" ng-disabled="sizeOf(restoreVersions.versions) == 0">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="restoreVersionDate"><span translate>Filter by date</span>:&nbsp</label>
<input id="restoreVersionDateRange" class="form-control">
<input id="restoreVersionDateRange" class="form-control" ng-disabled="sizeOf(restoreVersions.versions) == 0">
</div>
</div>
</div>