+ Add managetagpriv page for gitlab.
This commit is contained in:
@@ -1486,10 +1486,7 @@ class gitlab extends control
|
||||
}
|
||||
|
||||
$hasAccessTags = $this->gitlab->apiGetTagPrivs($gitlabID, $projectID, '', 'name_asc');
|
||||
foreach($hasAccessTags as $tag)
|
||||
{
|
||||
$tag->createAccess = $this->gitlab->checkAccessLevel($tag->create_access_levels);
|
||||
}
|
||||
foreach($hasAccessTags as $tag) $tag->createAccess = $this->gitlab->checkAccessLevel($tag->create_access_levels);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
@@ -1498,18 +1495,15 @@ class gitlab extends control
|
||||
|
||||
return $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success', 'locate' => inlink('browseProject', "gitlabID=$gitlabID")));
|
||||
}
|
||||
$allTags = $this->gitlab->apiGetTags($gitlabID, $projectID);
|
||||
$noAccessTags = array();
|
||||
foreach($allTags as $tag)
|
||||
{
|
||||
if(!isset($hasAccessTags[$tag->name])) $noAccessTags[$tag->name] = $tag->name;
|
||||
}
|
||||
$allTags = $this->gitlab->apiGetTags($gitlabID, $projectID);
|
||||
$tagPairs = array();
|
||||
foreach($allTags as $tag) $tagPairs[$tag->name] = $tag->name;
|
||||
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseTagPriv;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->hasAccessTags = $hasAccessTags;
|
||||
$this->view->noAccessTags = $noAccessTags;
|
||||
$this->view->tagPairs = $tagPairs;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
window.getMenu = function(item)
|
||||
{
|
||||
const selectedTags = [];
|
||||
$('.pick-value[name^=name]').each(function()
|
||||
{
|
||||
const name = $(this).val();
|
||||
if(name) selectedTags.push(name);
|
||||
});
|
||||
|
||||
item.disabled = selectedTags.includes(item.text);
|
||||
return item;
|
||||
}
|
||||
|
||||
window.onRenderRow = function(row, rowIdx, data)
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
row.find('[data-name="name"]').find('.picker-box').on('inited', function(_, info)
|
||||
{
|
||||
if(hasAccessTags[data.name])
|
||||
{
|
||||
const tags = [{text: data.name, value: data.name}];
|
||||
info[0].render({disabled: true, required: true, items: tags, defaultValue: data.name});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2721,8 +2721,10 @@ class gitlabModel extends model
|
||||
*/
|
||||
public function manageTagPrivs($gitlabID, $projectID, $protected = array())
|
||||
{
|
||||
$data = (array)fixer::input('post')->get();
|
||||
extract($data);
|
||||
$data = fixer::input('post')->get();
|
||||
$tags = $data->name;
|
||||
$createLevels = $data->createAccess;
|
||||
|
||||
$failure = array();
|
||||
|
||||
/* Remove privs. */
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The managetagpriv view file of gitlab module of ZenTaoPMS.
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package gitlab
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('hasAccessTags', $hasAccessTags);
|
||||
formBatchPanel
|
||||
(
|
||||
set::data(array_values($hasAccessTags)),
|
||||
set::onRenderRow(jsRaw('onRenderRow')),
|
||||
formBatchItem
|
||||
(
|
||||
set::name('id'),
|
||||
set::label('ID'),
|
||||
set::control('index'),
|
||||
set::width('50px'),
|
||||
),
|
||||
formBatchItem
|
||||
(
|
||||
set::label($lang->gitlab->tag->name),
|
||||
set::width('1/3'),
|
||||
set::name('name'),
|
||||
set::control
|
||||
(
|
||||
array(
|
||||
'type' => 'picker',
|
||||
'name' => 'name',
|
||||
'cache' => false,
|
||||
'items' => $tagPairs,
|
||||
'menu' => jsRaw('{getItem(item) {return getMenu(item)}}'),
|
||||
)
|
||||
)
|
||||
),
|
||||
formBatchItem
|
||||
(
|
||||
set::name('createAccess'),
|
||||
set::label($lang->gitlab->tag->accessLevel),
|
||||
set::control('picker'),
|
||||
set::width('1/2'),
|
||||
set::required(true),
|
||||
set::items($lang->gitlab->branch->branchCreationLevelList)
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user