* Clear codes for sync gitlab isssues.

This commit is contained in:
Guan Xiying
2021-07-29 14:22:04 +08:00
parent 2c02bfb29c
commit db0416297a
10 changed files with 4 additions and 102 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ $config->story = new stdclass();
$config->story->batchCreate = 10;
$config->story->affectedFixedNum = 7;
$config->story->needReview = 1;
$config->story->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,execution';
$config->story->removeFields = 'objectTypeList,productList,executionList,execution';
$config->story->batchClose = new stdclass();
$config->story->batchClose->columns = 10;
-13
View File
@@ -295,12 +295,6 @@ class story extends control
$this->view->customFields = $customFields;
$this->view->showFields = $this->config->story->custom->createFields;
$this->loadModel('gitlab');
$allGitlabs = $this->gitlab->getPairs();
$executionID = $objectID;
$gitlabProjects = $this->gitlab->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
$this->view->title = $product->name . $this->lang->colon . $this->lang->story->create;
$this->view->position[] = html::a($this->createLink('product', 'browse', "product=$productID&branch=$branch"), $product->name);
$this->view->position[] = $this->lang->story->common;
@@ -330,8 +324,6 @@ class story extends control
$this->view->URS = $type == 'story' ? $this->story->getRequierements($productID) : '';
$this->view->needReview = ($this->app->user->account == $product->PO || $objectID > 0 || $this->config->story->needReview == 0) ? "checked='checked'" : "";
$this->view->type = $type;
$this->view->gitlabList = $allGitlabs;
$this->view->gitlabProjects = $gitlabProjects;
$this->display();
}
@@ -991,11 +983,6 @@ class story extends control
}
else
{
/* Delete related issue in gitlab. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->deleteIssue('story', $storyID, $relation->issueID);
$this->story->delete(TABLE_STORY, $storyID);
if($story->parent > 0)
{
-19
View File
@@ -34,22 +34,3 @@ function refreshPlan()
$(window).unload(function(){
if(blockID) window.parent.refreshBlock($('#block' + blockID));
});
$(document).ready(function()
{
$('#gitlab').change(function()
{
host = $('#gitlab').val();
if(host == '') return false;
projects = '';
$.each(gitlabProjects[host], function(id, obj){projects = projects + ',' + obj.gitlabProject});
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + "&projects=" + projects);
$.get(url, function(response)
{
$('#gitlabProject').html('').append(response);
$('#gitlabProject').chosen().trigger("chosen:updated");;
});
});
});
-1
View File
@@ -406,4 +406,3 @@ $lang->story->categoryList['experience'] = 'Experience';
$lang->story->categoryList['improve'] = 'Improve';
$lang->story->categoryList['other'] = 'Other';
$lang->story->sync2Gitlab = 'Mit Gitlab synchronisieren';
-1
View File
@@ -407,4 +407,3 @@ $lang->story->categoryList['experience'] = 'Experience';
$lang->story->categoryList['improve'] = 'Improve';
$lang->story->categoryList['other'] = 'Other';
$lang->story->sync2Gitlab = 'Mit Gitlab synchronisieren';
-1
View File
@@ -406,4 +406,3 @@ $lang->story->categoryList['experience'] = 'Experience';
$lang->story->categoryList['improve'] = 'Improve';
$lang->story->categoryList['other'] = 'Other';
$lang->story->sync2Gitlab = 'Synchroniser avec Gitlab';
-1
View File
@@ -406,4 +406,3 @@ $lang->story->categoryList['experience'] = 'Experience';
$lang->story->categoryList['improve'] = 'Improve';
$lang->story->categoryList['other'] = 'Other';
$lang->story->sync2Gitlab = 'Đồng bộ hóa với Gitlab';
-1
View File
@@ -407,4 +407,3 @@ $lang->story->categoryList['experience'] = '体验';
$lang->story->categoryList['improve'] = '改进';
$lang->story->categoryList['other'] = '其他';
$lang->story->sync2Gitlab = '同步到Gitlab';
-1
View File
@@ -407,4 +407,3 @@ $lang->story->categoryList['experience'] = '體驗';
$lang->story->categoryList['improve'] = '改進';
$lang->story->categoryList['other'] = '其他';
$lang->story->sync2Gitlab = '同步到Gitlab';
+3 -63
View File
@@ -234,7 +234,7 @@ class storyModel extends model
$requiredFields = trim($requiredFields, ',');
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify,gitlab,gitlabProject')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec();
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$storyID = $this->dao->lastInsertID();
@@ -340,10 +340,6 @@ class storyModel extends model
/* Callback the callable method to process the related data for object that is transfered to story. */
if($from && is_callable(array($this, $this->config->story->fromObjects[$from]['callback']))) call_user_func(array($this, $this->config->story->fromObjects[$from]['callback']), $storyID);
/* push this story to gitlab issue */
$object = $this->getByID($storyID);
$this->loadModel('gitlab')->apiCreateIssue($this->post->gitlab, $this->post->gitlabProject, 'story', $storyID, $object);
return array('status' => 'created', 'id' => $storyID);
}
return false;
@@ -380,7 +376,7 @@ class storyModel extends model
$data->spec = $story->spec;
$data->verify = $story->spec;
$this->dao->insert(TABLE_STORYSPEC)->data($data)->exec();
/* Link story to execution. */
$this->linkStory($executionID, $story->product, $storyID);
@@ -699,11 +695,6 @@ class storyModel extends model
$this->file->updateObjectID($this->post->uid, $storyID, 'story');
/* update story to gitlab issue. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}
}
@@ -883,11 +874,6 @@ class storyModel extends model
}
}
/* update story to gitlab issue. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if($relation) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
unset($oldStory->parent);
unset($story->parent);
return common::createChanges($oldStory, $story);
@@ -1218,11 +1204,6 @@ class storyModel extends model
/* Update story sort of plan when story plan has changed. */
if($oldStory->plan != $story->plan) $this->updateStoryOrderOfPlan($storyID, $story->plan, $oldStory->plan);
/* update story to gitlab issue. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
$this->executeHooks($storyID);
if($story->type == 'story') $this->batchChangeStage(array($storyID), $story->stage);
if($story->closedReason == 'done') $this->loadModel('score')->create('story', 'close');
@@ -1488,15 +1469,6 @@ class storyModel extends model
->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty')
->where('id')->eq($storyID)->exec();
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation))
{
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
/* Update parent story status. */
if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent);
$this->setStage($storyID);
@@ -1563,14 +1535,6 @@ class storyModel extends model
if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent);
$this->setStage($storyID);
$allChanges[$storyID] = common::createChanges($oldStory, $story);
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation))
{
$currentIssue = $this->gitlab->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
}
else
{
@@ -1847,14 +1811,7 @@ class storyModel extends model
$story->assignedDate = $now;
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError())
{
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
$story->assignee_id = $this->gitlab->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}
if(!dao::isError()) return common::createChanges($oldStory, $story);
return false;
}
@@ -1883,18 +1840,6 @@ class storyModel extends model
$story->assignedDate = $now;
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError())
{
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
$story->assignee_id = $this->gitlab->getGitlabUserID($relation->gitlabID, $story->assignedTo);
if($story->assignee_id != '') $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
/* Push this story to gitlab issue. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
}
}
return $allChanges;
}
@@ -1929,11 +1874,6 @@ class storyModel extends model
/* Update parent story status. */
if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent);
/* Push this story to gitlab issue. */
$this->loadModel('gitlab');
$relation = $this->gitlab->getRelationByObject('story', $storyID);
if(!empty($relation)) $this->gitlab->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'story', $story, $storyID);
return common::createChanges($oldStory, $story);
}