Skip to content

Commit

Permalink
[Frontend] Adjust plus sign on attack pattern field (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanah29 authored Jun 18, 2024
1 parent d310c22 commit 54cca67
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 78 deletions.
114 changes: 57 additions & 57 deletions openbas-front/src/admin/components/payloads/PayloadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const PayloadForm = (props) => {
requiredFields.push(...['executable_file']);
break;
default:
// do nothing
// do nothing
}
requiredFields.forEach((field) => {
if (field === 'payload_platforms' && (!values[field] || values[field].length === 0)) {
Expand Down Expand Up @@ -86,68 +86,68 @@ const PayloadForm = (props) => {
style={{ marginTop: 20 }}
/>
{type === 'Command' && (
<>
<OldSelectField
variant="standard"
label={t('Command executor')}
name="command_executor"
fullWidth={true}
style={{ marginTop: 20 }}
>
<MenuItem value="psh">
{t('PowerShell')}
</MenuItem>
<MenuItem value="cmd">
{t('Command Prompt')}
</MenuItem>
<MenuItem value="bash">
{t('Bash')}
</MenuItem>
<MenuItem value="sh">
{t('Sh')}
</MenuItem>
</OldSelectField>
<OldTextField
name="command_content"
multiline={true}
fullWidth={true}
rows={3}
label={t('Command')}
style={{ marginTop: 20 }}
helperText={t('To put arguments in the command line, use #{argument_key}')}
/>
</>
<>
<OldSelectField
variant="standard"
label={t('Command executor')}
name="command_executor"
fullWidth={true}
style={{ marginTop: 20 }}
>
<MenuItem value="psh">
{t('PowerShell')}
</MenuItem>
<MenuItem value="cmd">
{t('Command Prompt')}
</MenuItem>
<MenuItem value="bash">
{t('Bash')}
</MenuItem>
<MenuItem value="sh">
{t('Sh')}
</MenuItem>
</OldSelectField>
<OldTextField
name="command_content"
multiline={true}
fullWidth={true}
rows={3}
label={t('Command')}
style={{ marginTop: 20 }}
helperText={t('To put arguments in the command line, use #{argument_key}')}
/>
</>
)}
{type === 'Executable' && (
<>
<DocumentField
name="executable_file"
label={t('Executable file')}
style={{ marginTop: 20 }}
/>
</>
<>
<DocumentField
name="executable_file"
label={t('Executable file')}
style={{ marginTop: 20 }}
/>
</>
)}
{type === 'FileDrop' && (
<>
<DocumentField
name="file_drop_file"
label={t('File to drop')}
style={{ marginTop: 20 }}
/>
</>
<>
<DocumentField
name="file_drop_file"
label={t('File to drop')}
style={{ marginTop: 20 }}
/>
</>
)}
{type === 'DnsResolution' && (
<>
<OldTextField
name="dns_resolution_hostname"
label={t('Hostname')}
style={{ marginTop: 20 }}
multiline={true}
fullWidth={true}
rows={3}
helperText={t('One hostname by line')}
/>
</>
<>
<OldTextField
name="dns_resolution_hostname"
label={t('Hostname')}
style={{ marginTop: 20 }}
multiline={true}
fullWidth={true}
rows={3}
helperText={t('One hostname by line')}
/>
</>
)}
<FieldArray name="payload_arguments">
{({ fields, meta }) => (
Expand Down
44 changes: 23 additions & 21 deletions openbas-front/src/components/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,23 @@ const renderAutocomplete = ({
fullWidth,
style,
openCreate,
noMargin,
...others
}) => {
let top = 30;
if (placeholder) {
top = -5;
} else if (noMargin) {
top = 10;
}
return (
<div style={{ position: 'relative' }}>
<MuiAutocomplete
label={label}
selectOnFocus={true}
autoHighlight={true}
selectOnFocus
autoHighlight
clearOnBlur={false}
clearOnEscape={false}
onInputChange={(event, value) => {
disableClearable
onInputChange={(_event, value) => {
if (others.freeSolo) {
onChange(value);
}
}}
onChange={(event, value) => {
onChange={(_event, value) => {
onChange(value);
}}
{...inputProps}
Expand All @@ -49,24 +43,32 @@ const renderAutocomplete = ({
style={style}
error={touched && invalid}
helperText={touched && error}
InputProps={{
...params.InputProps,
endAdornment: (
<>
{
typeof openCreate === 'function' && (
<IconButton
onClick={() => openCreate()}
>
<AddOutlined />
</IconButton>
)
}
{params.InputProps.endAdornment}
</>
),
}}
/>
)}
/>
{typeof openCreate === 'function' && (
<IconButton
onClick={() => openCreate()}
edge="end"
style={{ position: 'absolute', top, right: 35 }}
>
<AddOutlined />
</IconButton>
)}
</div>
);
};

/**
* @deprecated The component use old form libnary react-final-form
* @deprecated The component use old form library react-final-form
*/
const Autocomplete = (props) => {
return (<Field name={props.name} component={renderAutocomplete} {...props} />
Expand Down

0 comments on commit 54cca67

Please sign in to comment.