diff --git a/module/action/model.php b/module/action/model.php index e54e200885..95c17a55d9 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -203,11 +203,15 @@ class actionModel extends model if($actionName == 'repocreated') $action->extra = str_replace("class='iframe'", 'data-app="devops"', $action->extra); $action->history = zget($histories, $actionID, array()); - if($actionName == 'svncommited') array_map(function($history) {if($history->field == 'subversion') $history->diff = str_replace('+', '%2B', $history->diff);}, $action->history); - if($actionName == 'gitcommited') array_map(function($history) {if($history->field == 'git') $history->diff = str_replace('+', '%2B', $history->diff);}, $action->history); + foreach($action->history as $history) + { + if($history->field == 'subversion' || $history->field == 'git') + { + $history->diff = str_replace(array("class='iframe'", '+'), array("data-type='iframe' data-size='{\"width\": 800, \"height\": 500}' data-toggle='modal'", '%2B'), $history->diff); + } + } $action->comment = $this->loadModel('file')->setImgSize($action->comment, $this->config->action->commonImgSize); - $actions[$actionID] = $action; } return $actions; diff --git a/module/git/control.php b/module/git/control.php index 05f7b32d42..a5e44dca1b 100644 --- a/module/git/control.php +++ b/module/git/control.php @@ -42,13 +42,14 @@ class git extends control foreach($repos as $repo) { if(!empty($repo->path) && strpos($path, $repo->path) === 0) $currentRepo = $repo; + if(!empty($repo->apiPath) && strpos($path, $repo->apiPath) === 0) $currentRepo = $repo; } if($currentRepo && common::hasPriv('repo', 'diff')) { - $entry = $this->repo->encodePath(str_replace($currentRepo->path, '', $path)); + $entry = $this->repo->encodePath(str_replace(array($currentRepo->path, $currentRepo->apiPath), '', $path)); $oldRevision = "$revision^"; - return $this->locate($this->repo->createLink('diff', "repoID=$currentRepo->id&objectID=0&entry=$entry&oldRevision=$oldRevision&revision=$revision", 'html', 'true')); + return print($this->fetch('repo', 'diff', "repoID=$currentRepo->id&objectID=0&entry=$entry&oldRevision=$oldRevision&revision=$revision")); } if($currentRepo) @@ -82,12 +83,13 @@ class git extends control foreach($repos as $repo) { if(!empty($repo->path) && strpos($path, $repo->path) === 0) $currentRepo = $repo; + if(!empty($repo->apiPath) && strpos($path, $repo->apiPath) === 0) $currentRepo = $repo; } if($currentRepo && common::hasPriv('repo', 'view')) { - $entry = $this->repo->encodePath(str_replace($currentRepo->path, '', $path)); - return $this->locate($this->repo->createLink('view', "repoID=$currentRepo->id&objectID=0&entry=$entry&revision=$revision", 'html', true)); + $entry = $this->repo->encodePath(str_replace(array($currentRepo->path, $repo->apiPath), '', $path)); + return print($this->fetch('repo', 'view', "repoID=$currentRepo->id&objectID=0&entry=$entry&revision=$revision")); } if($currentRepo) diff --git a/module/repo/control.php b/module/repo/control.php index fbd1204d45..bcf4aea77e 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -45,7 +45,8 @@ class repo extends control */ public function commonAction(int $repoID = 0, int $objectID = 0) { - $tab = $this->app->tab; + $fromModal = in_array($this->app->rawModule, array('git', 'svn')); + $tab = $fromModal ? '' :$this->app->tab; $this->repos = $this->repo->getRepoPairs($tab, $objectID); if($tab == 'project') @@ -61,18 +62,22 @@ class repo extends control $execution = $this->loadModel('execution')->getByID($objectID); if($execution && $execution->type === 'kanban') return $this->locate($this->createLink('execution', 'kanban', "executionID=$objectID")); - $features = $this->execution->getExecutionFeatures($execution); - if(!$features['devops']) return print($this->locate($this->createLink('execution', 'task', "executionID=$objectID"))); + if($execution) + { + $features = $this->execution->getExecutionFeatures($execution); + if(!$features['devops']) return print($this->locate($this->createLink('execution', 'task', "executionID=$objectID"))); + } $this->loadModel('execution')->setMenu($objectID); $this->view->executionID = $objectID; } - elseif($tab != 'admin') + elseif($tab != 'admin' && !$fromModal) { $this->repo->setMenu($this->repos, $repoID); } if(empty($this->repos) && !in_array($this->methodName, array('create', 'setrules'))) return $this->locate($this->repo->createLink('create', "objectID=$objectID")); + $this->view->fromModal = $fromModal; } /** diff --git a/module/repo/model.php b/module/repo/model.php index f5b53f8513..dcf7fe8366 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -690,7 +690,7 @@ class repoModel extends model $matchedRepos = $this->getListByCondition('(' . implode(' OR ', $conditions). ')', 'Gitlab'); if(empty($matchedRepos)) return array('result' => 'fail', 'message' => 'No matched gitlab.'); - $matchedRepo = ''; + $matchedRepo = new stdclass(); foreach($matchedRepos as $repo) { if(!empty($repo->preMerge)) diff --git a/module/repo/ui/diff.html.php b/module/repo/ui/diff.html.php index 891d7d7c8d..36b8a0c877 100644 --- a/module/repo/ui/diff.html.php +++ b/module/repo/ui/diff.html.php @@ -12,14 +12,21 @@ declare(strict_types=1); namespace zin; -$module = $app->tab == 'devops' ? 'repo' : $app->tab; -dropmenu +$module = $app->tab == 'devops' ? 'repo' : $app->tab; +$inModal = isInModal() || !empty($fromModal); +$inModal ? null : dropmenu ( set::module($module), set::tab($module), set::url(createLink($module, 'ajaxGetDropMenu', "objectID=$objectID&module={$app->rawModule}&method={$app->rawMethod}")) ); +if($inModal) +{ + to::header(false); + to::main(false); +} + jsVar('repo', $repo); jsVar('repoLang', $lang->repo); jsVar('objectID', $objectID); @@ -130,12 +137,14 @@ else on::click('goDiff') ); } - -\zin\featureBar -( - backBtn(set::icon('back'), setClass('bg-transparent diff-back-btn'), set::back('GLOBAL'), $lang->goback), - item(set::type('divider')), - ...$breadcrumbItems +div( + setClass($inModal ? 'hidden' : ''), + \zin\featureBar + ( + backBtn(set::icon('back'), setClass('bg-transparent diff-back-btn'), set::back('GLOBAL'), $lang->goback), + item(set::type('divider')), + ...$breadcrumbItems + ) ); if($diffs) include 'diffeditor.html.php'; diff --git a/module/repo/ui/diffeditor.html.php b/module/repo/ui/diffeditor.html.php index 48d17dd29c..998ee15dae 100644 --- a/module/repo/ui/diffeditor.html.php +++ b/module/repo/ui/diffeditor.html.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace zin; +$inModal = isInModal() || !empty($fromModal); $entry = count($diffs) ? $diffs[0]->fileName : ''; $currentEntry = $this->repo->encodePath($entry); $fileInfo = $entry ? pathinfo($entry) : array(); @@ -30,10 +31,14 @@ jsVar('urlParams', "repoID=$repoID&objectID=$objectID&entry=%s&oldRevision=$oldR \zin\featureBar(); $dropMenus = array(); -if(common::hasPriv('repo', 'download')) $dropMenus[] = array('text' => $this->lang->repo->downloadDiff, 'icon' => 'download', 'data-link' => $this->repo->createLink('download', "repoID=$repoID&path={path}&fromRevision=$oldRevision&toRevision=$newRevision&type=path"), 'id' => 'repoDownloadCode'); +if(!$inModal) +{ + if(common::hasPriv('repo', 'download')) $dropMenus[] = array('text' => $this->lang->repo->downloadDiff, 'icon' => 'download', 'data-link' => $this->repo->createLink('download', "repoID=$repoID&path={path}&fromRevision=$oldRevision&toRevision=$newRevision&type=path"), 'id' => 'repoDownloadCode'); + + $dropMenus[] = array('text' => $this->lang->repo->viewDiffList['inline'], 'icon' => 'snap-house', 'id' => 'inline', 'class' => 'inline-appose'); + $dropMenus[] = array('text' => $this->lang->repo->viewDiffList['appose'], 'icon' => 'col-archive', 'id' => 'appose', 'class' => 'inline-appose'); +} -$dropMenus[] = array('text' => $this->lang->repo->viewDiffList['inline'], 'icon' => 'snap-house', 'id' => 'inline', 'class' => 'inline-appose'); -$dropMenus[] = array('text' => $this->lang->repo->viewDiffList['appose'], 'icon' => 'col-archive', 'id' => 'appose', 'class' => 'inline-appose'); div( set::id('fileTabs'), tabs @@ -56,7 +61,7 @@ div( ), div(set::id('tab-' . $currentEntry)) ), - dropdown + $inModal ? null : dropdown ( set::arrow(false), set::staticMenu(true), @@ -77,7 +82,7 @@ div( ) ); -sidebar +$inModal ? null : sidebar ( set::side('left'), setClass('repo-sidebar canvas p-2'), diff --git a/module/repo/ui/monaco.html.php b/module/repo/ui/monaco.html.php index 66c1b63177..efbf0e17a3 100644 --- a/module/repo/ui/monaco.html.php +++ b/module/repo/ui/monaco.html.php @@ -12,14 +12,21 @@ declare(strict_types=1); namespace zin; -$module = $app->tab == 'devops' ? 'repo' : $app->tab; -dropmenu +$module = $app->tab == 'devops' ? 'repo' : $app->tab; +$inModal = isInModal() || !empty($fromModal); +$inModal ? null : dropmenu ( set::module($module), set::tab($module), set::url(createLink($module, 'ajaxGetDropMenu', "objectID=$objectID&module={$app->rawModule}&method={$app->rawMethod}")) ); +if($inModal) +{ + to::header(false); + to::main(false); +} + jsVar('isonlybody', isonlybody()); jsVar('entry', $entry); jsVar('repoID', $repoID); @@ -37,8 +44,8 @@ jsVar('currentLink', $this->createLink('repo', 'view', "repoID=$repoID&objectID= \zin\featureBar(); $monacoDropMenus = array(); -if(common::hasPriv('repo', 'blame')) $monacoDropMenus[] = array('text' => $this->lang->repo->blame, 'icon' => 'blame', 'data-link' => $this->repo->createLink('blame', "repoID=$repoID&objectID=$objectID&entry={path}&revision=$revision&encoding=$encoding"), 'class' => 'repoDropDownMenu'); -if(common::hasPriv('repo', 'download')) $monacoDropMenus[] = array('text' => $this->lang->repo->download, 'icon' => 'download', 'data-link' => $this->repo->createLink('download', "repoID=$repoID&path={path}&fromRevision=$revision"), 'class' => 'repoDropDownMenu'); +if(!$inModal && common::hasPriv('repo', 'blame')) $monacoDropMenus[] = array('text' => $this->lang->repo->blame, 'icon' => 'blame', 'data-link' => $this->repo->createLink('blame', "repoID=$repoID&objectID=$objectID&entry={path}&revision=$revision&encoding=$encoding"), 'class' => 'repoDropDownMenu'); +if(!$inModal && common::hasPriv('repo', 'download')) $monacoDropMenus[] = array('text' => $this->lang->repo->download, 'icon' => 'download', 'data-link' => $this->repo->createLink('download', "repoID=$repoID&path={path}&fromRevision=$revision"), 'class' => 'repoDropDownMenu'); $tabs = array(array('name' => 'branch', 'text' => $lang->repo->branch), array('name' => 'tag', 'text' => $lang->repo->tag)); $menuData = $repo->SCM == 'Subversion' ? array() : array('branch' => $dropMenus['branchMenus'], 'tag' => $dropMenus['tagMenus']); @@ -87,7 +94,7 @@ div( ) ); -helper::isAjaxRequest('modal') ? null : sidebar +$inModal ? null : sidebar ( set::side('left'), setClass('repo-sidebar canvas'), diff --git a/module/svn/control.php b/module/svn/control.php index da7f83ee37..01afecf245 100644 --- a/module/svn/control.php +++ b/module/svn/control.php @@ -47,7 +47,7 @@ class svn extends control { $entry = $this->repo->encodePath(str_ireplace($repo->path, '', $url)); $oldRevision = $revision - 1; - $this->locate($this->repo->createLink('diff', "repoID=$repo->id&objectID=0&entry=$entry&oldRevision=$oldRevision&revision=$revision", 'html', true)); + return print($this->fetch('repo', 'diff', "repoID=$repo->id&objectID=0&entry=$entry&oldRevision=$oldRevision&revision=$revision")); } } } @@ -81,7 +81,7 @@ class svn extends control if(strpos(strtolower($url), strtolower($repo->path)) === 0) { $entry = $this->repo->encodePath(str_ireplace(strtolower($repo->path), '', $url)); - $this->locate($this->repo->createLink('view', "repoID=$repo->id&objectID=0&entry=$entry&revision=$revision", 'html', true)); + return print($this->fetch('repo', 'view', "repoID=$repo->id&objectID=0&entry=$entry&revision=$revision")); } } }