Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 75af5bf

Browse files
oodamienghillert
authored andcommitted
Task Launch: fix properties concatenation
Resolves #915 - Fix concatenation properties - Add tests
1 parent d238498 commit 75af5bf

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

ui/src/app/tasks/task-launch/task-launch.component.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,34 @@ describe('TaskLaunchComponent', () => {
8282
expect(component).toBeTruthy();
8383
});
8484

85+
86+
describe('Prepare Arguments', () => {
87+
88+
beforeEach(() => {
89+
fixture.detectChanges();
90+
});
91+
92+
it('Name, no arg, 2 properties', () => {
93+
const result = component.prepareParams('name', [], ['prop1=val1', 'prop2=val2']);
94+
expect(result.name).toBe('name');
95+
expect(result.args).toBe('');
96+
expect(result.props).toBe('prop1=val1, prop2=val2');
97+
});
98+
99+
it('Name, 2 args, no property', () => {
100+
const result = component.prepareParams('name', ['arg1=val1', 'arg2=val2'], []);
101+
expect(result.name).toBe('name');
102+
expect(result.args).toBe('arg1=val1 arg2=val2');
103+
expect(result.props).toBe('');
104+
});
105+
106+
it('Name, 2 args, 2 properties', () => {
107+
const result = component.prepareParams('name', ['arg1=valArg1', 'arg2=valArg2'], ['prop1=valProp1', 'prop2=valProp2']);
108+
expect(result.name).toBe('name');
109+
expect(result.args).toBe('arg1=valArg1 arg2=valArg2');
110+
expect(result.props).toBe('prop1=valProp1, prop2=valProp2');
111+
});
112+
113+
});
114+
85115
});

ui/src/app/tasks/task-launch/task-launch.component.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { TaskLaunchValidator } from './task-launch.validator';
1111
import { NotificationService } from '../../shared/services/notification.service';
1212
import { AppError } from '../../shared/model/error.model';
1313
import { RoutingStateService } from '../../shared/services/routing-state.service';
14+
import { TaskLaunchParams } from '../components/tasks.interface';
1415

1516
/**
1617
* Component that provides a launcher of task.
@@ -109,6 +110,21 @@ export class TaskLaunchComponent implements OnInit, OnDestroy {
109110
this.ngUnsubscribe$.complete();
110111
}
111112

113+
/**
114+
* Prepare params
115+
* @param {string} name
116+
* @param {Array<string>} taskArguments
117+
* @param {Array<string>} taskProperties
118+
* @returns {TaskLaunchParams}
119+
*/
120+
prepareParams(name: string, taskArguments: Array<string>, taskProperties: Array<string>): TaskLaunchParams {
121+
return {
122+
name: name,
123+
args: taskArguments.join(' '),
124+
props: taskProperties.join(', ')
125+
};
126+
}
127+
112128
/**
113129
* Launch the task
114130
*
@@ -125,11 +141,8 @@ export class TaskLaunchComponent implements OnInit, OnDestroy {
125141
};
126142
const taskArguments = getClean(this.form.get('args') as FormArray);
127143
const taskProperties = getClean(this.form.get('params') as FormArray);
128-
const busy = this.tasksService.launchDefinition({
129-
name: name,
130-
args: taskArguments.join(' '),
131-
props: taskProperties.join(',')
132-
}).pipe(takeUntil(this.ngUnsubscribe$))
144+
const busy = this.tasksService.launchDefinition(this.prepareParams(name, taskArguments, taskProperties))
145+
.pipe(takeUntil(this.ngUnsubscribe$))
133146
.subscribe(
134147
data => {
135148
this.notificationService.success('Successfully launched task "' + name + '"');

0 commit comments

Comments
 (0)