Skip to content

Commit

Permalink
ok on build action (todo: on study opening)
Browse files Browse the repository at this point in the history
Signed-off-by: David BRAQUART <[email protected]>
  • Loading branch information
dbraquart committed Jul 15, 2024
1 parent 9ac12a7 commit 17b7b81
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/network-modification-tree-pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ const noSelectionForCopy = {
copyType: null,
allChilddrenIds: null,
};

const HTTP_MAX_NODE_BUILDS_EXCEEDED_MESSAGE = 'MAX_NODE_BUILDS_EXCEEDED';

export const NetworkModificationTreePane = ({
studyUuid,
studyMapTreeDisplay,
Expand Down Expand Up @@ -498,10 +501,24 @@ export const NetworkModificationTreePane = ({
const handleBuildNode = useCallback(
(element) => {
buildNode(studyUuid, element.id).catch((error) => {
snackError({
messageTxt: error.message,
headerId: 'NodeBuildingError',
});
if (
error.status === 403 &&
error.message.includes(
HTTP_MAX_NODE_BUILDS_EXCEEDED_MESSAGE
)
) {
// retrieve last word of the message (ex: "MAX_NODE_BUILDS_EXCEEDED max allowed built nodes : 2" -> 2)
let limit = error.message.split(/[: ]+/).pop();
snackError({
messageId: 'maxBuiltNodeExceededError',
messageValues: { limit: limit },
});
} else {
snackError({
messageTxt: error.message,
headerId: 'NodeBuildingError',
});
}
});
},
[studyUuid, snackError]
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@
"Optional": " (optional)",
"loadingOptions": "Loading...",
"buildNode": "Build node",
"maxBuiltNodeExceededError": "You have reached your user quota for built nodes number. Please unbuild some nodes in the current study in order to go below the limit of {limit} builds",
"createNetworkModificationNode": "Create a new node",
"createNetworkModificationNodeInNewBranch": "in a new branch",
"pasteNetworkModificationNodeInNewBranch": "in a new branch",
Expand Down
1 change: 1 addition & 0 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
"Optional": " (optionnel)",
"loadingOptions": "Chargement...",
"buildNode": "Réaliser le nœud",
"maxBuiltNodeExceededError": "Vous avez atteint votre quota utilisateur en termes de noeuds réalisés. Merci de supprimer des réalisations dans cette étude afin de redescendre sous le seuil de {limit} réalisations.",
"createNetworkModificationNode": "Créer un nouveau nœud",
"createNetworkModificationNodeInNewBranch": "dans une nouvelle branche",
"pasteNetworkModificationNodeInNewBranch": "dans une nouvelle branche",
Expand Down

0 comments on commit 17b7b81

Please sign in to comment.