Skip to content

Commit

Permalink
[frontend] Remove feature flag for bulk entities (#4352)
Browse files Browse the repository at this point in the history
  • Loading branch information
lndrtrbn authored Sep 11, 2024
1 parent dabf6e1 commit 13e8b1f
Show file tree
Hide file tree
Showing 25 changed files with 605 additions and 810 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import BulkTextModal from '../../../../components/fields/BulkTextField/BulkTextM
import BulkTextModalButton from '../../../../components/fields/BulkTextField/BulkTextModalButton';
import useBulkCommit from '../../../../utils/hooks/useBulkCommit';
import useHelper from '../../../../utils/hooks/useHelper';
import TextField from '../../../../components/TextField';
import { splitMultilines } from '../../../../utils/String';
import ProgressBar from '../../../../components/ProgressBar';
import CreateEntityControlledDial from '../../../../components/CreateEntityControlledDial';
Expand Down Expand Up @@ -85,7 +84,6 @@ export const ChannelCreationForm: FunctionComponent<ChannelFormProps> = ({
bulkModalOpen = false,
onBulkModalClose,
}) => {
const { isFeatureEnable } = useHelper();
const { t_i18n } = useFormatter();
const [progressBarOpen, setProgressBarOpen] = useState(false);

Expand Down Expand Up @@ -182,38 +180,34 @@ export const ChannelCreationForm: FunctionComponent<ChannelFormProps> = ({
>
{({ submitForm, handleReset, isSubmitting, setFieldValue, values, resetForm }) => (
<>
{isFeatureEnable('BULK_ENTITIES') && (
<>
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
</>
)}
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
<Form style={{ margin: '20px 0 20px 0' }}>
<Field
component={isFeatureEnable('BULK_ENTITIES') ? BulkTextField : TextField}
component={BulkTextField}
name="name"
label={t_i18n('Name')}
fullWidth={true}
Expand Down Expand Up @@ -333,10 +327,7 @@ const ChannelCreation = ({
<Drawer
title={t_i18n('Create a channel')}
variant={isFABReplaced ? undefined : DrawerVariant.create}
header={isFeatureEnable('BULK_ENTITIES')
? <BulkTextModalButton onClick={() => setBulkOpen(true)} />
: <></>
}
header={<BulkTextModalButton onClick={() => setBulkOpen(true)} />}
controlledDial={isFABReplaced ? CreateChannelControlledDial : undefined}
>
{({ onClose }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { FormikConfig } from 'formik/dist/types';
import Drawer, { DrawerControlledDialProps, DrawerVariant } from '@components/common/drawer/Drawer';
import { useFormatter } from '../../../../components/i18n';
import { handleErrorInForm } from '../../../../relay/environment';
import TextField from '../../../../components/TextField';
import CreatedByField from '../../common/form/CreatedByField';
import ObjectLabelField from '../../common/form/ObjectLabelField';
import ObjectMarkingField from '../../common/form/ObjectMarkingField';
Expand Down Expand Up @@ -94,7 +93,6 @@ export const MalwareCreationForm: FunctionComponent<MalwareFormProps> = ({
onBulkModalClose,
inputValue,
}) => {
const { isFeatureEnable } = useHelper();
const { t_i18n } = useFormatter();
const [progressBarOpen, setProgressBarOpen] = useState(false);

Expand Down Expand Up @@ -217,38 +215,34 @@ export const MalwareCreationForm: FunctionComponent<MalwareFormProps> = ({
resetForm,
}) => (
<>
{isFeatureEnable('BULK_ENTITIES') && (
<>
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
</>
)}
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
<Form style={{ margin: '20px 0 20px 0' }}>
<Field
component={isFeatureEnable('BULK_ENTITIES') ? BulkTextField : TextField}
component={BulkTextField}
variant="standard"
name="name"
label={t_i18n('Name')}
Expand Down Expand Up @@ -392,10 +386,7 @@ const MalwareCreation = ({ paginationOptions }: { paginationOptions: MalwaresCar
title={t_i18n('Create a malware')}
variant={isFABReplaced ? undefined : DrawerVariant.create}
controlledDial={isFABReplaced ? CreateMalwareControlledDial : undefined}
header={isFeatureEnable('BULK_ENTITIES')
? <BulkTextModalButton onClick={() => setBulkOpen(true)} />
: <></>
}
header={<BulkTextModalButton onClick={() => setBulkOpen(true)} />}
>
{({ onClose }) => (
<MalwareCreationForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Drawer, { DrawerControlledDialProps, DrawerVariant } from '@components/co
import { ToolsLinesPaginationQuery$variables } from '@components/arsenal/__generated__/ToolsLinesPaginationQuery.graphql';
import { useFormatter } from '../../../../components/i18n';
import { handleErrorInForm } from '../../../../relay/environment';
import TextField from '../../../../components/TextField';
import KillChainPhasesField from '../../common/form/KillChainPhasesField';
import CreatedByField from '../../common/form/CreatedByField';
import ObjectLabelField from '../../common/form/ObjectLabelField';
Expand Down Expand Up @@ -87,7 +86,6 @@ export const ToolCreationForm: FunctionComponent<ToolFormProps> = ({
bulkModalOpen = false,
onBulkModalClose,
}) => {
const { isFeatureEnable } = useHelper();
const { t_i18n } = useFormatter();
const [progressBarOpen, setProgressBarOpen] = useState(false);

Expand Down Expand Up @@ -185,38 +183,34 @@ export const ToolCreationForm: FunctionComponent<ToolFormProps> = ({
>
{({ submitForm, handleReset, isSubmitting, setFieldValue, values, resetForm }) => (
<>
{isFeatureEnable('BULK_ENTITIES') && (
<>
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
</>
)}
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
<Form style={{ margin: '20px 0 20px 0' }}>
<Field
component={isFeatureEnable('BULK_ENTITIES') ? BulkTextField : TextField}
component={BulkTextField}
variant="standard"
name="name"
label={t_i18n('Name')}
Expand Down Expand Up @@ -331,10 +325,7 @@ const ToolCreation = ({
<Drawer
title={t_i18n('Create a tool')}
variant={isFABReplaced ? undefined : DrawerVariant.create}
header={isFeatureEnable('BULK_ENTITIES')
? <BulkTextModalButton onClick={() => setBulkOpen(true)} />
: <></>
}
header={<BulkTextModalButton onClick={() => setBulkOpen(true)} />}
controlledDial={isFABReplaced ? CreateToolControlledDial : undefined}
>
{({ onClose }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const VulnerabilityCreationForm: FunctionComponent<VulnerabilityFormProps
bulkModalOpen = false,
onBulkModalClose,
}) => {
const { isFeatureEnable } = useHelper();
const { t_i18n } = useFormatter();
const [progressBarOpen, setProgressBarOpen] = useState(false);
const basicShape = {
Expand Down Expand Up @@ -224,38 +223,34 @@ export const VulnerabilityCreationForm: FunctionComponent<VulnerabilityFormProps
resetForm,
}) => (
<>
{isFeatureEnable('BULK_ENTITIES') && (
<>
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
</>
)}
<BulkTextModal
open={bulkModalOpen}
onClose={onBulkModalClose}
onValidate={async (val) => {
await setFieldValue('name', val);
if (splitMultilines(val).length > 1) {
await setFieldValue('file', null);
}
}}
formValue={values.name}
/>
<ProgressBar
open={progressBarOpen}
value={(bulkCurrentCount / bulkCount) * 100}
label={`${bulkCurrentCount}/${bulkCount}`}
title={t_i18n('Create multiple entities')}
onClose={() => {
setProgressBarOpen(false);
resetForm();
resetBulk();
onCompleted?.();
}}
>
<BulkResult variablesToString={(v) => v.input.name} />
</ProgressBar>
<Form style={{ margin: '20px 0 20px 0' }}>
<Field
component={isFeatureEnable('BULK_ENTITIES') ? BulkTextField : TextField}
component={BulkTextField}
variant="standard"
name="name"
label={t_i18n('Name')}
Expand Down Expand Up @@ -432,10 +427,7 @@ const VulnerabilityCreation: FunctionComponent<VulnerabilityCreationProps> = ({
<Drawer
title={t_i18n('Create a vulnerability')}
variant={isFABReplaced ? undefined : DrawerVariant.create}
header={isFeatureEnable('BULK_ENTITIES')
? <BulkTextModalButton onClick={() => setBulkOpen(true)} />
: <></>
}
header={<BulkTextModalButton onClick={() => setBulkOpen(true)} />}
controlledDial={isFABReplaced ? CreateVulnerabilityControlledDial : undefined}
>
{({ onClose }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import useGranted, { KNOWLEDGE_KNUPDATE } from '../../../../utils/hooks/useGrant
import { CaseRfiCreationForm } from '../../cases/case_rfis/CaseRfiCreation';
import { CaseRftCreationForm } from '../../cases/case_rfts/CaseRftCreation';
import { ThreatActorIndividualCreationForm } from '../../threats/threat_actors_individual/ThreatActorIndividualCreation';
import useHelper from '../../../../utils/hooks/useHelper';
import BulkTextModalButton from '../../../../components/fields/BulkTextField/BulkTextModalButton';

export const stixDomainObjectCreationAllTypesQuery = graphql`
Expand Down Expand Up @@ -203,7 +202,6 @@ const StixDomainPanel = ({
defaultMarkingDefinitions,
isFromBulkRelation,
}) => {
const { isFeatureEnable } = useHelper();
const [bulkOpen, setBulkOpen] = useState(false);
const { t_i18n } = useFormatter();
const queryData = usePreloadedQuery(
Expand Down Expand Up @@ -753,7 +751,7 @@ const StixDomainPanel = ({
};

const renderUnavailableBulkMessage = () => {
if (isFeatureEnable('BULK_ENTITIES') && isFromBulkRelation && !BULK_ENTITIES.includes(type)) {
if (isFromBulkRelation && !BULK_ENTITIES.includes(type)) {
return (
<Alert
severity="info"
Expand All @@ -776,7 +774,7 @@ const StixDomainPanel = ({
>
<DialogTitle style={{ display: 'flex' }}>
{t_i18n('Create an entity')}
{isFeatureEnable('BULK_ENTITIES') && !isFromBulkRelation && (
{!isFromBulkRelation && (
<BulkTextModalButton
onClick={() => setBulkOpen(true)}
sx={{ marginRight: 0 }}
Expand Down
Loading

0 comments on commit 13e8b1f

Please sign in to comment.