Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/gmp/commands/__tests__/target.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('TargetCommand tests', () => {
targetSource: 'manual',
targetExcludeSource: 'manual',
hostsFilter: undefined,
hosts: '123.456, 678.9',
excludeHosts: '',
hosts: ['123.456', '678.9'],
excludeHosts: [],
reverseLookupOnly: false,
reverseLookupUnify: true,
portListId: 'pl_id1',
Expand All @@ -52,7 +52,7 @@ describe('TargetCommand tests', () => {
exclude_file: undefined,
exclude_hosts: '',
file: undefined,
hosts: '123.456, 678.9',
hosts: '123.456,678.9',
hosts_filter: undefined,
name: 'name',
port: 22,
Expand Down Expand Up @@ -134,8 +134,8 @@ describe('TargetCommand tests', () => {
targetSource: 'manual',
targetExcludeSource: 'manual',
hostsFilter: undefined,
hosts: '123.456, 678.9',
excludeHosts: '',
hosts: ['123.456', '678.9'],
excludeHosts: [],
reverseLookupOnly: false,
reverseLookupUnify: true,
portListId: 'pl_id1',
Expand Down Expand Up @@ -163,8 +163,8 @@ describe('TargetCommand tests', () => {
targetSource: 'manual',
targetExcludeSource: 'manual',
hostsFilter: undefined,
hosts: '123.456, 678.9',
excludeHosts: '',
hosts: ['123.456', '678.9'],
excludeHosts: [],
reverseLookupOnly: false,
reverseLookupUnify: true,
portListId: 'pl_id1',
Expand All @@ -187,7 +187,7 @@ describe('TargetCommand tests', () => {
exclude_file: undefined,
exclude_hosts: '',
file: undefined,
hosts: '123.456, 678.9',
hosts: '123.456,678.9',
hosts_filter: undefined,
name: 'name',
port: 22,
Expand Down Expand Up @@ -220,8 +220,8 @@ describe('TargetCommand tests', () => {
targetExcludeSource: 'manual',
hostsFilter: undefined,
excludeFile: undefined,
hosts: '123.456, 678.9',
excludeHosts: '',
hosts: ['123.456', '678.9'],
excludeHosts: [],
reverseLookupOnly: false,
reverseLookupUnify: true,
portListId: 'pl_id1',
Expand All @@ -244,7 +244,7 @@ describe('TargetCommand tests', () => {
exclude_file: undefined,
exclude_hosts: '',
file: undefined,
hosts: '123.456, 678.9',
hosts: '123.456,678.9',
hosts_filter: undefined,
name: 'name',
port: 22,
Expand Down Expand Up @@ -330,8 +330,8 @@ describe('TargetCommand tests', () => {
targetExcludeSource: 'manual',
hostsFilter: undefined,
excludeFile: undefined,
hosts: '123.456, 678.9',
excludeHosts: '',
hosts: ['123.456', '678.9'],
excludeHosts: [],
reverseLookupOnly: false,
reverseLookupUnify: true,
portListId: 'pl_id1',
Expand Down
18 changes: 10 additions & 8 deletions src/gmp/commands/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ interface TargetCommandCreateParams {
comment?: string;
esxiCredentialId?: string;
excludeFile?: File;
excludeHosts?: string;
excludeHosts?: string[];
file?: File;
hosts?: string;
hosts?: string[];
hostsFilter?: FilterType | string;
krb5CredentialId?: string;
name: string;
Expand Down Expand Up @@ -54,8 +54,8 @@ class TargetCommand extends EntityCommand<Target> {
comment = '',
targetSource,
targetExcludeSource,
hosts,
excludeHosts,
hosts = [],
excludeHosts = [],
reverseLookupOnly,
reverseLookupUnify,
portListId,
Expand All @@ -82,8 +82,8 @@ class TargetCommand extends EntityCommand<Target> {
: undefined,
target_source: targetSource,
target_exclude_source: targetExcludeSource,
hosts,
exclude_hosts: excludeHosts,
hosts: hosts.join(','),
exclude_hosts: excludeHosts.join(','),
reverse_lookup_only: isDefined(reverseLookupOnly)
? parseYesNo(reverseLookupOnly)
: undefined,
Expand Down Expand Up @@ -146,10 +146,12 @@ class TargetCommand extends EntityCommand<Target> {
: undefined,
comment,
esxi_credential_id: esxiCredentialId,
exclude_hosts: excludeHosts,
exclude_hosts: isDefined(excludeHosts)
? excludeHosts.join(',')
: undefined,
file,
exclude_file: excludeFile,
hosts,
hosts: isDefined(hosts) ? hosts.join(',') : undefined,
name,
port,
port_list_id: portListId,
Expand Down
14 changes: 6 additions & 8 deletions src/web/pages/targets/TargetComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ const TargetComponent = ({
>(undefined);
const [name, setName] = useState<string | undefined>(undefined);
const [inUse, setInUse] = useState<boolean>(false);
const [excludeHosts, setExcludeHosts] = useState<string | undefined>(
undefined,
);
const [hosts, setHosts] = useState<string | undefined>(undefined);
const [excludeHosts, setExcludeHosts] = useState<string[]>([]);
const [hosts, setHosts] = useState<string[]>([]);
const [reverseLookupOnly, setReverseLookupOnly] = useState<
boolean | undefined
>(undefined);
Expand Down Expand Up @@ -230,8 +228,8 @@ const TargetComponent = ({
setPortListId(entity.portList?.id);
setName(entity.name);
setInUse(entity.isInUse());
setExcludeHosts(entity.excludeHosts?.join(', '));
setHosts(entity.hosts.join(', '));
setExcludeHosts(entity.excludeHosts ?? []);
setHosts(entity.hosts ?? []);
setReverseLookupOnly(entity.reverseLookupOnly);
setReverseLookupUnify(entity.reverseLookupUnify);
setTargetSource('manual');
Expand All @@ -252,8 +250,8 @@ const TargetComponent = ({
setSshElevateCredentialId(undefined);
setPortListId(DEFAULT_PORT_LIST_ID);
setInUse(false);
setExcludeHosts(undefined);
setHosts(undefined);
setExcludeHosts([]);
setHosts([]);
setReverseLookupOnly(undefined);
setReverseLookupUnify(undefined);
setTargetSource(targetSource);
Expand Down
19 changes: 11 additions & 8 deletions src/web/pages/targets/TargetDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import SaveDialog from 'web/components/dialog/SaveDialog';
import FileField from 'web/components/form/FileField';
import FormGroup from 'web/components/form/FormGroup';
import MultiSelect from 'web/components/form/MultiSelect';
import MultiValueTextField from 'web/components/form/MultiValueTextField';
import NumberField from 'web/components/form/NumberField';
import Radio from 'web/components/form/Radio';
import Select from 'web/components/form/Select';
Expand Down Expand Up @@ -90,9 +91,9 @@ interface TargetDialogDefaultValues {
allowSimultaneousIPs: boolean;
comment: string;
excludeFile?: File;
excludeHosts: string;
excludeHosts: string[];
file?: File;
hosts: string;
hosts: string[];
hostsCount?: number;
hostsFilter?: Filter;
inUse: boolean;
Expand All @@ -112,8 +113,8 @@ interface TargetDialogProps {
comment?: string;
credentials?: Credential[];
esxiCredentialId?: string;
excludeHosts?: string;
hosts?: string;
excludeHosts?: string[];
hosts?: string[];
hostsCount?: number;
hostsFilter?: Filter;
id?: string;
Expand Down Expand Up @@ -166,8 +167,8 @@ const TargetDialog = ({
comment = '',
credentials = [],
esxiCredentialId,
excludeHosts = '',
hosts = '',
excludeHosts = [],
hosts = [],
hostsCount,
hostsFilter,
id,
Expand Down Expand Up @@ -441,7 +442,8 @@ const TargetDialog = ({
value="manual"
onChange={onValueChange}
/>
<TextField
<MultiValueTextField
color="gray"
disabled={inUse || state.targetSource !== 'manual'}
grow="1"
name="hosts"
Expand Down Expand Up @@ -493,7 +495,8 @@ const TargetDialog = ({
value="manual"
onChange={onValueChange}
/>
<TextField
<MultiValueTextField
color="gray"
disabled={inUse || state.targetExcludeSource !== 'manual'}
grow="1"
name="excludeHosts"
Expand Down
Loading
Loading