Skip to content

Commit

Permalink
[frontend] Fixed tests and linted
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonsai8863 committed Apr 22, 2024
1 parent aa58485 commit c499cca
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FunctionComponent } from 'react';
import useHelper from 'src/utils/hooks/useHelper';
import ListLines from '../../../components/list_lines/ListLines';
import ExternalReferencesLines, { externalReferencesLinesQuery } from './external_references/ExternalReferencesLines';
import ExternalReferenceCreation from './external_references/ExternalReferenceCreation';
Expand All @@ -19,7 +20,6 @@ import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup } from '../../..
import { useFormatter } from '../../../components/i18n';
import ExportContextProvider from '../../../utils/ExportContextProvider';
import Breadcrumbs from '../../../components/Breadcrumbs';
import useHelper from 'src/utils/hooks/useHelper';

const LOCAL_STORAGE_KEY = 'externalReferences';

Expand Down Expand Up @@ -116,7 +116,7 @@ const ExternalReferences: FunctionComponent<ExternalReferencesProps> = () => {
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
entityTypes={['External-Reference']}
createButton={isFeatureEnable("FAB_REPLACEMENT") && <Security needs={[KNOWLEDGE_KNUPDATE]}>
createButton={isFeatureEnable('FAB_REPLACEMENT') && <Security needs={[KNOWLEDGE_KNUPDATE]}>
<ExternalReferenceCreation
paginationOptions={queryPaginationOptions}
openContextual={false}
Expand Down Expand Up @@ -168,8 +168,8 @@ const ExternalReferences: FunctionComponent<ExternalReferencesProps> = () => {
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Analyses') }, { label: t_i18n('External references'), current: true }]} />
{renderLines()}
{!isFeatureEnable("FAB_REPLACEMENT") &&
<Security needs={[KNOWLEDGE_KNUPDATE]}>
{!isFeatureEnable('FAB_REPLACEMENT')
&& <Security needs={[KNOWLEDGE_KNUPDATE]}>
<ExternalReferenceCreation
paginationOptions={queryPaginationOptions}
openContextual={false}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FunctionComponent } from 'react';
import useHelper from 'src/utils/hooks/useHelper';
import ListLines from '../../../components/list_lines/ListLines';
import GroupingsLines, { groupingsLinesQuery } from './groupings/GroupingsLines';
import GroupingCreation from './groupings/GroupingCreation';
Expand All @@ -16,7 +17,6 @@ import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup, useGetDefaultFi
import { useFormatter } from '../../../components/i18n';
import ExportContextProvider from '../../../utils/ExportContextProvider';
import Breadcrumbs from '../../../components/Breadcrumbs';
import useHelper from 'src/utils/hooks/useHelper';

const LOCAL_STORAGE_KEY = 'groupings';

Expand Down Expand Up @@ -149,7 +149,7 @@ const Groupings: FunctionComponent<GroupingsProps> = () => {
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
iconExtension={true}
createButton={isFeatureEnable("FAB_REPLACEMENT") && <Security needs={[KNOWLEDGE_KNUPDATE]}>
createButton={isFeatureEnable('FAB_REPLACEMENT') && <Security needs={[KNOWLEDGE_KNUPDATE]}>
<GroupingCreation paginationOptions={queryPaginationOptions} />
</Security>}
>
Expand Down Expand Up @@ -196,8 +196,8 @@ const Groupings: FunctionComponent<GroupingsProps> = () => {
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Analyses') }, { label: t_i18n('Groupings'), current: true }]} />
{renderLines()}
{!isFeatureEnable("FAB_REPLACEMENT") &&
<Security needs={[KNOWLEDGE_KNUPDATE]}>
{!isFeatureEnable('FAB_REPLACEMENT')
&& <Security needs={[KNOWLEDGE_KNUPDATE]}>
<GroupingCreation paginationOptions={queryPaginationOptions} />
</Security>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FunctionComponent } from 'react';
import useHelper from 'src/utils/hooks/useHelper';
import ListLines from '../../../components/list_lines/ListLines';
import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage';
import Security from '../../../utils/Security';
Expand All @@ -18,7 +19,6 @@ import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup } from '../../..
import { useFormatter } from '../../../components/i18n';
import ExportContextProvider from '../../../utils/ExportContextProvider';
import Breadcrumbs from '../../../components/Breadcrumbs';
import useHelper from 'src/utils/hooks/useHelper';

const LOCAL_STORAGE_KEY = 'malwareAnalyses';

Expand Down Expand Up @@ -131,7 +131,7 @@ const MalwareAnalyses: FunctionComponent = () => {
filters={filters}
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
createButton={isFeatureEnable("FAB_REPLACEMENT") && <Security needs={[KNOWLEDGE_KNUPDATE]}>
createButton={isFeatureEnable('FAB_REPLACEMENT') && <Security needs={[KNOWLEDGE_KNUPDATE]}>
<MalwareAnalysisCreation paginationOptions={queryPaginationOptions}/>
</Security>}
>
Expand Down Expand Up @@ -180,8 +180,8 @@ const MalwareAnalyses: FunctionComponent = () => {
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Analyses') }, { label: t_i18n('Malware analyses'), current: true }]} />
{renderLines()}
{!isFeatureEnable("FAB_REPLACEMENT") &&
<Security needs={[KNOWLEDGE_KNUPDATE]}>
{!isFeatureEnable('FAB_REPLACEMENT')
&& <Security needs={[KNOWLEDGE_KNUPDATE]}>
<MalwareAnalysisCreation paginationOptions={queryPaginationOptions}/>
</Security>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FunctionComponent } from 'react';
import useHelper from 'src/utils/hooks/useHelper';
import ListLines from '../../../components/list_lines/ListLines';
import NotesLines, { notesLinesQuery } from './notes/NotesLines';
import Security from '../../../utils/Security';
Expand All @@ -16,7 +17,6 @@ import NoteCreation from './notes/NoteCreation';
import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup, useGetDefaultFilterObject } from '../../../utils/filters/filtersUtils';
import { useFormatter } from '../../../components/i18n';
import Breadcrumbs from '../../../components/Breadcrumbs';
import useHelper from 'src/utils/hooks/useHelper';

const LOCAL_STORAGE_KEY = 'notes';

Expand Down Expand Up @@ -139,7 +139,7 @@ const Notes: FunctionComponent = () => {
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
iconExtension={true}
createButton={isFeatureEnable("FAB_REPLACEMENT") && <Security needs={[KNOWLEDGE_KNUPDATE, KNOWLEDGE_KNPARTICIPATE]}>
createButton={isFeatureEnable('FAB_REPLACEMENT') && <Security needs={[KNOWLEDGE_KNUPDATE, KNOWLEDGE_KNPARTICIPATE]}>
<NoteCreation paginationOptions={queryPaginationOptions} />
</Security>}
>
Expand Down Expand Up @@ -186,8 +186,8 @@ const Notes: FunctionComponent = () => {
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Analyses') }, { label: t_i18n('Notes'), current: true }]} />
{renderLines()}
{!isFeatureEnable("FAB_REPLACEMENT") &&
<Security needs={[KNOWLEDGE_KNUPDATE, KNOWLEDGE_KNPARTICIPATE]}>
{!isFeatureEnable('FAB_REPLACEMENT')
&& <Security needs={[KNOWLEDGE_KNUPDATE, KNOWLEDGE_KNPARTICIPATE]}>
<NoteCreation paginationOptions={queryPaginationOptions} />
</Security>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FunctionComponent } from 'react';
import useHelper from 'src/utils/hooks/useHelper';
import ListLines from '../../../components/list_lines/ListLines';
import ReportsLines, { reportsLinesQuery } from './reports/ReportsLines';
import ReportCreation from './reports/ReportCreation';
Expand All @@ -16,7 +17,6 @@ import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup } from '../../..
import { useFormatter } from '../../../components/i18n';
import Breadcrumbs from '../../../components/Breadcrumbs';
import ExportContextProvider from '../../../utils/ExportContextProvider';
import useHelper from 'src/utils/hooks/useHelper';

const LOCAL_STORAGE_KEY = 'reports';

Expand Down Expand Up @@ -139,7 +139,7 @@ const Reports: FunctionComponent = () => {
paginationOptions={queryPaginationOptions}
numberOfElements={numberOfElements}
iconExtension={true}
createButton={isFeatureEnable("FAB_REPLACEMENT") && <Security needs={[KNOWLEDGE_KNUPDATE]}>
createButton={isFeatureEnable('FAB_REPLACEMENT') && <Security needs={[KNOWLEDGE_KNUPDATE]}>
<ReportCreation paginationOptions={queryPaginationOptions} />
</Security>}
>
Expand Down Expand Up @@ -187,8 +187,8 @@ const Reports: FunctionComponent = () => {
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Analyses') }, { label: t_i18n('Reports'), current: true }]} />
{renderLines()}
{!isFeatureEnable("FAB_REPLACEMENT") &&
<Security needs={[KNOWLEDGE_KNUPDATE]}>
{!isFeatureEnable('FAB_REPLACEMENT')
&& <Security needs={[KNOWLEDGE_KNUPDATE]}>
<ReportCreation paginationOptions={queryPaginationOptions} />
</Security>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import ListItemText from '@mui/material/ListItemText';
import { Add } from '@mui/icons-material';
import Skeleton from '@mui/material/Skeleton';
import makeStyles from '@mui/styles/makeStyles';
import { Button, styled } from '@mui/material';
import { useFormatter } from '../../../../components/i18n';
import useHelper from '../../../../utils/hooks/useHelper';
import Drawer from '../../common/drawer/Drawer';
import SearchInput from '../../../../components/SearchInput';
import { QueryRenderer } from '../../../../relay/environment';
import AddExternalReferencesLines, { addExternalReferencesLinesQuery } from './AddExternalReferencesLines';
import { useFormatter } from 'src/components/i18n';
import useHelper from 'src/utils/hooks/useHelper';
import { Button, styled } from '@mui/material';

// Deprecated - https://mui.com/system/styles/basics/
// Do not use it for new code.
Expand Down Expand Up @@ -49,7 +49,7 @@ const AddExternalReferences = ({
const [open, setOpen] = useState(false);
const [dialogOpen, setDialogOpen] = useState(false);
const [search, setSearch] = useState('');
const FABReplaced = isFeatureEnable("FAB_REPLACEMENT");
const FABReplaced = isFeatureEnable('FAB_REPLACEMENT');

const handleOpen = () => {
setOpen(true);
Expand Down Expand Up @@ -77,7 +77,7 @@ const AddExternalReferences = ({
<Add fontSize="small" />
</IconButton>
<Drawer
title={t_i18n("Add external references")}
title={t_i18n('Add external references')}
open={open}
onClose={handleClose}
header={(
Expand All @@ -86,13 +86,13 @@ const AddExternalReferences = ({
variant="inDrawer"
onSubmit={handleSearch}
/>
{FABReplaced &&
<CreateButtonWithMargin
{FABReplaced
&& <CreateButtonWithMargin
onClick={() => setDialogOpen(true)}
color='primary'
size='small'
variant='contained'
>
>
{t_i18n('Create')} {t_i18n('entity_External-Reference')} <Add />
</CreateButtonWithMargin>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import makeStyles from '@mui/styles/makeStyles';
import { RecordSourceSelectorProxy } from 'relay-runtime';
import { FormikConfig } from 'formik/dist/types';
import Drawer, { DrawerVariant } from '@components/common/drawer/Drawer';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';
import { MESSAGING$, commitMutation, handleErrorInForm } from '../../../../relay/environment';
import { useFormatter } from '../../../../components/i18n';
import TextField from '../../../../components/TextField';
Expand All @@ -23,8 +25,6 @@ import { ExternalReferencesLinesPaginationQuery$variables } from './__generated_
import type { Theme } from '../../../../components/Theme';
import { ExternalReferenceAddInput, ExternalReferenceCreationMutation$data } from './__generated__/ExternalReferenceCreationMutation.graphql';
import CustomFileUploader from '../../common/files/CustomFileUploader';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';

// Deprecated - https://mui.com/system/styles/basics/
// Do not use it for new code.
Expand Down Expand Up @@ -103,7 +103,7 @@ const ExternalReferenceCreation: FunctionComponent<ExternalReferenceCreationProp
const classes = useStyles();
const { t_i18n } = useFormatter();
const { isFeatureEnable } = useHelper();
const FABReplaced = isFeatureEnable("FAB_REPLACEMENT");
const FABReplaced = isFeatureEnable('FAB_REPLACEMENT');

const [open, setOpen] = useState(false);

Expand Down Expand Up @@ -207,7 +207,7 @@ const ExternalReferenceCreation: FunctionComponent<ExternalReferenceCreationProp
<Drawer
title={t_i18n('Create an external reference')}
variant={FABReplaced ? undefined : DrawerVariant.create}
controlledDial={FABReplaced ? CreateEntityControlledDial("entity_External-Reference") : undefined}
controlledDial={FABReplaced ? CreateEntityControlledDial('entity_External-Reference') : undefined}
>
{({ onClose }) => (
<Formik
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import makeStyles from '@mui/styles/makeStyles';
import { RecordSourceSelectorProxy } from 'relay-runtime';
import { FormikConfig } from 'formik/dist/types';
import { useNavigate } from 'react-router-dom';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';
import { MESSAGING$, handleErrorInForm } from '../../../../relay/environment';
import TextField from '../../../../components/TextField';
import ObjectMarkingField from '../../common/form/ObjectMarkingField';
Expand All @@ -29,8 +31,6 @@ import useDefaultValues from '../../../../utils/hooks/useDefaultValues';
import RichTextField from '../../../../components/RichTextField';
import CustomFileUploader from '../../common/files/CustomFileUploader';
import useApiMutation from '../../../../utils/hooks/useApiMutation';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';

// Deprecated - https://mui.com/system/styles/basics/
// Do not use it for new code.
Expand Down Expand Up @@ -291,8 +291,8 @@ const GroupingCreation = ({
return (
<Drawer
title={t_i18n('Create a grouping')}
variant={isFeatureEnable("FAB_REPLACEMENT") ? undefined : DrawerVariant.create}
controlledDial={isFeatureEnable("FAB_REPLACEMENT") ? CreateEntityControlledDial("entity_Grouping") : undefined}
variant={isFeatureEnable('FAB_REPLACEMENT') ? undefined : DrawerVariant.create}
controlledDial={isFeatureEnable('FAB_REPLACEMENT') ? CreateEntityControlledDial('entity_Grouping') : undefined}
>
<GroupingCreationForm updater={updater} />
</Drawer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Field, Form, Formik } from 'formik';
import Button from '@mui/material/Button';
import { RecordSourceSelectorProxy } from 'relay-runtime';
import Drawer, { DrawerVariant } from '@components/common/drawer/Drawer';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';
import { useFormatter } from '../../../../components/i18n';
import { insertNode } from '../../../../utils/store';
import TextField from '../../../../components/TextField';
Expand All @@ -30,8 +32,6 @@ import { MESSAGING$, handleErrorInForm } from '../../../../relay/environment';
import useDefaultValues from '../../../../utils/hooks/useDefaultValues';
import CustomFileUploader from '../../common/files/CustomFileUploader';
import useApiMutation from '../../../../utils/hooks/useApiMutation';
import useHelper from 'src/utils/hooks/useHelper';
import CreateEntityControlledDial from '@components/common/menus/CreateEntityControlledDial';

// Deprecated - https://mui.com/system/styles/basics/
// Do not use it for new code.
Expand Down Expand Up @@ -275,8 +275,8 @@ const MalwareAnalysisCreation = ({
const renderClassic = () => (
<Drawer
title={t_i18n('Create a malware analysis')}
variant={isFeatureEnable("FAB_REPLACEMENT") ? undefined : DrawerVariant.create}
controlledDial={isFeatureEnable("FAB_REPLACEMENT") ? CreateEntityControlledDial("entity_Malware-Analysis") : undefined}
variant={isFeatureEnable('FAB_REPLACEMENT') ? undefined : DrawerVariant.create}
controlledDial={isFeatureEnable('FAB_REPLACEMENT') ? CreateEntityControlledDial('entity_Malware-Analysis') : undefined}
>
<MalwareAnalysisCreationForm updater={updater} />
</Drawer>
Expand Down

0 comments on commit c499cca

Please sign in to comment.