Skip to content

Commit 2f4500d

Browse files
committed
add snack warning
Signed-off-by: David BRAQUART <[email protected]>
1 parent 97ce8b7 commit 2f4500d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/components/directory-content-dialog.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function DirectoryContentDialog(
7373
) {
7474
const intl = useIntl();
7575
const dispatch = useDispatch();
76-
const { snackError } = useSnackMessage();
76+
const { snackError, snackWarning } = useSnackMessage();
7777
const itemSelectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
7878
const activeDirectory = useSelector((state: AppState) => state.activeDirectory);
7979
const enableDeveloperMode = useSelector((state: AppState) => state.enableDeveloperMode);
@@ -169,7 +169,8 @@ function DirectoryContentDialog(
169169
setOpenDescModificationDialog(true);
170170
} else if (childrenMetadata[event.data.elementUuid] !== undefined) {
171171
setActiveElement(event.data);
172-
setElementName(childrenMetadata[event.data.elementUuid].elementName);
172+
const childName = childrenMetadata[event.data.elementUuid].elementName;
173+
setElementName(childName);
173174
setElementDescription(childrenMetadata[event.data.elementUuid].description);
174175
const subtype = childrenMetadata[event.data.elementUuid].specificMetadata.type as unknown as string;
175176
/** set active directory on the store because it will be used while editing the contingency name */
@@ -180,6 +181,13 @@ function DirectoryContentDialog(
180181
if (url) {
181182
if (selectedDirectoryWritable) {
182183
window.open(url, '_blank');
184+
} else {
185+
snackWarning({
186+
messageTxt: intl.formatMessage(
187+
{ id: 'noWritePermissionOnStudy' },
188+
{ studyName: childName }
189+
),
190+
});
183191
}
184192
} else {
185193
snackError({
@@ -241,6 +249,7 @@ function DirectoryContentDialog(
241249
setActiveElement,
242250
setOpenDialog,
243251
snackError,
252+
snackWarning,
244253
]
245254
);
246255

@@ -251,7 +260,6 @@ function DirectoryContentDialog(
251260
description={activeElement.description}
252261
elementUuid={activeElement.elementUuid}
253262
onClose={handleDescDialogClose}
254-
// @ts-expect-error TODO: set UUID as parameter type in commons-ui
255263
updateElement={updateElement}
256264
/>
257265
);

src/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"retrieveCompositeModificationError": "Could not retrieve composite modification content: ",
122122
"PropertyName": "Property name",
123123
"getAppLinkError": "Error getting application link for type = {type}",
124+
"noWritePermissionOnStudy": "No write permission on the study \"{studyName}\"",
124125
"missingEquipmentsIdsError": "ID is required field for all equipments",
125126
"contingencyTablePartiallyDefinedError": "At least one contingency is partially defined",
126127
"contingencyTableContainAtLeastOneRowError": "Contingency list should contain at least one contingency ",

src/translations/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"retrieveCompositeModificationError": "Erreur d'accès au contenu de la modification composite : ",
121121
"PropertyName": "Nom de la propriété",
122122
"getAppLinkError": "Erreur lors de la récupération du lien vers l'application pour le type = {type}",
123+
"noWritePermissionOnStudy": "Pas de droits en écriture sur l'étude \"{studyName}\"",
123124
"missingEquipmentsIdsError": "L'ID est un champ obligatoire pour tous les ouvrages",
124125
"contingencyTablePartiallyDefinedError": "Au moins un des aléas est défini de manière incomplète",
125126
"contingencyTableContainAtLeastOneRowError": "La liste d'aléas doit contenir au moins un aléa",

0 commit comments

Comments
 (0)