Skip to content

Commit

Permalink
[frontend] Fix remaining button when fab is not replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Sep 17, 2024
1 parent e965f3b commit 558e6c1
Show file tree
Hide file tree
Showing 29 changed files with 157 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ExternalReferenceComponentProps
<ExternalReferenceHeader
externalReference={externalReference}
PopoverComponent={
<ExternalReferencePopover id={''} handleRemove={undefined} />
<ExternalReferencePopover id={externalReference.id} handleRemove={undefined} />
}
EditComponent={(
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<ExternalReferenceEdition externalReferenceId={externalReference.id} />
</Security>
Expand All @@ -62,42 +62,41 @@ ExternalReferenceComponentProps
spacing={3}
classes={{ container: classes.gridContainer }}
>
{
overviewLayoutCustomization.map(({ key, width }) => {
switch (key) {
case 'basicInformation':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceOverview externalReference={externalReference} />
</Grid>
);
case 'details':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceDetails externalReference={externalReference} />
</Grid>
);
case 'linkedObjects':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceStixCoreObjects
externalReference={externalReference}
/>
</Grid>
);
case 'uploadedFiles':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceFileImportViewer
externalReference={externalReference}
connectorsImport={connectorsImport}
/>
</Grid>
);
default:
return null;
}
})
{overviewLayoutCustomization.map(({ key, width }) => {
switch (key) {
case 'basicInformation':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceOverview externalReference={externalReference} />
</Grid>
);
case 'details':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceDetails externalReference={externalReference} />
</Grid>
);
case 'linkedObjects':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceStixCoreObjects
externalReference={externalReference}
/>
</Grid>
);
case 'uploadedFiles':
return (
<Grid key={key} item xs={width}>
<ExternalReferenceFileImportViewer
externalReference={externalReference}
connectorsImport={connectorsImport}
/>
</Grid>
);
default:
return null;
}
})
}
</Grid>
{!isFABReplaced && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const useStyles = makeStyles(() => ({
interface ExternalReferenceHeaderComponentProps {
externalReference: ExternalReferenceHeader_externalReference$data;
PopoverComponent: ReactElement<{ id: string }>;
EditComponent?: React.JSX.Element;
EditComponent?: React.JSX.Element | boolean;
}

const ExternalReferenceHeaderComponent: FunctionComponent<ExternalReferenceHeaderComponentProps> = ({ externalReference, PopoverComponent, EditComponent }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default createFragmentContainer(GroupingComponent, {
}
}
workflowEnabled
currentUserAccessRight
...GroupingDetails_grouping
...ContainerHeader_container
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const GroupingEditionContainer = (props) => {

const { handleClose, grouping, open, controlledDial } = props;
const { editContext } = grouping;

return (
<Drawer
title={t_i18n('Update a grouping')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE, KNOWLEDGE_KNUPDATE }
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import GroupingEdition from './GroupingEdition';
import { useGetCurrentUserAccessRight } from '../../../../utils/authorizedMembers';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootGroupingSubscription($id: ID!) {
Expand Down Expand Up @@ -89,6 +90,8 @@ const RootGrouping = () => {
[groupingId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Grouping') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand All @@ -115,8 +118,10 @@ const RootGrouping = () => {
/>
<ContainerHeader
container={grouping}
PopoverComponent={<GroupingPopover />}
EditComponent={(
PopoverComponent={
<GroupingPopover id={groupingId} />
}
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
<GroupingEdition groupingId={grouping.id} />
</Security>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Breadcrumbs from '../../../../components/Breadcrumbs';
import { getMainRepresentative } from '../../../../utils/defaultRepresentatives';
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import MalwareAnalysisEdition from './MalwareAnalysisEdition';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootMalwareAnalysisSubscription($id: ID!) {
Expand Down Expand Up @@ -79,6 +80,8 @@ const RootMalwareAnalysis = () => {
[malwareAnalysisId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const { t_i18n } = useFormatter();
useSubscription(subConfig);
const link = `/dashboard/analyses/malware_analyses/${malwareAnalysisId}/knowledge`;
Expand Down Expand Up @@ -106,7 +109,7 @@ const RootMalwareAnalysis = () => {
PopoverComponent={
<MalwareAnalysisPopover id={malwareAnalysisId} />
}
EditComponent={(
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<MalwareAnalysisEdition malwareAnalysisId={malwareAnalysis.id} />
</Security>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ const RootVulnerability = ({ queryRef, vulnerabilityId }: RootVulnerabilityProps
<StixDomainObjectHeader
entityType="Vulnerability"
stixDomainObject={vulnerability}
PopoverComponent={<VulnerabilityPopover />}
PopoverComponent={<VulnerabilityPopover id={vulnerabilityId} />}
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<VulnerabilityEdition vulnerabilityId={vulnerability.id} />
<VulnerabilityEdition vulnerabilityId={vulnerabilityId} />
</Security>
)}
enableQuickSubscription={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE, KNOWLEDGE_KNUPDATE }
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import CaseIncidentEdition from './CaseIncidentEdition';
import { useGetCurrentUserAccessRight } from '../../../../utils/authorizedMembers';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootIncidentCaseSubscription($id: ID!) {
Expand Down Expand Up @@ -89,6 +90,8 @@ const RootCaseIncidentComponent = ({ queryRef, caseId }) => {
[caseId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Case-Incident') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand Down Expand Up @@ -116,11 +119,11 @@ const RootCaseIncidentComponent = ({ queryRef, caseId }) => {
<ContainerHeader
container={caseData}
PopoverComponent={<CaseIncidentPopover id={caseData.id} />}
EditComponent={
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
<CaseIncidentEdition caseId={caseData.id} />
</Security>
}
)}
enableQuickSubscription={true}
enableAskAi={true}
redirectToContent={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE, KNOWLEDGE_KNUPDATE }
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import CaseRfiEdition from './CaseRfiEdition';
import { useGetCurrentUserAccessRight } from '../../../../utils/authorizedMembers';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootCaseRfiCaseSubscription($id: ID!) {
Expand Down Expand Up @@ -86,6 +87,8 @@ const RootCaseRfiComponent = ({ queryRef, caseId }) => {
[caseId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Case-Rfi') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand All @@ -111,9 +114,11 @@ const RootCaseRfiComponent = ({ queryRef, caseId }) => {
<ContainerHeader
container={caseData}
PopoverComponent={<CaseRfiPopover id={caseData.id} />}
EditComponent={<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
<CaseRfiEdition caseId={caseData.id} />
</Security>}
</Security>
)}
enableQuickSubscription={true}
enableAskAi={true}
redirectToContent={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE, KNOWLEDGE_KNUPDATE }
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import CaseRftEdition from './CaseRftEdition';
import { useGetCurrentUserAccessRight } from '../../../../utils/authorizedMembers';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootCaseRftCaseSubscription($id: ID!) {
Expand Down Expand Up @@ -85,6 +86,8 @@ const RootCaseRftComponent = ({ queryRef, caseId }) => {
[caseId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Case-Rft') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand All @@ -110,9 +113,11 @@ const RootCaseRftComponent = ({ queryRef, caseId }) => {
<ContainerHeader
container={caseData}
PopoverComponent={<CaseRftPopover id={caseData.id} />}
EditComponent={<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={currentAccessRight.canEdit}>
<CaseRftEdition caseId={caseData.id} />
</Security>}
</Security>
)}
enableQuickSubscription={true}
enableAskAi={true}
redirectToContent={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE } from '../../../../ut
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import FeedbackEdition from './FeedbackEdition';
import { useGetCurrentUserAccessRight } from '../../../../utils/authorizedMembers';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootFeedbackSubscription($id: ID!) {
Expand Down Expand Up @@ -91,6 +92,8 @@ const RootFeedbackComponent = ({ queryRef, caseId }) => {
[caseId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Feedback') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand All @@ -116,9 +119,11 @@ const RootFeedbackComponent = ({ queryRef, caseId }) => {
<ContainerHeader
container={feedbackData}
PopoverComponent={<FeedbackPopover id={feedbackData.id} />}
EditComponent={<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={canEdit}>
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]} hasAccess={canEdit}>
<FeedbackEdition feedbackId={feedbackData.id} />
</Security>}
</Security>
)}
enableSuggestions={false}
disableSharing={true}
enableQuickSubscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useIsEnforceReference } from '../../../../utils/hooks/useEntitySettings
import useGranted, { KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE } from '../../../../utils/hooks/useGranted';
import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import TaskEdition from './TaskEdition';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootTaskSubscription($id: ID!) {
Expand Down Expand Up @@ -75,6 +76,8 @@ const RootTaskComponent = ({ queryRef, taskId }) => {
[taskId],
);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const enableReferences = useIsEnforceReference('Task') && !useGranted([KNOWLEDGE_KNUPDATE_KNBYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);
Expand All @@ -97,9 +100,11 @@ const RootTaskComponent = ({ queryRef, taskId }) => {
<ContainerHeader
container={data}
PopoverComponent={<TasksPopover id={data.id} />}
EditComponent={<Security needs={[KNOWLEDGE_KNUPDATE]}>
<TaskEdition caseId={data.id} />
</Security>}
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<TaskEdition caseId={data.id} />
</Security>
)}
enableSuggestions={false}
redirectToContent={true}
disableAuthorizedMembers={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import Security from '../../../../utils/Security';
import { KNOWLEDGE_KNUPDATE } from '../../../../utils/hooks/useGranted';
import EventEdition from './EventEdition';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootEventsSubscription($id: ID!) {
Expand Down Expand Up @@ -83,6 +84,8 @@ const RootEvent = ({ eventId, queryRef }: RootEventProps) => {
}), [eventId]);

const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');
const { t_i18n } = useFormatter();
useSubscription<RootEventsSubscription>(subConfig);

Expand Down Expand Up @@ -135,7 +138,7 @@ const RootEvent = ({ eventId, queryRef }: RootEventProps) => {
stixDomainObject={event}
enableQuickSubscription={true}
PopoverComponent={<EventPopover />}
EditComponent={(
EditComponent={isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<EventEdition eventId={event.id} />
</Security>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { getCurrentTab, getPaddingRight } from '../../../../utils/utils';
import IndividualEdition from './IndividualEdition';
import Security from '../../../../utils/Security';
import { KNOWLEDGE_KNUPDATE } from '../../../../utils/hooks/useGranted';
import useHelper from '../../../../utils/hooks/useHelper';

const subscription = graphql`
subscription RootIndividualsSubscription($id: ID!) {
Expand Down Expand Up @@ -87,6 +88,9 @@ const RootIndividual = ({ individualId, queryRef }: RootIndividualProps) => {
variables: { id: individualId },
}), [individualId]);
const location = useLocation();
const { isFeatureEnable } = useHelper();
const isFABReplaced = isFeatureEnable('FAB_REPLACEMENT');

const navigate = useNavigate();
const LOCAL_STORAGE_KEY = `individual-${individualId}`;
const params = buildViewParamsFromUrlAndStorage(
Expand Down Expand Up @@ -169,7 +173,7 @@ const RootIndividual = ({ individualId, queryRef }: RootIndividualProps) => {
isOpenctiAlias={true}
enableQuickSubscription={true}
PopoverComponent={<IndividualPopover />}
EditComponent={!individual.isUser && (
EditComponent={!individual.isUser && isFABReplaced && (
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<IndividualEdition individualId={individual.id} />
</Security>
Expand Down
Loading

0 comments on commit 558e6c1

Please sign in to comment.