-
Notifications
You must be signed in to change notification settings - Fork 68
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
Delete folder or file from file group #744
Conversation
@@ -36,6 +40,7 @@ export class BlobFilesBrowserComponent implements OnChanges, OnDestroy { | |||
if (inputs.upload) { | |||
this.fileExplorerConfig = { | |||
canDropExternalFiles: Boolean(this.upload), | |||
canDeleteFiles: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above Boolean(this.delete)
// TODO: Check with Tim as to whether i can chain 2 background tasks to run one after another. | ||
// In which case most of this can be moved into DataContainerFilesComponent. | ||
// task 1: get files to delete | ||
// task 2: delete files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could but I don't think thats a good idea, it would look weird. Maybe what you could do is have it send back an observable that resolve files instead of the actual files so the waiting can be done in the background task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but otherwise I think its all good like that for now until we make that generic FileSystem
yes: () => { | ||
const listParams = { recursive: true, startswith: path }; | ||
const data = this.storageService.listBlobs(Promise.resolve(this.container), listParams); | ||
return data.fetchAll().flatMap(() => data.items.take(1)).map((items) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would not use .map here because it won't run unless you subscribe to it. I know this funciton is being passed up to the dialog which subscribe to it but it is a bit confusing to actually do state actions in the map. I would just have it
const obs = ...
obs.subscribe(...)
return obs;
|
||
return this.backgroundTaskService.startTask(taskTitle, (task) => { | ||
let deleted = 0; | ||
let observable = Observable.interval(250).take(fileCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
…ure/delete-group-files
task.progress.next(deleted / fileCount * 100); | ||
|
||
if (response && blobCache) { | ||
blobCache.deleteItem(files[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be the deleteBlobIfexists that remove from the cache. I feel this would be better. THat way you don't have to do that everytime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on a .subscribe(() => { /* remove from cache */ })?
probably a very good idea and one that i am not sure why i didn't think of :)
complete: () => { | ||
task.progress.next(100); | ||
// tslint:disable-next-line:max-line-length | ||
const message = `${deleted} files were successfully removed from the file group: ${this.container.name}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note this is where I think starting to think about i18n would be good. Long string like that don't look good in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sure, and every time i see loads of UI text in the code i think the same thing.
task.progress.next(100); | ||
// tslint:disable-next-line:max-line-length | ||
const message = `${deleted} files were successfully removed from the file group: ${this.container.name}`; | ||
this.notificationService.success("Removed files from group", message, { persist: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really want to persist that one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not, though i saw it was in a few other places. can remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah error and warning are persisted by default but info and success disapear.
I force it to displayed for stuff where you have actions that you might want to do
public handleDeleteEvent(event: FileDeleteEvent) { | ||
const { path } = event; | ||
this.dialogService.confirm(`Delete files`, { | ||
description: event.isDirectory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make a description variable no to have this ternary condition inline
yes: () => { | ||
const listParams = { recursive: true, startswith: path }; | ||
const data = this.storageService.listBlobs(this.container, listParams); | ||
const obs = data.fetchAll().flatMap(() => data.items.take(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add .shareReplay(1) at the end so it doesn't trigger the flatMap for every subscription
} | ||
|
||
/** | ||
* Load the inital data | ||
*/ | ||
public init() { | ||
this._loadFilesInPath(""); | ||
if (this._cache) { | ||
this._fileDeleted = this._cache.deleted.subscribe((key: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick:_fileDeletedSub
}); | ||
|
||
return observable; | ||
// TODO: would like to get the deleted count from this call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use next instead of complete and make the service return the number of files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean the number of files(because you can just do files.length above) or the number of files that actually existsed and were deleted?
error: (error) => { | ||
// tslint:disable-next-line:max-line-length | ||
const message = `Not all files were able to be removed from the file group: ${this.container.name}`; | ||
this.notificationService.error("Error while deleting files", message, { persist: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to specify presist true for error its the default
app/services/storage.service.ts
Outdated
const observable = Observable.interval(100).take(fileCount); | ||
observable.subscribe({ | ||
next: (i) => { | ||
deleted++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't deleted the same as i?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, though i need to change it to be the actual number of deleted files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but actually what do you expect to show if the number is different? Some files wasn't deleted successfully or some files were already deleted?
because of option 2 I don't really see the point of showing 23/26 files deleted. This feels more confusing to me and let you wonder why there is three that are not deleted(even though they actually are)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i expected i would show a warning that not all files were able to be deleted. but maybe i just shouldn't bother ....
Fix #733
Only allow deletion from a storage container. Ignore files and folders on compute nodes.
Storage API only allows deleting blobs one at a time.