Skip to content

Commit

Permalink
[frontend/backend] Fixes following PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimfacion committed Oct 16, 2024
1 parent fedc15f commit 69045c7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public class InjectApi extends RestBehavior {
private final InjectService injectService;
private final AtomicTestingService atomicTestingService;
private final InjectDuplicateService injectDuplicateService;
private final InjectDependenciesRepository injectDependenciesRepository;

// -- INJECTS --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Add, DeleteOutlined, ExpandMore } from '@mui/icons-material';
import { useFormatter } from '../../../../components/i18n';
import ClickableModeChip from '../../../../components/common/chips/ClickableModeChip';
import ClickableChip from '../../../../components/common/chips/ClickableChip';
import { capitalize } from '../../../../utils/String';

const useStyles = makeStyles(() => ({
container: {
Expand Down Expand Up @@ -33,10 +34,6 @@ const InjectForm = ({
const breakpointValue = /==/gm;
const typeFromName = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}-(.*)-Success/mg;

const capitalize = (text) => {
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
};

const [parents, setParents] = useState(
injects.filter((currentInject) => values.inject_depends_on !== null
&& values.inject_depends_on[currentInject.inject_id] !== undefined)
Expand Down Expand Up @@ -570,20 +567,22 @@ const InjectForm = ({
>
{getClickableParentChip(parent)}
</Box>
<Button
color="secondary"
aria-label="Add"
size="large"
onClick={() => {
addConditionParent(parent);
}}
style={{ justifyContent: 'start' }}
>
<Add fontSize="small"/>
<Typography>
{t('Add condition')}
</Typography>
</Button>
<div style={{ justifyContent: 'left' }}>
<Button
color="secondary"
aria-label="Add"
size="large"
onClick={() => {
addConditionParent(parent);
}}
style={{ justifyContent: 'start' }}
>
<Add fontSize="small"/>
<Typography>
{t('Add condition')}
</Typography>
</Button>
</div>
</FormControl>
</AccordionDetails>
</Accordion>
Expand Down Expand Up @@ -661,20 +660,22 @@ const InjectForm = ({
>
{getClickableChildrenChip(children)}
</Box>
<Button
color="secondary"
aria-label="Add"
size="large"
onClick={() => {
addConditionChildren(children);
}}
style={{ justifyContent: 'start' }}
>
<Add fontSize="small"/>
<Typography>
{t('Add condition')}
</Typography>
</Button>
<div style={{ justifyContent: 'left' }}>
<Button
color="secondary"
aria-label="Add"
size="large"
onClick={() => {
addConditionChildren(children);
}}
style={{ justifyContent: 'start' }}
>
<Add fontSize="small"/>
<Typography>
{t('Add condition')}
</Typography>
</Button>
</div>
</FormControl>
</AccordionDetails>
</Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ const Injects: FunctionComponent<Props> = ({
'inject_description',
'inject_injector_contract',
'inject_content',
'inject_depends_from_another',
'inject_depends_on',
'inject_depends_duration',
'inject_teams',
'inject_assets',
Expand Down
4 changes: 4 additions & 0 deletions openbas-front/src/utils/String.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export const computeLabel = (status) => {
return 'Failed';
};

export const capitalize = (text) => {
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
};

// compute color for status
export const computeColorStyle = (status) => {
if (status === 'PENDING') {
Expand Down

0 comments on commit 69045c7

Please sign in to comment.