-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor upload inputs into one component (#6859)
* Refactor upload inputs into one component * Add changelog item * Run linter * Use `oc-` classes Co-authored-by: Pascal Wengerter <pwengerter@owncloud.com> * Update snapshots Co-authored-by: Pascal Wengerter <pwengerter@owncloud.com>
- Loading branch information
1 parent
b45b8ec
commit 80195d8
Showing
14 changed files
with
139 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Refactor upload input components | ||
|
||
We've refactored the upload input components for files and folders into one component. | ||
|
||
https://github.com/owncloud/web/pull/6859 | ||
https://github.com/owncloud/web/issues/6819 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
packages/web-app-files/src/components/AppBar/Upload/FileUpload.vue
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
packages/web-app-files/src/components/AppBar/Upload/FolderUpload.vue
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<template> | ||
<div> | ||
<oc-button :class="btnClass" justify-content="left" appearance="raw" @click="triggerUpload"> | ||
<oc-resource-icon :resource="{ extension: '', isFolder }" /> | ||
<span :id="uploadLabelId">{{ buttonLabel }}</span> | ||
</oc-button> | ||
<input | ||
:id="inputId" | ||
ref="input" | ||
v-bind="inputAttrs" | ||
class="upload-input-target" | ||
type="file" | ||
:aria-labelledby="uploadLabelId" | ||
:name="isFolder ? 'file' : 'folder'" | ||
tabindex="-1" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
btnLabel: { | ||
type: String, | ||
required: false, | ||
default: '' | ||
}, | ||
btnClass: { | ||
type: String, | ||
required: false, | ||
default: '' | ||
}, | ||
isFolder: { | ||
type: Boolean, | ||
required: false, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
inputId() { | ||
if (this.isFolder) { | ||
return 'files-folder-upload-input' | ||
} | ||
return 'files-file-upload-input' | ||
}, | ||
uploadLabelId() { | ||
if (this.isFolder) { | ||
return 'files-folder-upload-button' | ||
} | ||
return 'files-file-upload-button' | ||
}, | ||
buttonLabel() { | ||
if (this.btnLabel) { | ||
return this.btnLabel | ||
} | ||
if (this.isFolder) { | ||
return this.$gettext('Folder') | ||
} | ||
return this.$gettext('Files') | ||
}, | ||
inputAttrs() { | ||
if (this.isFolder) { | ||
return { | ||
webkitdirectory: true, | ||
mozdirectory: true, | ||
allowdirs: true | ||
} | ||
} | ||
return { multiple: true } | ||
} | ||
}, | ||
mounted() { | ||
this.$uppyService.registerUploadInput(this.$refs.input) | ||
}, | ||
beforeDestroy() { | ||
this.$uppyService.removeUploadInput(this.$refs.input) | ||
}, | ||
methods: { | ||
triggerUpload() { | ||
this.$refs.input.click() | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.upload-input-target { | ||
position: absolute; | ||
left: -99999px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
packages/web-app-files/tests/unit/components/AppBar/Upload/FolderUpload.spec.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...b-app-files/tests/unit/components/AppBar/Upload/__snapshots__/ResourceUpload.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Resource Upload Component file upload should render component 1`] = `<div><button type="button" class="oc-button oc-rounded oc-button-m oc-button-justify-content-left oc-button-gap-m oc-button-passive oc-button-passive-raw"><span class="oc-icon oc-icon-l oc-icon-passive oc-resource-icon oc-resource-icon-file"><!----></span> <span id="files-file-upload-button">Files</span></button> <input id="files-file-upload-input" type="file" aria-labelledby="files-file-upload-button" name="folder" tabindex="-1" multiple="multiple" class="upload-input-target"></div>`; | ||
exports[`Resource Upload Component folder upload should render component 1`] = `<div><button type="button" class="oc-button oc-rounded oc-button-m oc-button-justify-content-left oc-button-gap-m oc-button-passive oc-button-passive-raw"><span class="oc-icon oc-icon-l oc-icon-passive oc-resource-icon oc-resource-icon-folder"><!----></span> <span id="files-folder-upload-button">Folder</span></button> <input id="files-folder-upload-input" type="file" aria-labelledby="files-folder-upload-button" name="file" tabindex="-1" webkitdirectory="true" mozdirectory="true" allowdirs="true" class="upload-input-target"></div>`; |
Oops, something went wrong.