Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Feb 9, 2024
1 parent 29a90f6 commit ba4f04f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
4 changes: 2 additions & 2 deletions application/controllers/IssuesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ protected function requireMonitoringInfo()
/* if (Module::exists('icingadb') && $this->hasPermission()) {
}*/
$auth = Auth::getInstance();
$user = Auth::getInstance()->getUser();
$authenticated = Icinga::app()->isWeb() && Auth::getInstance()->isAuthenticated();
if (
! Module::exists('monitoring')
|| ($authenticated && ! $auth->getUser()->can('module/monitoring'))
|| ($authenticated && $user && $user->can('modules/monitoring'))
) {
$backend = new IcingadbBackend();
} else {
Expand Down
14 changes: 0 additions & 14 deletions library/Jira/Web/RenderingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ public function linkToMonitoringHost($host)
]);
}

protected function useIcingaDbAsBackend()
{
$auth = Auth::getInstance();
$authenticated = Icinga::app()->isWeb() && Auth::getInstance()->isAuthenticated();
if (
! Module::exists('monitoring')
|| ($authenticated && ! $auth->getUser()->can('module/monitoring'))
) {
return true;
}

return false;
}

public function linkToMonitoringService($host, $service)
{
if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) {
Expand Down
46 changes: 24 additions & 22 deletions library/Jira/Web/Table/IssueDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ protected function assemble()
$this->translate('Created') => $helper->shortTimeSince($fields->created, false),
]);

$hostLink = null;
$serviceLink = null;
$summary = $this->getSummary(
$fields->summary,
$fields->created,
$fields->description
);

if ($this->host !== null) {
$this->addNameValueRow(
$this->translate('Host'),
$hostLink
$this->getLinkToMonitoringHost()
);
}
if ($this->service !== null) {
Expand All @@ -109,19 +113,10 @@ protected function assemble()
);
}

$summary = $this->getSummary(

);

$this->addComments(array_reverse($fields->comment->comments));
$this->addComment(
$fields->summary,
$fields->created,
$fields->description
$summary
);

$hostLink = $this->getLinkToMonitoringHost();
$serviceLink = $this->getLinkToMonitoringService();
}

protected function addWideRow($content)
Expand All @@ -136,9 +131,11 @@ protected function addComments($comments)
foreach ($comments as $comment) {
if (property_exists($comment, 'author')) {
$this->addComment(
$this->formatAuthor($comment->author),
$comment->created,
$comment->body
$this->getSummary(
$this->formatAuthor($comment->author),
$comment->created,
$comment->body
)
);
}
}
Expand Down Expand Up @@ -181,28 +178,28 @@ protected function replaceLinks($string)
return \preg_replace_callback('/\[([^|]+)\|([^]]+)]/', function ($match) {
$link = Html::tag('a', ['href' => $match[2], 'target' => '_blank'], $match[1]);
if ($this->service && $this->service === $match[1]) {
$serviceLink = $link;
$serviceLink = clone $link;
$serviceLink->setContent([new Icon('cog'), $match[1]]);
$serviceLink->addAttributes(
['title' => t('Show Icinga Service State')]
);
$this->setLinkToMonitoringService($serviceLink);
} else {
$hostLink = $link;
$hostLink = clone $link;
$hostLink->setContent([new Icon('server'), $match[1]]);
$hostLink->addAttributes(
['title' => t('Show Icinga Host State')]
);
$this->setLinkToMonitoringHost($link);
$this->setLinkToMonitoringHost($hostLink);
}

return $link;
}, $string);
}

protected function addComment($author, $time, $body)
protected function getSummary($author, $time, $body)

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has no return type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $author with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $body with no type specified.

Check failure on line 200 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::getSummary() has parameter $time with no type specified.
{
return $this->addWideRow([
return [
Html::tag('h3', null, Html::sprintf(
'%s: %s',
$this->helper->shortTimeSince($time),
Expand All @@ -213,7 +210,12 @@ protected function addComment($author, $time, $body)
['class' => 'comment'],
$this->formatBody($body)
),
]);
];
}

protected function addComment($summary)

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.

Check failure on line 216 in library/Jira/Web/Table/IssueDetails.php

View workflow job for this annotation

GitHub Actions / Static analysis for php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\Web\Table\IssueDetails::addComment() has parameter $summary with no type specified.
{
return $this->addWideRow($summary);
}

protected function createNameValueRow($name, $value)
Expand Down

0 comments on commit ba4f04f

Please sign in to comment.