Skip to content

Commit

Permalink
[frontend] Hide actions in Data tab according to capability (#8243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Dec 12, 2024
1 parent e8033b0 commit 0d9bdb8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ ExternalReferenceFileImportViewerBaseProps
}
}}
size={undefined}
placeholderIfNoRights={<div style={{ height: 47 }}/>}
/>
</div>
<div className="clearfix" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import * as R from 'ramda';
import { createFragmentContainer, graphql } from 'react-relay';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
Expand Down Expand Up @@ -27,10 +26,8 @@ const useStyles = makeStyles((theme) => ({
const ExternalReferenceStixCoreObjectsComponent = ({ externalReference }) => {
const classes = useStyles();
const { t_i18n } = useFormatter();
const stixCoreObjects = R.map(
(n) => n?.node,
externalReference.references?.edges ?? [],
);
const stixCoreObjects = (externalReference.references?.edges ?? [])
.map((n) => n?.node);
return (
<div style={{ height: '100%' }}>
<Typography variant="h4" gutterBottom={true}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent, useRef, useState } from 'react';
import React, { FunctionComponent, ReactElement, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { graphql } from 'react-relay';
import { CloudUploadOutlined } from '@mui/icons-material';
Expand Down Expand Up @@ -50,6 +50,7 @@ interface FileUploaderProps {
accept?: string;
size: 'small' | 'large' | 'medium' | undefined;
nameInCallback?: boolean;
placeholderIfNoRights?: ReactElement;
}

const FileUploader: FunctionComponent<FileUploaderProps> = ({
Expand All @@ -58,6 +59,7 @@ const FileUploader: FunctionComponent<FileUploaderProps> = ({
accept,
size,
nameInCallback,
placeholderIfNoRights = <span />,
}) => {
const { t_i18n } = useFormatter();
const uploadRef = useRef<HTMLInputElement | null>(null);
Expand Down Expand Up @@ -116,7 +118,7 @@ const FileUploader: FunctionComponent<FileUploaderProps> = ({
const hasSelectedFile = !!selectedFile;

return (
<Security needs={[KNOWLEDGE_KNUPLOAD]}>
<Security needs={[KNOWLEDGE_KNUPLOAD]} placeholder={placeholderIfNoRights}>
<React.Fragment>
{accept ? (
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { TEN_SECONDS } from '../../../../../utils/Time';
import inject18n from '../../../../../components/i18n';
import WorkbenchFileLine from './WorkbenchFileLine';
import WorkbenchFileCreator from './WorkbenchFileCreator';
import { KNOWLEDGE_KNASKIMPORT, KNOWLEDGE_KNUPDATE } from "../../../../../utils/hooks/useGranted";
import Security from "../../../../../utils/Security";
import { KNOWLEDGE_KNASKIMPORT } from '../../../../../utils/hooks/useGranted';
import Security from '../../../../../utils/Security';

const interval$ = interval(TEN_SECONDS);

Expand Down Expand Up @@ -62,7 +62,7 @@ const WorkbenchFileViewerBase = ({
<Typography variant="h4" gutterBottom={true} style={{ float: 'left' }}>
{t('Analyst workbenches')}
</Typography>
<Security needs={[KNOWLEDGE_KNASKIMPORT]}>
<Security needs={[KNOWLEDGE_KNASKIMPORT]} placeholder={<div style={{ height: 22 }}/>}>
<IconButton
color="primary"
aria-label="Add"
Expand Down

0 comments on commit 0d9bdb8

Please sign in to comment.