-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE : Grant access to edit a document to a user (see #7)
Co-Authored-By: petitfa1 <115662302+petitfa1@users.noreply.github.com> Co-Authored-By: Barnabepetit <160789624+Barnabepetit@users.noreply.github.com>
- Loading branch information
1 parent
4aff075
commit 4b6757a
Showing
5 changed files
with
143 additions
and
21 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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
#language: fr | ||
|
||
Fonctionnalité: Essayer d'accorder les droits d'édition d'un document à un utilisateur | ||
Fonctionnalité: Essayer d'accorder à un utilisateur les droits d'édition d'un document | ||
|
||
Scénario: dont on est l'auteur | ||
Scénario: dont on est l'auteur | ||
|
||
Soit un document dont je suis l'auteur | ||
Soit un document dont je suis l'auteur affiché comme glose | ||
Et une session active avec mon compte | ||
Quand j'essaye d'accorder les droits d'édition à [Louis] | ||
Alors [Louis] peux modifier le document //modifier cette phrase | ||
|
||
Scénario: dont on n'est pas l'auteur | ||
Quand j'essaye d'accorder les droits d'édition à "bill" | ||
Alors "bill" peut modifier le document | ||
|
||
Soit un document dont je ne suis pas l'auteur | ||
Et une session active avec mon compte | ||
Quand j'essaye d'accorder les droits d'édition à [Louis] | ||
Alors [Louis] ne peux pas modifier le document | ||
Scénario: dont on n'est pas l'auteur | ||
|
||
Scénario: sans etre connecté | ||
Soit un document dont je ne suis pas l'auteur affiché comme glose | ||
Et une session active avec mon compte | ||
Quand j'essaye d'accorder les droits d'édition à "alice" | ||
Alors alice ne peut pas modifier le document | ||
|
||
Scénario: sans etre connecté | ||
|
||
Soit un document dont je suis l'auteur | ||
Et une session non active avec mon compte | ||
Quand j'essaye d'accorder les droits d'édition à [Louis] | ||
Alors [Louis] ne peux pas modifier le document | ||
Soit un document dont je suis l'auteur affiché comme glose | ||
Et une session active avec mon compte | ||
Quand j'essaye d'accorder les droits d'édition à "bill" | ||
Alors bill ne peut pas modifier le document |
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
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,78 @@ | ||
import Dropdown from 'react-bootstrap/Dropdown'; | ||
import {ThreeDotsVertical} from 'react-bootstrap-icons'; | ||
import {useEffect, useState} from 'react'; | ||
import {Button, InputGroup, ListGroup, Modal} from 'react-bootstrap'; | ||
import Form from 'react-bootstrap/Form'; | ||
|
||
export default function More({metadata, backend}) { | ||
const [show, setShow] = useState(false); | ||
const [userName, setUserName] = useState(''); | ||
const [loading, setLoading] = useState(false); | ||
const [document, setDocument] = useState(metadata); | ||
|
||
const handleClose = () => setShow(false); | ||
const handleShow = () => setShow(true); | ||
|
||
let addEditor = () => { | ||
if (!loading) { | ||
setLoading(true); | ||
const payload = {...document, editors: [...(document.editors ?? [])]}; | ||
const formattedUserName = userName.trim(); | ||
|
||
if (payload.editors.includes(formattedUserName) || formattedUserName === '') { | ||
setUserName(''); | ||
setLoading(false); | ||
return; | ||
} | ||
|
||
payload.editors.push(formattedUserName); | ||
|
||
backend.putDocument(payload).then(({rev}) => { | ||
payload._rev = rev; | ||
setDocument(payload); | ||
setUserName(''); | ||
setLoading(false); | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Dropdown className="float-end more-btn"> | ||
<Dropdown.Toggle variant="ghost"> | ||
<ThreeDotsVertical/> | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu> | ||
<Dropdown.Item as="button" onClick={handleShow} className="dropdown-item-share">Share</Dropdown.Item> | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
|
||
<Modal show={show} onHide={handleClose}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Invite user to edit document</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form.Label htmlFor="inputPassword5">Username</Form.Label> | ||
<InputGroup className="mb-3"> | ||
<Form.Control | ||
className="add-user-input" | ||
value={userName} | ||
onInput={(event) => setUserName(event.target.value)} | ||
/> | ||
<Button variant="primary" onClick={addEditor} className="add-user-input-btn"> | ||
Invite | ||
</Button> | ||
</InputGroup> | ||
</Modal.Body> | ||
<Modal.Body> | ||
<h5>Editors</h5> | ||
<ListGroup> | ||
{(document && document.editors ? document.editors : []).map((user) => ( | ||
<ListGroup.Item key={user}>{user}</ListGroup.Item> | ||
))} | ||
</ListGroup> | ||
</Modal.Body> | ||
</Modal> | ||
</> | ||
); | ||
} |
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