Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix UI defect RAC-4416 #549

Merged
merged 1 commit into from
Nov 10, 2017
Merged

fix UI defect RAC-4416 #549

merged 1 commit into from
Nov 10, 2017

Conversation

kellylu2sym
Copy link

BackGround :
when we create a workflow without task definition , rackhd will add api path to the taskName ,when you change the workflow and need save again , it will failed when validation of the task with taskName like "api/2.0/workflows/tasks****"
Solution :
code change in task-graph.js . when validate ,we use actually task name instead of the whole name witch contains api path
Test :
manual test
Jira:
https://rackhd.atlassian.net/browse/RAC-4416
Reviewer :
@anhou @panpan0000 @bbcyyb

return store.getTaskDefinition(taskData.taskName)
var taskName = new String(taskData.taskName);
var contains = taskName.indexOf("\/");
if(contains != null){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected '!==' and instead saw '!='.

@@ -360,7 +366,13 @@ function taskGraphFactory(
assert.arrayOfObject(self.definition.tasks, 'Graph.tasks');
return Promise.map(self.definition.tasks, function(taskData) {
if (!_.has(taskData, 'taskDefinition')) {
return store.getTaskDefinition(taskData.taskName)
var taskName = new String(taskData.taskName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use String as a constructor.

@@ -210,8 +210,14 @@ function taskGraphFactory(
};

if (taskData.taskName) {
var taskName = new String(taskData.taskName);
var contains = taskName.indexOf("\/");
if(contains != null){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected '!==' and instead saw '!='.

@@ -210,8 +210,14 @@ function taskGraphFactory(
};

if (taskData.taskName) {
var taskName = new String(taskData.taskName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use String as a constructor.

@@ -208,10 +208,15 @@ function taskGraphFactory(
waitingOn: taskData.waitOn,
ignoreFailure: taskData.ignoreFailure
};

if (taskData.taskName) {
if (taskData.taskName && typeof(taskData.taskName) !== "undefined") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition never goto 'typeof(taskData.taskName) !== "undefined"' which after '&&' , right?

if (taskData.taskName && typeof(taskData.taskName) !== "undefined") {
var taskName = taskData.taskName;
var contains = taskName.indexOf("\/");
if(contains !== -1){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add annotations for string operations

@@ -360,7 +365,15 @@ function taskGraphFactory(
assert.arrayOfObject(self.definition.tasks, 'Graph.tasks');
return Promise.map(self.definition.tasks, function(taskData) {
if (!_.has(taskData, 'taskDefinition')) {
return store.getTaskDefinition(taskData.taskName)
var taskName = taskData.taskName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated code with above, please extract a function if possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, however this line is in the new function.

if (taskData.taskName) {
if (taskData.taskName && typeof(taskData.taskName) !== "undefined") {
var taskName = taskData.taskName;
var contains = taskName.indexOf("\/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains what, a descriptive name is better

@@ -130,6 +130,13 @@ describe('Task Graph', function () {
expect(graph).to.be.an.instanceof(TaskGraph);
});
});
it('should return this', function() {
Copy link
Contributor

@panpan0000 panpan0000 Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please choose another description other than "should return this". it was used in line 127

@panpan0000
Copy link
Contributor

panpan0000 commented Nov 8, 2017

a silly question:
is it possible that there's different path but with same task name ?
ex:
api/workflows/tasks/wsman/Task.test
api/workflows/tasks/ucs/Task.test

taskName = nameArray[nameArray.length - 1];
}
return taskName;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

@@ -229,7 +235,14 @@ function taskGraphFactory(
return self;
});
};

var getTaskName = function(taskName){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'getTaskName' was used before it was defined.

taskName = nameArray[nameArray.length - 1];
}
return taskName;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

taskName = nameArray[nameArray.length - 1];
}
return taskName;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

var getTaskName = function(taskName){
// check if there is "/" in the task name ,if yes
// it may have the api path before task name
var contains = taskName.indexOf("\/");
Copy link
Member

@anhou anhou Nov 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary variable name could be slashIndex, or slashOffset. I think this is your purpose, it's more straightforward than a verb 'contain', and it's more readable

return store.getTaskDefinition(taskData.taskName)
var taskName = taskData.taskName;
if(taskName){
taskName = getTaskName(taskName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskName in this function have two meanings. former taskName is taskName input, latter is true taskName, it's not so good for clean code. so you could naming former one as taskNameInput, the latter is taskName. Otherwise, it's a little werid that get 'taskName' from 'taskName'

@panpan0000
Copy link
Contributor

can you git commit --amend then git push again, to trigger the Concourse?

@anhou anhou merged commit b4e1757 into RackHD:master Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants