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

feat(information): migrate to HTML content #1463

Closed
wants to merge 1 commit into from

Conversation

m-maillot
Copy link
Contributor

No description provided.

Copy link

sonarcloud bot commented Aug 29, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
81.9% Duplication on New Code (required ≤ 15%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

rowCount: number;
};

export const EnhancedTableHead = <T extends Data>({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Création d'un tableau générique permettant d'afficher la liste des documents, d'en sélectionner et de publier.
C'est un composant générique graphique mais avec également une partie publication qui est commune aux différents contenu. Cette partie affiche une modale avec les contenus sélectionnés et permet de les publier et de suivre l'avancement de l'opération.
Son principal objectif dans un premier temps est de nous permettre de republier des contenus après des migrations de contenu.

Par la suite, on pourra ajouter un bouton pour supprimer. Ajouter le suivi des statuts et principalement celui de savoir si le contenu est publié et dispo en prod, à publier (version en attente de publication)...

Copy link
Member

Choose a reason for hiding this comment

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

Ok top, j'aurai juste nommé le fichier composant EnhancedTableHead au lieu de Head

@@ -11,13 +11,12 @@ import React from "react";
import { useAgreementUpdateMutation } from "./agreement.mutation";
import { useAgreementQuery } from "./agreement.query";
import { AgreementForm } from "../Common";
import { usePublishMutation } from "./publish.mutation";
import { usePublishMutation } from "../../../documents/components/publish.mutation";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

J'ai homogénéisé le usePublicationMutation pour en avoir un seul dans documents. Ca évite de devoir modifier X graphQL quand on veut modifier l'API...

Copy link
Member

Choose a reason for hiding this comment

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

coool

};

return (
<FormControl sx={{ width: 200, marginX: "8px" }} size="small">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ce composant est une amélioration du filtre sur les conventions collectives. Avant on avait un switch, maintenant on a une liste à choix multiple. Plus simple à comprendre et plus jolie.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avant :
CleanShot 2024-08-29 at 14 03 23@2x

Après :

CleanShot 2024-08-29 at 14 04 05@2x

color="success"
onClick={() => {
router.push("/agreements/creation");
<EnhancedTable<AgreementData>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ici, on remplace le code répété pour chaque contenu qui affiche les documents dans un tableau. On remplace par le composant EnhancedTable.

Ce composant prend la source pour faire automatiquement le publish.
Il va ensuite prendre des headCells qui sont les différentes colonnes. Pour chaque colonne, on indique la donnée dans l'objet à afficher et on peut customiser le render si besoin.
On a ensuite rows qui contient le contenu du tableau donc ici les conventions collectives.
On a ensuite les onClick permettant de rediriger.
Le setSearch qui permet d'appliquer la recherche
Et pour finir le customFilters qui permet d'ajouter des filtres spécifiques (comme ici sur les CCs traitées vs non traitées).

Copy link
Member

Choose a reason for hiding this comment

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

Sympa le generic pour bien typer

@@ -10,8 +10,7 @@ export const listAgreementsQuery = gql`
agreements: agreement_agreements(
order_by: { id: asc }
where: {
id: { _ilike: $idcc }
name: { _ilike: $keyword }
_or: [{ id: { _ilike: $idcc } }, { shortName: { _ilike: $keyword } }]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Petite amélioration sur la recherche dans les CCs. Au lieu d'avoir deux champs, un pour filtrer sur l'idcc et un autre sur le nom, on a un seul champ et on filtre sur les deux.

Copy link
Member

Choose a reason for hiding this comment

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

nice ;)

props: PublishProps
) => Promise<OperationResult<Result>>;

export const usePublishMutation = (): PublishMutationResult => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ici c'est le usePublishMutation générique que l'on réutilise ensuite. Ca permet d'avoir qu'une requête graphQL écrite pour publier dans le code (comme la fonction est générique, c'est plus simple de le faire comme ça).

@@ -21,14 +21,11 @@ export const InformationsBlockText = ({
spacing={2}
>
<FormControl>
<FormTextField
<FormEditionField
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ce qui nous intéresse dans cette PR :)
J'ai remplacé par le composant tiptap pour éditer une page info.

@@ -48,7 +48,7 @@ export const mapInformationToDocument = async (
blocks: await Promise.all(
blocks.map(async (block) => {
const htmlWithGlossary = await getGlossaryContent(
"markdown",
"html",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a maintenant du html en entrée :)

@@ -4,6 +4,7 @@ actions:
kind: synchronous
handler: '{{API_URL}}/actions/publish'
forward_client_headers: true
timeout: 180
Copy link
Contributor Author

Choose a reason for hiding this comment

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

J'ai monté le timeout du publish car en local j'avais des pages infos qui prenaient trop de temps.

Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -0,0 +1,1500 @@
UPDATE information.informations_contents_blocks
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Là on migre les données en markdown en html. Il faudra vérifier qu'aucune page info n'a été mise à jour au moment de merge et release la feature.

Copy link
Member

@maxgfr maxgfr left a comment

Choose a reason for hiding this comment

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

top gg! j'ai juste lu le code mais pas recetté pour info

rowCount: number;
};

export const EnhancedTableHead = <T extends Data>({
Copy link
Member

Choose a reason for hiding this comment

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

Ok top, j'aurai juste nommé le fichier composant EnhancedTableHead au lieu de Head

@@ -11,13 +11,12 @@ import React from "react";
import { useAgreementUpdateMutation } from "./agreement.mutation";
import { useAgreementQuery } from "./agreement.query";
import { AgreementForm } from "../Common";
import { usePublishMutation } from "./publish.mutation";
import { usePublishMutation } from "../../../documents/components/publish.mutation";
Copy link
Member

Choose a reason for hiding this comment

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

coool

color="success"
onClick={() => {
router.push("/agreements/creation");
<EnhancedTable<AgreementData>
Copy link
Member

Choose a reason for hiding this comment

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

Sympa le generic pour bien typer

Comment on lines +40 to +44
{value ? (
<Tooltip title="Convention collective traitée par le CDTN">
<GavelIcon fontSize="small" />
</Tooltip>
) : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{value ? (
<Tooltip title="Convention collective traitée par le CDTN">
<GavelIcon fontSize="small" />
</Tooltip>
) : undefined}
{value && (
<Tooltip title="Convention collective traitée par le CDTN">
<GavelIcon fontSize="small" />
</Tooltip>
)}

@@ -10,8 +10,7 @@ export const listAgreementsQuery = gql`
agreements: agreement_agreements(
order_by: { id: asc }
where: {
id: { _ilike: $idcc }
name: { _ilike: $keyword }
_or: [{ id: { _ilike: $idcc } }, { shortName: { _ilike: $keyword } }]
Copy link
Member

Choose a reason for hiding this comment

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

nice ;)

Copy link
Member

Choose a reason for hiding this comment

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

👌

@@ -4,6 +4,7 @@ actions:
kind: synchronous
handler: '{{API_URL}}/actions/publish'
forward_client_headers: true
timeout: 180
Copy link
Member

Choose a reason for hiding this comment

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

+1

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.

4 participants