stable

Clone or download

Read-only

feat: Introduce PUT artidoc/:id/sections

This allows to set the sections of an artidoc document. Payload looks like the following: ``` { "sections": [ {"artifact": { "id": 324845}}, {"artifact": { "id": 324844}} ] } ``` The new section order follows the submitted order (in this example: `[324845, 324844]`) With the following payload, the document becomes empty: ``` { "sections": [] } ``` If one of the artifact is not readable by the current user, then the update is rejected. This includes also its title and description since user cannot read such document. If user does not have write permissions on the document, then the update is rejected. Implementation note: The payload is not a simple array of ids, because we don't know yet if they will contain other things than artifacts (free text for example). So in order to limit the BC of the route we have to indicate that the id we are refering to is an artifact (this follows the GET counterpart by the way). We don't have any possibility to create an artidoc document, so this is not tested yet. REST tests will come in a dedicated contribution. (Took the opportunity to fix psalm issue in ArtidocRetriever and RawSectionsToRepresentationTransformer) Part of story #37542: display a read only Document Change-Id: I0744d4da56db41275a2123e421fc1762bc308c65

Modified Files

Name
M plugins/artidoc/include/Artidoc/Document/ArtidocDao.php +21 −1 Go to diff View file
M plugins/artidoc/include/Artidoc/Document/ArtidocRetriever.php +1 −1 Go to diff View file
A plugins/artidoc/include/Artidoc/Document/SaveSections.php +26 −0 Go to diff View file
A plugins/artidoc/include/Artidoc/REST/v1/ArtidocPUTSectionArtifactRepresentation.php +36 −0 Go to diff View file
A plugins/artidoc/include/Artidoc/REST/v1/ArtidocPUTSectionRepresentation.php +36 −0 Go to diff View file
M plugins/artidoc/include/Artidoc/REST/v1/ArtidocResource.php +65 −1 Go to diff View file
A plugins/artidoc/include/Artidoc/REST/v1/PUTSectionsHandler.php +103 −0 Go to diff View file
M plugins/artidoc/include/Artidoc/REST/v1/RawSectionsToRepresentationTransformer.php +3 −2 Go to diff View file
A plugins/artidoc/include/Artidoc/REST/v1/UserCannotReadSectionFault.php +36 −0 Go to diff View file
M plugins/artidoc/site-content/fr_FR/LC_MESSAGES/tuleap-artidoc.po +7 −0 Go to diff View file
M plugins/artidoc/tests/integration/Artidoc/Document/ArtidocDaoTest.php +40 −19 Go to diff View file
M plugins/artidoc/tests/rest/Artidoc/ArtidocTest.php +1 −1 Go to diff View file
A plugins/artidoc/tests/unit/Artidoc/REST/v1/PUTSectionsHandlerTest.php +189 −0 Go to diff View file
A plugins/artidoc/tests/unit/Artidoc/Stubs/Document/SaveSectionsStub.php +57 −0 Go to diff View file