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

Add a ressource to an item (see #142). #598

Merged
merged 3 commits into from
Jun 3, 2022

Conversation

dylanbonelli
Copy link
Contributor

@dylanbonelli dylanbonelli commented May 12, 2022

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:

  • Each commit:
    • corresponds to a contribution that should be notified to users,
    • does not generate new errors or warnings at compile or test time,
    • must be attributed to its real authors (with correct GitHub IDs and correct syntax for multiple authors).
  • The title of a commit should:
    • begin with a contribution type
      • 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),
    • be followed by a colon (:) with one space after and no space before,
    • be followed by a title (written in English) as short, as user-centered and as explicit as possible
      • If it is a feature, the title must be the user action (beginning with a verb, and please not manage),
      • If it is a fix, the title must describe the intended behavior (with should).
    • ends with a reference to the corresponding ticket with the following syntax:
      • (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,
  • Each committed line is:
    • useful (it would not work if removed)
      • if it is a comment line, its information could not be conveyed by better variables and function naming, better code structuring, or better commit message,
    • related to this very contribution (feature, fix...),
    • in English (with the exception of Gherkin scenarios in French and resulting steps),
    • without any typo in variable, class or function names,
    • correctly indented (spaces rather than tabs, same number of characters as in the rest of the file).

@dylanbonelli dylanbonelli force-pushed the feature-142 branch 5 times, most recently from 36e4226 to 3f1d108 Compare May 19, 2022 15:11
@dylanbonelli dylanbonelli marked this pull request as ready for review May 19, 2022 15:28
@corentinprp51 corentinprp51 requested a review from benel May 22, 2022 18:06
Copy link
Member

@benel benel left a 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'));
Copy link
Member

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.

end

Quand("l'utilisateur consulte la ressource {string}") do |string|
# click_on string
Copy link
Member

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';
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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) {
Copy link
Member

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');
Copy link
Member

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' });
Copy link
Member

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' }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Localiser" le message.

@benel benel merged commit f9f8b18 into Hypertopic:v7 Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants