-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add a ressource to an item (see #142). #598
Conversation
36e4226
to
3f1d108
Compare
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.
Thank you for this important contribution.
Here are the few problems that should be fixed before integration.
Please also verify the coauthors mentioned in commits (they are not the same as in the pull request).
const myHeaders = new Headers(); | ||
myHeaders.append('Content-Type', file.type); | ||
myHeaders.append('credentials', 'include'); | ||
myHeaders.append('Authorization', 'Basic ' + Buffer.from('alice:whiterabbit').toString('base64')); |
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.
That shouldn't be hard-coded.
features/step_definitions/event.rb
Outdated
end | ||
|
||
Quand("l'utilisateur consulte la ressource {string}") do |string| | ||
# click_on 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.
Commenting out a line of code is considered as a bad practice.
@@ -0,0 +1,59 @@ | |||
import React, {useEffect, useState} from 'react'; | |||
// import Hypertopic from 'hypertopic'; |
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.
Commenting out a line of code is considered as a bad practice.
const [rev, setRev] = useState(''); | ||
const [uploadStatus, setUpload] = useState({ isUpload: false, message: '' }); | ||
|
||
// Post one file |
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.
If you think the name of the function is not clear enough, please change it instead of adding such a comment.
|
||
// Post one file | ||
const postFile = async (file, revision) => { | ||
// Gestion des headers pour la requête |
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.
If the comment is really needed for developpers, it should be translated in the same language of the code.
Soit "AXN 009" l'item affiché | ||
Et l'utilisateur est connecté | ||
Quand l'utilisateur dépose "favicon.ico" comme ressource | ||
Alors la ressource "favicon.ico" est ajoutée |
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 should test a state rather than an action. Please rephrase "est ajoutée".
Scénario: Consulter une ressource en tant que fichier | ||
|
||
Soit "AXN 009" l'item affiché | ||
Et la ressource "favicon.ico" existe comme ressource |
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.
This is considered as a bad practice to make a test depend on the success of a previous test.
Either find a way to include the attachment in the test data. Or just remove this scenario (and the corresponding steps).
Alors la ressource "favicon.ico" est ajoutée | ||
|
||
|
||
Scénario: Consulter une ressource en tant que fichier |
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.
This is not really a different case of the feature. Please move it to the consultation of an item or just remove this scenario.
Fonctionnalité: Ajouter une ressource en tant que fichier | ||
|
||
|
||
Scénario: Ajouter une ressource en tant que fichier |
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.
The name of a scenario should correspond to a special case of the feature.
Duplicating the feature name just means that you should let the scenario title empty.
return ( | ||
<div> | ||
<div > | ||
<button className="inputFiles_Button" onClick={()=>document.getElementById('inputFiles').click() } >Ajouter une ressource </button> |
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.
Please use lingui.js to internationalize the label.
@@ -89,6 +90,11 @@ class Item extends Component { | |||
<div className="d-none d-sm-block">{this._getAttributeCreationForm()}</div> | |||
</div> | |||
{viewpoints} | |||
<div className="Ressources"> | |||
<h3 className="h4"><Trans>Ressources</Trans></h3> |
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.
Please use npm extract
to create the entry in the localization dictionaries and then translate it.
event.preventDefault(); | ||
const files = Array.from(event.target.files); | ||
let newRev = rev; | ||
for (const file 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.
const
? N'est-ce pas un peu contradictoire ?
for (const file of files) { | ||
let myHeaders = new Headers(); | ||
myHeaders.append('Content-Type', file.type); | ||
myHeaders.append('credentials', 'include'); |
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.
Que faites-vous ensuite de ces entêtes ?
newRev = result.rev; | ||
} | ||
if (!uploadStatus.message) { | ||
setUpload({ isUpload: true, message: 'Tous les fichiers ont bien été ajoutés' }); |
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.
Si vraiment vous voulez afficher un message, il faut le "localiser"...
Par contre, on peut se demander si c'est nécessaire, puisque le résultat doit normalement déjà se voir.
return await fetch(await service + itemId + '/' + file.name + '?rev=' + revision, | ||
{ method: 'PUT', body: file, headers: myHeaders}) | ||
.then(res => res.json()) | ||
.catch(() => setUpload({ isUpload: false, message: 'Une erreur est survenue' })); |
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.
"Localiser" le message.
Co-authored-by: corentinprp51 <[email protected]> Co-authored-by: Caramella-ICE <[email protected]>
Co-authored-by: corentinprp51 <[email protected]>
Co-authored-by: corentinprp51 <[email protected]>
Co-authored-by: corentinprp51 [email protected]
Co-authored-by: Caramella-ICE [email protected]
Content
Please describe your contribution here...
Checklist
Please check that your pull request is correct:
FEATURE
for a behaviour allowing a user to do something new,FIX
for a behaviour which has been changed in order to meet user’s expectations,SCENARIO
for examples showing a given behaviour,TEST
when it concerns an acceptance test of a given behaviour,PROCESS
for a change in the way the software is built, tested, deployed,DOC
when it concerns only internal documentation (however it is better to combine it with the contribution that required this documentation change),:
) with one space after and no space before,manage
),should
).(closes #xx)
if xx is a feature ticket (and the commit is a complete implementation),(fixes #xx)
if xx is a fix ticket (and the commit is a complete fix),(see #xx)
otherwise,