Skip to content

Commit 4619bca

Browse files
authored
do not allow copy when multiselection (#724)
* do not allow copy when multiselectied elements --------- Signed-off-by: SOUISSI Maissa (Externe)
1 parent f14f8b5 commit 4619bca

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/components/menus/content-contextual-menu.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
287287
);
288288

289289
const noCreationInProgress = useCallback(() => selectedElements.every((el) => el.hasMetadata), [selectedElements]);
290+
const isSingleElement = selectedElements.length === 1;
290291

291-
const allowsDuplicateAndCopy = useCallback(() => {
292+
const allowsDuplicate = useCallback(() => {
292293
const allowedTypes = [
293294
ElementType.CASE,
294295
ElementType.STUDY,
@@ -307,11 +308,10 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
307308
];
308309

309310
const hasMetadata = selectedElements[0]?.hasMetadata;
310-
const isSingleElement = selectedElements.length === 1;
311311
const isAllowedType = allowedTypes.includes(selectedElements[0]?.type);
312312

313313
return hasMetadata && isSingleElement && isAllowedType && directoryWritable;
314-
}, [selectedElements, directoryWritable]);
314+
}, [selectedElements, isSingleElement, directoryWritable]);
315315

316316
const allowsCreateNewStudyFromCase = useCallback(
317317
() =>
@@ -394,15 +394,15 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
394394
});
395395
}
396396

397-
if (allowsDuplicateAndCopy()) {
397+
if (allowsDuplicate()) {
398398
menuItems.push({
399399
messageDescriptorId: 'duplicate',
400400
callback: duplicateItem,
401401
icon: <FileCopyTwoToneIcon fontSize="small" data-testid="DuplicateIcon" />,
402402
});
403403
}
404404

405-
if (directoryReadable) {
405+
if (directoryReadable && isSingleElement) {
406406
menuItems.push({
407407
messageDescriptorId: 'copy',
408408
callback: copyItem,
@@ -462,30 +462,31 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
462462

463463
if (menuItems.length === 0) {
464464
menuItems.push({
465-
messageDescriptorId: noCreationInProgress() ? 'notElementCreator' : 'elementCreationInProgress',
465+
messageDescriptorId: noCreationInProgress() ? 'noActionAvailable' : 'elementCreationInProgress',
466466
icon: <DoNotDisturbAltIcon fontSize="small" />,
467467
disabled: true,
468468
});
469469
}
470470

471471
return menuItems;
472472
}, [
473-
allowsConvertFilterIntoExplicitNaming,
473+
selectedElements,
474+
directoryWritable,
474475
allowsCreateNewStudyFromCase,
476+
allowsDuplicate,
477+
directoryReadable,
478+
isSingleElement,
475479
allowsDownload,
480+
enableDeveloperMode,
481+
allowsExportCase,
476482
allowsSpreadsheetCollection,
477-
allowsDuplicateAndCopy,
483+
allowsConvertFilterIntoExplicitNaming,
484+
handleOpenDialog,
485+
duplicateItem,
478486
copyItem,
479487
downloadElements,
480-
duplicateItem,
481488
handleCloseDialog,
482-
handleOpenDialog,
483489
noCreationInProgress,
484-
selectedElements,
485-
directoryReadable,
486-
directoryWritable,
487-
allowsExportCase,
488-
enableDeveloperMode,
489490
]);
490491

491492
const renderDialog = () => {

src/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"moveElementNotFoundError": "The element or the targeted folder was not found",
126126
"moveElementNotAllowedError": "You cannot move this element to the targeted folder. Unauthorized action",
127127
"moveNameConflictError": "An element with the same name already exists in the target folder.",
128-
"notElementCreator": "You are not the element's creator",
128+
"noActionAvailable": "No action available",
129129
"elementCreationInProgress": "Creation in progress: no operation permitted",
130130
"serverConnectionFailed": "Failed to connect to server. Please retry later.",
131131
"invalidFormatOrName": "Imported file name or format invalid",

src/translations/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"moveElementNotFoundError": "L'élément ou le dossier cible n'a pas été trouvé",
125125
"moveElementNotAllowedError": "Vous ne pouvez pas déplacer cet élément dans le dossier cible. Action non autorisée",
126126
"moveNameConflictError": "Un élément avec le même nom existe déjà dans le dossier cible.",
127-
"notElementCreator": "Vous n'êtes pas le créateur de l'élément",
127+
"noActionAvailable": "Aucune action disponible",
128128
"elementCreationInProgress": "Création en cours : pas d'opération autorisée",
129129
"serverConnectionFailed": "Échec de connexion avec le serveur. Veuillez réessayer ultérieurement",
130130
"invalidFormatOrName": "Format ou nom du fichier importé non valide",

0 commit comments

Comments
 (0)