Skip to content

Commit

Permalink
feat(ui): restore file or folder (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 committed Dec 3, 2024
1 parent cbad865 commit ee1d0b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 108 deletions.
8 changes: 4 additions & 4 deletions ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@
"from_node_name": "From node {name}",
"most_recent": "Most recent",
"no_snapshot_to_restore": "No snapshot to restore",
"start_typing_to_search": "Start typing to search file or folder",
"search_file_or_folder": "Search file or folder",
"restore_file_info": "The selected file or folder will be restored to '{restoredFolder}'. Ensure there is sufficient space on {node} to avoid restore failure.",
"restoring_to_share_name": "Restoring to share '{name}'",
"searchbox_limit_reached": "Continue typing to show more options"
"restoring_to_share_name": "Restoring to share '{name}'"
},
"about": {
"title": "About"
Expand Down Expand Up @@ -122,6 +121,7 @@
"ns_combo_search_box": {
"placeholder": "Search",
"clear_search": "Clear search",
"no_results": "No results"
"no_results": "No results",
"results_limit_reached": "Keep typing to show more options"
}
}
108 changes: 9 additions & 99 deletions ui/src/components/shared-folders/NsComboSearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@
</div>
</div>
</div>
<!-- more options available -->
<!-- more results available -->
<div
v-if="
!loadingResults &&
internalResults.length &&
(internalResultsLimitReached ||
internalResults.length > maxDisplayOptions)
(resultsLimitReached || internalResults.length > maxDisplayOptions)
"
:class="`${carbonPrefix}--list-box__menu-item`"
>
Expand All @@ -206,7 +206,7 @@
'item-disabled'
]"
>
{{ $t("shares.searchbox_limit_reached") }}
{{ resultsLimitReachedLabel }}
</div>
</div>
</div>
Expand Down Expand Up @@ -267,11 +267,6 @@ export default {
Search20
},
props: {
// repositoryId: String, //// remove
// repositoryPath: String, //// remove
// snapshotId: String, //// remove
// shareName: String, //// remove
// searchCallback: { type: Function, required: true }, ////
results: { type: Array, default: () => [] },
resultsLimitReached: { type: Boolean, default: false },
loadingResults: { type: Boolean, default: false },
Expand All @@ -289,6 +284,10 @@ export default {
value: String,
clearFilterLabel: { type: String, default: "Clear search" },
noResultsLabel: { type: String, default: "No results" },
resultsLimitReachedLabel: {
type: String,
default: "Keep typing to show more options"
},
// limit the number of options to be displayed
maxDisplayOptions: { type: Number, default: 100 },
tooltipAlignment: {
Expand All @@ -314,10 +313,7 @@ export default {
isHelper: false,
isInvalid: false,
isWarn: false,
internalResultsLimitReached: false,
noResults: false,
// loading: false, ////
errorMessage: "" //// remove?
noResults: false
};
},
model: {
Expand All @@ -336,11 +332,6 @@ export default {
results() {
this.updateResults();
},
resultsLimitReached() {
console.log("watch resultsLimitReached", this.resultsLimitReached); ////

this.updateResultsLimitReached();
},
internalResults() {
setTimeout(() => {
// mark textQuery in internalResults
Expand All @@ -357,7 +348,6 @@ export default {
this.highlighted = this.value ? this.value : this.highlight; // override highlight with value if provided
this.checkSlots();
this.updateResults();
this.updateResultsLimitReached();
},
updated() {
this.checkSlots();
Expand Down Expand Up @@ -583,9 +573,6 @@ export default {
this.internalResults = _cloneDeep(this.results);
this.noResults = this.internalResults.length === 0;
},
updateResultsLimitReached() {
this.internalResultsLimitReached = this.resultsLimitReached;
},
performSearch(textQuery) {
textQuery = textQuery.trim();

Expand All @@ -598,88 +585,11 @@ export default {
this.internalResults = [];
return;
}
// this.loading = true; ////
this.doOpen(true);
// this.internalResultsLimitReached = false; ////

// trigger search on parent component
this.$emit("search", textQuery);
}
//// remove
// async seekSnapshotContents(textQuery) {
// // textQuery = textQuery.trim(); ////

// // if (textQuery === this.lastQuery) {
// // return;
// // }
// // this.lastQuery = textQuery;

// // if (!textQuery) {
// // this.internalResults = [];
// // return;
// // }
// // this.loading = true;
// this.errorMessage = "";
// this.internalResultsLimitReached = false;
// // this.doOpen(true); ////
// const taskAction = "seek-snapshot-contents";
// const eventId = this.getUuid();

// // register to task error
// this.core.$root.$once(
// `${taskAction}-aborted-${eventId}`,
// this.seekSnapshotContentsAborted
// );

// // register to task completion
// this.core.$root.$once(
// `${taskAction}-completed-${eventId}`,
// this.seekSnapshotContentsCompleted
// );

// const res = await to(
// this.createModuleTaskForApp(this.instanceName, {
// action: taskAction,
// data: {
// snapshot: this.snapshotId,
// destination: this.repositoryId,
// repopath: this.repositoryPath,
// share: this.shareName,
// limit: 50,
// query: textQuery
// },
// extra: {
// title: this.$t("action." + taskAction),
// isNotificationHidden: true,
// eventId
// }
// })
// );
// const err = res[0];

// if (err) {
// console.error(`error creating task ${taskAction}`, err);
// this.errorMessage = this.getErrorMessage(err);
// this.loading = false;
// this.doOpen(false);
// return;
// }
// },
// seekSnapshotContentsAborted(taskResult, taskContext) {
// console.error(`${taskContext.action} aborted`, taskResult);
// this.loading = false;
// },
// seekSnapshotContentsCompleted(taskContext, taskResult) {
// this.internalResults = taskResult.output.contents.map((item) => ({
// name: item,
// label: item,
// value: item
// }));

// this.noResults = this.internalResults.length === 0;
// this.internalResultsLimitReached = taskResult.output.limit_reached;
// this.loading = false;
// }
}
};
</script>
Expand Down
10 changes: 5 additions & 5 deletions ui/src/components/shared-folders/RestoreFileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<cv-grid class="mg-top-xlg mg-bottom-md no-padding">
<cv-row>
<cv-column>
<!-- backupSnapshots {{ backupSnapshots }} //// -->
<BackupSnapshotSelector
v-model="selectedSnapshotId"
:snapshots="backupSnapshots"
Expand All @@ -83,11 +82,14 @@
:resultsLimitReached="resultsLimitReached"
:loadingResults="loading.seekSnapshotContents"
auto-highlight
:placeholder="$t('shares.start_typing_to_search')"
:placeholder="$t('shares.search_file_or_folder')"
:invalid-message="error.group"
light
:clearFilterLabel="$t('ns_combo_search_box.clear_search')"
:noResultsLabel="$t('ns_combo_search_box.no_results')"
:resultsLimitReachedLabel="
$t('ns_combo_search_box.results_limit_reached')
"
ref="fileSearch"
class="mg-top-xlg"
@change="selectedFile = $event"
Expand Down Expand Up @@ -234,7 +236,7 @@ export default {
}

if (this.isLastStep) {
this.restoreBackupContent(); ////
this.restoreBackupContent();
} else {
this.step = this.steps[this.stepIndex + 1];
}
Expand Down Expand Up @@ -544,8 +546,6 @@ export default {
value: item
}));

console.log("limitREached", taskResult.output.limit_reached); ////

this.resultsLimitReached = taskResult.output.limit_reached;
this.loading.seekSnapshotContents = false;
}
Expand Down

0 comments on commit ee1d0b6

Please sign in to comment.