Skip to content

Commit 6ef477e

Browse files
committed
[frontend] add ee highlight
Signed-off-by: Marine LM <[email protected]>
1 parent 8e0fdec commit 6ef477e

File tree

9 files changed

+75
-25
lines changed

9 files changed

+75
-25
lines changed

openbas-front/src/admin/components/agents/Agents.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import PlatformSelector from './PlatformSelector';
2020

2121
const OPENBAS_CALDERA = 'openbas_caldera';
2222
const OPENBAS_AGENT = 'openbas_agent';
23+
const OPENBAS_CROWDSTRIKE = 'openbas_crowdstrike';
24+
const OPENBAS_TANIUM = 'openbas_tanium';
2325

2426
const Executors = () => {
2527
// Standard hooks
@@ -47,13 +49,9 @@ const Executors = () => {
4749
openbas_tanium: 2,
4850
openbas_crowdstrike: 3,
4951
};
50-
const sortedExecutors = executors
51-
.map((executor: Executor) => ({
52-
...executor,
53-
order: order[executor.executor_type as keyof typeof order],
54-
}))
55-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
56-
.sort((a: any, b: any) => a.order - b.order);
52+
53+
const sortedExecutors = executors.sort((a: Executor, b: Executor) => order[a.executor_type as keyof typeof order] - order[b.executor_type as keyof typeof order]);
54+
const needInformationStepper = (selectedExecutor?.executor_type === OPENBAS_AGENT || selectedExecutor?.executor_type === OPENBAS_CALDERA);
5755

5856
// -- Manage Dialogs
5957
const steps = [t('Choose your platform'), t('Installation Instructions')];
@@ -84,6 +82,7 @@ const Executors = () => {
8482
<ExecutorSelector
8583
executor={executor}
8684
setSelectedExecutor={setSelectedExecutor}
85+
isEEExecutor={executor.executor_type == OPENBAS_TANIUM || executor.executor_type == OPENBAS_CROWDSTRIKE}
8786
/>
8887
</Grid>
8988
))}
@@ -93,16 +92,16 @@ const Executors = () => {
9392
slots={{ transition: Transition }}
9493
onClose={closeInstall}
9594
slotProps={{ paper: { elevation: 1 } }}
96-
maxWidth="md"
95+
maxWidth={needInformationStepper ? 'md' : 'sm'}
9796
>
98-
<DialogTitle style={{ padding: theme.spacing(4, 4, 4, 5) }}>
97+
<DialogTitle>
9998
{`${selectedExecutor?.executor_name} `}
10099
</DialogTitle>
101100
<DialogContent>
102-
{(selectedExecutor?.executor_type === OPENBAS_AGENT || selectedExecutor?.executor_type === OPENBAS_CALDERA)
101+
{needInformationStepper
103102
&& (
104103
<>
105-
<Stepper activeStep={activeStep} style={{ padding: theme.spacing(0, 1, 3) }}>
104+
<Stepper activeStep={activeStep} style={{ padding: theme.spacing(0, 1, 3, 0) }}>
106105
{steps.map((label, index) => (
107106
<Step key={label}>
108107
<StepButton color="inherit" onClick={() => setActiveStep(index)}>{label}</StepButton>
@@ -117,7 +116,7 @@ const Executors = () => {
117116
)}
118117
</>
119118
)}
120-
{selectedExecutor?.executor_type !== OPENBAS_AGENT && selectedExecutor?.executor_type !== OPENBAS_CALDERA && selectedExecutor && (
119+
{!needInformationStepper && selectedExecutor && (
121120
<ExecutorDocumentationLink executor={selectedExecutor} />
122121
)}
123122
</DialogContent>

openbas-front/src/admin/components/agents/ExecutorDocumentationLink.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
import { Typography } from '@mui/material';
1+
import { Alert, Typography } from '@mui/material';
22
import { useTheme } from '@mui/material/styles';
3-
import { type FunctionComponent } from 'react';
3+
import { type FunctionComponent, useEffect } from 'react';
44

55
import { useFormatter } from '../../../components/i18n';
66
import { type Executor } from '../../../utils/api-types';
7+
import useEnterpriseEdition from '../../../utils/hooks/useEnterpriseEdition';
8+
import EEChip from '../common/entreprise_edition/EEChip';
79

810
interface Props { executor: Executor }
911

1012
const ExecutorDocumentationLink: FunctionComponent<Props> = ({ executor }) => {
1113
// Standard hooks
1214
const { t } = useFormatter();
1315
const theme = useTheme();
16+
const { openDialog, setFeatureDetectedInfo } = useEnterpriseEdition();
1417

18+
useEffect(() => {
19+
}, []);
20+
const onAlertClick = () => {
21+
setFeatureDetectedInfo(executor.executor_name);
22+
openDialog();
23+
};
1524
return (
16-
<div style={{ padding: theme.spacing(0, 2, 2) }}>
25+
<div style={{
26+
display: 'grid',
27+
gap: theme.spacing(2),
28+
}}
29+
>
30+
<Alert style={{ cursor: 'pointer' }} icon={<EEChip style={{ marginTop: theme.spacing(1) }} />} severity="success" onClick={onAlertClick}>
31+
{`${executor.executor_name} ${t('executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.')} `}
32+
</Alert>
1733
{executor.executor_doc && (
1834
<Typography variant="body1">
1935
{t('To install the agent please follow the ')}

openbas-front/src/admin/components/agents/ExecutorSelector.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { makeStyles } from 'tss-react/mui';
55
import { useFormatter } from '../../../components/i18n';
66
import PlatformIcon from '../../../components/PlatformIcon';
77
import { type Executor } from '../../../utils/api-types';
8+
import EEChip from '../common/entreprise_edition/EEChip';
89
import ExecutorBanner from './ExecutorBanner';
910

1011
const useStyles = makeStyles()(theme => ({
@@ -27,9 +28,10 @@ const useStyles = makeStyles()(theme => ({
2728
interface ExecutorSelectorProps {
2829
executor: Executor;
2930
setSelectedExecutor: (executor: Executor) => void;
31+
isEEExecutor?: boolean;
3032
}
3133

32-
const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelectedExecutor }) => {
34+
const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelectedExecutor, isEEExecutor = false }) => {
3335
const theme = useTheme();
3436
const { classes } = useStyles();
3537
const { t } = useFormatter();
@@ -55,12 +57,12 @@ const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelect
5557
fontSize: 15,
5658
padding: theme.spacing(2, 0, 1),
5759
display: 'flex',
58-
alignItems: 'center',
5960
justifyContent: 'center',
6061
color: platforms.length === 0 ? theme.palette.text?.disabled : theme.palette.text?.primary,
6162
}}
6263
>
6364
{`${t('Install')} ${executor.executor_name}`}
65+
{isEEExecutor && <EEChip style={{ marginLeft: theme.spacing(1) }} />}
6466
</Typography>
6567
<Box
6668
sx={{

openbas-front/src/admin/components/assets/endpoints/endpoint/AgentList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DevicesOtherOutlined } from '@mui/icons-material';
22
import { List, ListItem, ListItemIcon, ListItemText } from '@mui/material';
3+
import { useTheme } from '@mui/material/styles';
34
import { type CSSProperties, type FunctionComponent } from 'react';
45
import { makeStyles } from 'tss-react/mui';
56

@@ -11,6 +12,7 @@ import { useHelper } from '../../../../../store';
1112
import { type AgentOutput } from '../../../../../utils/api-types';
1213
import { useAppDispatch } from '../../../../../utils/hooks';
1314
import useDataLoader from '../../../../../utils/hooks/useDataLoader';
15+
import EEChip from '../../../common/entreprise_edition/EEChip';
1416
import AssetStatus from '../../AssetStatus';
1517
import AgentDeploymentMode from '../AgentDeploymentMode';
1618
import AgentPrivilege from '../AgentPrivilege';
@@ -44,6 +46,7 @@ interface Props { agents: AgentOutput[] }
4446

4547
const AgentList: FunctionComponent<Props> = ({ agents }) => {
4648
const { classes } = useStyles();
49+
const theme = useTheme();
4750
const bodyItemsStyles = useBodyItemsStyles();
4851
const dispatch = useAppDispatch();
4952
const { t, fldt } = useFormatter();
@@ -81,7 +84,9 @@ const AgentList: FunctionComponent<Props> = ({ agents }) => {
8184
}}
8285
/>
8386
)}
84-
{executor?.executor_name ?? t('Unknown')}
87+
{executor.executor_name ?? t('Unknown')}
88+
{(executor.executor_type == 'openbas_tanium' || executor.executor_type == 'openbas_crowdstrike')
89+
&& <EEChip style={{ marginLeft: theme.spacing(1) }} clickable featureDetectedInfo={executor.executor_name} />}
8590
</>
8691
);
8792
},

openbas-front/src/admin/components/common/entreprise_edition/EEChip.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Tooltip } from '@mui/material';
2+
import { type CSSProperties } from 'react';
23
import { makeStyles } from 'tss-react/mui';
34

45
import { useFormatter } from '../../../../components/i18n';
@@ -20,20 +21,25 @@ const useStyles = makeStyles<{ isClickable: boolean }>()((theme, { isClickable }
2021
},
2122
}));
2223

23-
const EEChip = ({ clickable = false }: {
24+
const EEChip = ({ clickable = false, featureDetectedInfo = null, style = {} }: {
2425
clickable?: boolean;
25-
featureDetectedInfo?: string;
26+
featureDetectedInfo?: string | null;
27+
style?: CSSProperties;
2628
}) => {
2729
const { classes } = useStyles({ isClickable: clickable });
2830
const { t } = useFormatter();
29-
const { openDialog } = useEnterpriseEdition();
31+
const { openDialog, setFeatureDetectedInfo } = useEnterpriseEdition();
3032
const { isValidated: isEnterpriseEdition } = useEnterpriseEdition();
33+
if (featureDetectedInfo) {
34+
setFeatureDetectedInfo(featureDetectedInfo);
35+
}
3136

3237
return (
3338
<Tooltip
3439
title={t('Enterprise Edition Feature')}
3540
className={classes.container}
3641
onClick={() => clickable && !isEnterpriseEdition && openDialog()}
42+
style={style}
3743
>
3844
<span>
3945
EE

openbas-front/src/admin/components/common/entreprise_edition/EnterpriseEditionAgreementDialog.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,31 @@ const useStyles = makeStyles()(theme => ({
3232

3333
const EnterpriseEditionAgreementDialog = () => {
3434
const { t } = useFormatter();
35-
const { open, closeDialog, featureDetectedInfo } = useEnterpriseEdition();
35+
const { open, closeDialog, featureDetectedInfo, setFeatureDetectedInfo } = useEnterpriseEdition();
3636
const { classes } = useStyles();
3737
const dispatch = useAppDispatch();
3838
const [enterpriseLicense, setEnterpriseLicense] = useState('');
3939

40+
const onCloseEnterpriseEditionDialog = () => {
41+
closeDialog();
42+
setFeatureDetectedInfo('');
43+
};
44+
4045
const updateEnterpriseEdition = (data: SettingsEnterpriseEditionUpdateInput) => {
4146
dispatch(updatePlatformEnterpriseEditionParameters(data));
42-
closeDialog();
47+
onCloseEnterpriseEditionDialog();
4348
};
49+
4450
const enableEnterpriseEdition = () => updateEnterpriseEdition({ platform_enterprise_license: enterpriseLicense });
51+
4552
return (
4653
<Dialog
4754
open={open}
48-
handleClose={closeDialog}
55+
handleClose={onCloseEnterpriseEditionDialog}
4956
title={t('OpenBAS Enterprise Edition (EE) license agreement')}
5057
actions={(
5158
<>
52-
<Button onClick={closeDialog}>{t('Cancel')}</Button>
59+
<Button onClick={onCloseEnterpriseEditionDialog}>{t('Cancel')}</Button>
5360
<Button
5461
color="secondary"
5562
onClick={enableEnterpriseEdition}

openbas-front/src/utils/lang/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@
508508
"Execution Time": "Execution Time",
509509
"Executor": "Executor",
510510
"Executor Caldera is not responding, your exercises may be impacted.": "Executor Caldera is not responding, your exercises may be impacted.",
511+
"executor is an enterprise edition feature": {
512+
" You can start the set up but you will need a license key to execute your injects": {
513+
" We provide a 3 month trial to let you test the platform at full capacity": "executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity."
514+
}
515+
},
511516
"Executors": "Executors",
512517
"Exercise": "Simulation",
513518
"Exercise details": "Exercise details",

openbas-front/src/utils/lang/fr.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@
508508
"Execution Time": "Temps d'exécution",
509509
"Executor": "Exécuteur",
510510
"Executor Caldera is not responding, your exercises may be impacted.": "L'exécuteur Caldera ne réponds pas, vos exercises peuvent être impactés.",
511+
"executor is an enterprise edition feature": {
512+
" You can start the set up but you will need a license key to execute your injects": {
513+
" We provide a 3 month trial to let you test the platform at full capacity": "exécuteur est une fonctionnalité de l'édition Entreprise. Vous pouvez commencer l'installation, mais vous aurez besoin d'une clé de licence pour exécuter vos injections. Nous proposons une période d'essai de 3 mois pour vous permettre de tester la plateforme à pleine capacité."
514+
}
515+
},
511516
"Executors": "Exécuteurs",
512517
"Exercise": "Simulation",
513518
"Exercise details": "Détails de l'exercise",

openbas-front/src/utils/lang/zh.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@
508508
"Execution Time": "执行时间",
509509
"Executor": "执行者",
510510
"Executor Caldera is not responding, your exercises may be impacted.": "Executor Caldera is not responding, your exercises may be impacted.",
511+
"executor is an enterprise edition feature": {
512+
" You can start the set up but you will need a license key to execute your injects": {
513+
" We provide a 3 month trial to let you test the platform at full capacity": "执行器是企业版功能。您可以开始设置,但需要许可证密钥才能执行注入。我们提供 3 个月的试用期,让您可以充分测试平台的功能。"
514+
}
515+
},
511516
"Executors": "执行者",
512517
"Exercise": "练习",
513518
"Exercise details": "锻炼详情",

0 commit comments

Comments
 (0)