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

Replace spaces by underscores in file names #24

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 9 additions & 4 deletions src/resources/assets/js/createContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import DirectoriesApi from './api/storageRequestDirectories';
import FilesApi from './api/storageRequestFiles';
import StorageRequestApi from './api/storageRequests';
import {LoaderMixin, handleErrorResponse, FileBrowserComponent, warning} from './import';
import {LoaderMixin, handleErrorResponse, FileBrowserComponent} from './import';
import {sizeForHumans} from './utils';

// Number of times a file upload is retried.
Expand Down Expand Up @@ -34,6 +34,7 @@ export default {
maxFilesizeBytes: 0,
exceedsMaxFilesize: false,
chunkSize: 0,
pathContainsSpaces: false,
};
},
computed: {
Expand Down Expand Up @@ -130,9 +131,9 @@ export default {
// See https://github.com/biigle/user-storage/issues/16.
let file = newFiles[i];
if (file.name.includes(' ')) {
let newName = newFiles[i].name.replace(' ', '_');
file = new File([newFiles[i]], newName, { type: newFiles[i].type })
warning('Spaces are replaced by underscores in file names');
this.pathContainsSpaces = true;
let newName = newFiles[i].name.replace(/ /g, '_');
file = new File([newFiles[i]], newName, { type: newFiles[i].type });
}
files.push(file);
}
Expand Down Expand Up @@ -176,6 +177,10 @@ export default {
addDirectory(root) {
let name = prompt('Please enter the new directory name');
if (name) {
if (name.includes(' ')) {
this.pathContainsSpaces = true;
name = name.replace(/ /g, '_');
}
this.handleNewDirectory(name, root === true);
}
},
Expand Down
1 change: 0 additions & 1 deletion src/resources/assets/js/import.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export let FileBrowserComponent = biigle.$require('core.components.fileBrowser');
export let handleErrorResponse = biigle.$require('messages').handleErrorResponse;
export let warning = biigle.$require('messages').warning;
export let LoaderMixin = biigle.$require('core.mixins.loader');
4 changes: 4 additions & 0 deletions src/resources/views/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class="btn btn-success"
Selected files with a total size of <span v-text="totalSizeForHumans"></span>.
</p>

<p v-cloak v-if="pathContainsSpaces" class="text-warning">
Replaced spaces by underscores.
mzur marked this conversation as resolved.
Show resolved Hide resolved
</p>

<file-browser
v-cloak
v-bind:root-directory="rootDirectory"
Expand Down