This repository was archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
File Uploader #80
Merged
Merged
File Uploader #80
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
63d8a8c
Merge branch 'release-1.0.0-beta.6'
simardo 9b1174d
Merge branch 'release-1.0.0-beta.7'
simardo 54a9747
Merge branch 'release-1.0.0-beta.8'
simardo 49ed1c6
Merge branch 'release-1.0.0-beta.9'
simardo 221caac
Merge branch 'release-1.0.0-beta.10'
simardo d52f256
Merge branch 'release-1.0.0-beta.11'
simardo 22f0151
Merge branch 'release-1.0.0-beta.12'
simardo 961b342
Merge branch 'release-1.0.0-beta.13'
simardo 54c4351
Merge branch 'release-1.0.0-beta.14'
simardo d144b67
Merge branch 'release-1.0.0-beta.15'
simardo c85326b
Merge branch 'release-1.0.0-beta.16'
simardo 17bf7d1
Merge branch 'release-1.0.0-beta.17'
simardo f2cddb5
Merge pull request #71 from ulaval/release-1.0.0-beta.18
simardo 30482ae
file-select
jfnadeau 74646e6
$file
jfnadeau 7cb8655
file-upload
jfnadeau 7badd09
progress
jfnadeau f626679
file-drop
jfnadeau 8c1321b
drag-drop zone vector
jfnadeau 509fd32
filesize dependency
jfnadeau 0fe4f44
spec to jest
jfnadeau 2c6eadd
file extension to method
jfnadeau 9d4ca1f
Add error message under the progress bar
setur52 be9c418
visual hint after file is completed
jfnadeau 47ff545
remove setTimeout
jfnadeau 3276840
translation filesize
jfnadeau 016d86f
file-upload spec
jfnadeau bf61e43
extract file mocking utils
jfnadeau 00965a9
Style modifications
setur52 3140a3a
update shapshot
setur52 f937985
meta: support optional prop
jfnadeau 7c0df37
line break
jfnadeau e33ecc0
extra typing
jfnadeau 0ac1012
extension - convert to getter
jfnadeau 9b26355
Typing getters
setur52 f4367fb
Merge branch 'feature/fileupload' of https://github.com/ulaval/modul-…
simardo 6638f5e
update package-lock (to resolve conflict)
simardo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
src/components/file-select/__snapshots__/file-select.spec.ts.snap
This file contains hidden or 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,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`file-select should render correctly 1`] = ` | ||
<div class="m-file-select"> | ||
<input type="file" id="mFileSelect-uuid" tabindex="-1" class="m-file-select__hidden"> | ||
<label for="mFileSelect-uuid" class="m-file-select__hidden"><span class="m-i18n">Browse</span></label> | ||
<button type="button" aria-hidden="true" class="m-button m--is-skin-secondary"> <span class="m-button__text"><span class="m-i18n">Browse</span> </span> | ||
</button> | ||
</div> | ||
`; |
This file contains hidden or 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,24 @@ | ||
<div class="m-file-select"> | ||
<input ref="inputFile" type="file" :id="id" class="m-file-select__hidden" @change="processFile" :disabled="disabled || isWaiting" tabindex="-1" :multiple="multiple"> | ||
<label :for="id" class="m-file-select__hidden"> | ||
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n> | ||
<template v-else>{{ label }}</template> | ||
</label> | ||
<m-button @click="onClick" @focus="onFocus" @blur="onBlur" aria-hidden="true" | ||
:skin="skin" | ||
:disabled="disabled" | ||
:waiting="waiting" | ||
:fullSize="fullSize" | ||
:iconName="iconName" | ||
:iconPosition="iconPosition" | ||
:iconSize="iconSize"> | ||
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n> | ||
<template v-else>{{ label }}</template> | ||
</m-button> | ||
<m-validation-message ref="validation" | ||
:disabled="isDisabled" | ||
:error="hasError" | ||
:error-message="errorMessage" | ||
:valid-message="validMessage" | ||
:helper-message="helperMessage"></m-validation-message> | ||
</div> |
This file contains hidden or 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 @@ | ||
{ | ||
"m-select-file": { | ||
"label": "Browse" | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
{ | ||
"m-select-file": { | ||
"label": "Parcourir" | ||
} | ||
} |
This file contains hidden or 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,7 @@ | ||
@import 'abstracts/variables'; | ||
|
||
.m-file-select { | ||
&__hidden { | ||
@include m-visually-hidden; | ||
} | ||
} |
This file contains hidden or 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,79 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils'; | ||
import Vue, { VueConstructor } from 'vue'; | ||
|
||
import { addMessages } from '../../../tests/helpers/lang'; | ||
import { renderComponent } from '../../../tests/helpers/render'; | ||
import uuid from '../../utils/uuid/uuid'; | ||
import { MButton } from '../button/button'; | ||
import FileSelectPlugin, { MFileSelect } from './file-select'; | ||
|
||
jest.mock('../../utils/uuid/uuid'); | ||
(uuid.generate as jest.Mock).mockReturnValue('uuid'); | ||
|
||
describe('file-select', () => { | ||
let localVue: VueConstructor<Vue>; | ||
|
||
beforeEach(() => { | ||
localVue = createLocalVue(); | ||
localVue.use(FileSelectPlugin); | ||
addMessages(localVue, [ | ||
'components/file-select/file-select.lang.en.json', | ||
'components/validation-message/validation-message.lang.en.json' | ||
]); | ||
}); | ||
|
||
it('should render correctly', () => { | ||
const fileSelect = mount(MFileSelect, { | ||
localVue: localVue | ||
}); | ||
|
||
return expect( | ||
renderComponent(fileSelect.vm) | ||
).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
it('should flow down button props', () => { | ||
const buttonProps = { | ||
skin: 'primary', | ||
disabled: true, | ||
waiting: true, | ||
fullSize: true, | ||
iconName: 'icon-name', | ||
iconPosition: 'right', | ||
iconSize: '24px' | ||
}; | ||
|
||
const fileSelect = mount(MFileSelect, { | ||
localVue: localVue, | ||
propsData: buttonProps | ||
}); | ||
|
||
expect(fileSelect.find(MButton).props()).toEqual(buttonProps); | ||
}); | ||
|
||
it('should set multiple attribute on input based on prop value', () => { | ||
const fileSelect = mount(MFileSelect, { | ||
localVue: localVue | ||
}); | ||
|
||
fileSelect.setProps({ multiple: true }); | ||
expect(fileSelect.find('input').attributes()).toHaveProperty( | ||
'multiple' | ||
); | ||
|
||
fileSelect.setProps({ multiple: false }); | ||
expect(fileSelect.find('input').attributes()).not.toHaveProperty( | ||
'multiple' | ||
); | ||
}); | ||
|
||
it('should emit click event when button is clicked', () => { | ||
const fileSelect = mount(MFileSelect, { | ||
localVue: localVue | ||
}); | ||
|
||
fileSelect.find(MButton).trigger('click'); | ||
|
||
expect(fileSelect.emitted('click')).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
La mécanique de close des modals a évolué depuis... Est-ce qu'on a validé que ça fonctionnait bien dans le cas où le téléverseur pop à partir d'une fenêtre modale? Et surtout que la fermeture s'effectue correctement lorsqu'on clique sur le backdrop par exemple.
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.
J'ai testé le téléverser dans une fenêtre modale et ça fonctionne. Pour le clic sur l'arrière-plan, j'ai mis l'option à false, je vais valider si c'est un comportement qu'on souhaite.