From 497ca078f9a462b0109940825ac30fcd99b03d77 Mon Sep 17 00:00:00 2001
From: Landry Trebon <33682259+lndrtrbn@users.noreply.github.com>
Date: Thu, 21 Nov 2024 10:08:16 +0100
Subject: [PATCH] [frontend] fix download files + some css issues (#9099)
---
.../StixCoreObjectContent.jsx | 2 +-
.../StixCoreObjectContentFilesList.tsx | 50 ++++++++++++-------
.../StixCoreObjectSubscribers.tsx | 6 ++-
3 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx
index 1eb60d4c3233..d55c453b1efd 100644
--- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx
+++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContent.jsx
@@ -456,7 +456,7 @@ class StixCoreObjectContentComponent extends Component {
&& [...files, ...exportFiles, ...contentsFromTemplate].find((n) => n.id === currentFileId);
const currentFileType = currentFile && currentFile.metaData.mimetype;
const { innerHeight } = window;
- const height = innerHeight - 300;
+ const height = innerHeight - 320;
const isContentCompatible = isContainerWithContent(stixCoreObject.entity_type);
return (
diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContentFilesList.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContentFilesList.tsx
index ba994698b347..9975ebca32a4 100644
--- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContentFilesList.tsx
+++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectContentFilesList.tsx
@@ -64,15 +64,20 @@ const StixCoreObjectContentFilesList = ({
const [deleting, setDeleting] = useState(null);
const [anchorEl, setAnchorEl] = useState(null);
- const openPopover = (e: MouseEvent) => {
+ const [menuFile, setMenuFile] = useState(null);
+ const openPopover = (e: MouseEvent, file: ContentFile) => {
e.stopPropagation();
setAnchorEl(e.currentTarget);
+ setMenuFile(file);
+ };
+ const closePopover = () => {
+ setAnchorEl(null);
+ setMenuFile(null);
};
const [commitDelete] = useApiMutation(deleteMutation);
-
const submitDelete = (fileId: string) => {
- setAnchorEl(null);
+ closePopover();
setDeleting(fileId);
commitDelete({
variables: { fileName: fileId },
@@ -84,7 +89,7 @@ const StixCoreObjectContentFilesList = ({
};
const downloadPdf = async (file: ContentFile) => {
- setAnchorEl(null);
+ closePopover();
const { id } = file;
const url = `${APP_BASE_PATH}/storage/view/${encodeURIComponent(id)}`;
@@ -132,7 +137,7 @@ const StixCoreObjectContentFilesList = ({
/>
openPopover(e, file)}
aria-haspopup="true"
color="primary"
size="small"
@@ -142,29 +147,36 @@ const StixCoreObjectContentFilesList = ({
-
);
};
diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectSubscribers.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectSubscribers.tsx
index 4b838921b229..37d650a730ce 100644
--- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectSubscribers.tsx
+++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectSubscribers.tsx
@@ -59,7 +59,11 @@ const StixCoreObjectSubscribers: FunctionComponent =
size="small"
variant="text"
color={hasSetAccess ? 'primary' : 'inherit'}
- style={{ cursor: hasSetAccess && triggersKnowledgeCount && triggersKnowledgeCount > 0 ? 'pointer' : 'default', marginRight: 10 }}
+ style={{
+ cursor: hasSetAccess && triggersKnowledgeCount && triggersKnowledgeCount > 0 ? 'pointer' : 'default',
+ marginRight: 10,
+ whiteSpace: 'nowrap',
+ }}
sx={!hasSetAccess ? {
'&.MuiButtonBase-root:hover': {
bgcolor: 'transparent',