diff options
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | 2022-10-17 19:05:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 19:05:51 +0300 |
commit | 8e8fdb3f741b5edebab1a9bcdf7936c7521280d7 (patch) | |
tree | 842f473ac3bdb371ae5742570b6893d9d1106e4c | |
parent | 9e57981437fabe5ebb488c15f7d1a6d77d2c5e18 (diff) | |
parent | 88addc2834169d132b17f55fceaf7073f020a23e (diff) |
Merge pull request #540 from nextcloud/dependabot/composer/vimeo/psalm-4.29.0
-rw-r--r-- | .github/workflows/phpunit.yml | 16 | ||||
-rw-r--r-- | composer.lock | 57 | ||||
-rw-r--r-- | lib/Dashboard/Widget.php | 27 | ||||
-rw-r--r-- | lib/Manager.php | 5 | ||||
-rw-r--r-- | lib/Model/AnnouncementMapper.php | 5 |
5 files changed, 76 insertions, 34 deletions
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 4948d32..d8351be 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,6 +1,18 @@ name: PHPUnit -on: pull_request +on: + pull_request: + paths: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' concurrency: group: lint-phpunit-${{ github.head_ref || github.run_id }} @@ -156,7 +168,7 @@ jobs: services: postgres: - image: postgres + image: postgres:14 ports: - 4444:5432/tcp env: diff --git a/composer.lock b/composer.lock index 163187c..240e465 100644 --- a/composer.lock +++ b/composer.lock @@ -1489,25 +1489,30 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.1", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "ext-tokenizer": "*", - "psalm/phar": "^4.8" + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" }, "type": "library", "extra": { @@ -1533,9 +1538,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" }, - "time": "2022-03-15T21:29:03+00:00" + "time": "2022-10-14T12:47:21+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3120,16 +3125,16 @@ }, { "name": "symfony/console", - "version": "v5.4.13", + "version": "v5.4.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be" + "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", + "url": "https://api.github.com/repos/symfony/console/zipball/984ea2c0f45f42dfed01d2f3987b187467c4b16d", + "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d", "shasum": "" }, "require": { @@ -3199,7 +3204,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.13" + "source": "https://github.com/symfony/console/tree/v5.4.14" }, "funding": [ { @@ -3215,7 +3220,7 @@ "type": "tidelift" } ], - "time": "2022-08-26T13:50:20+00:00" + "time": "2022-10-07T08:01:20+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4424,16 +4429,16 @@ }, { "name": "symfony/string", - "version": "v5.4.13", + "version": "v5.4.14", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "2900c668a32138a34118740de3e4d5a701801f53" + "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/2900c668a32138a34118740de3e4d5a701801f53", - "reference": "2900c668a32138a34118740de3e4d5a701801f53", + "url": "https://api.github.com/repos/symfony/string/zipball/089e7237497fae7a9c404d0c3aeb8db3254733e4", + "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4", "shasum": "" }, "require": { @@ -4490,7 +4495,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.13" + "source": "https://github.com/symfony/string/tree/v5.4.14" }, "funding": [ { @@ -4506,7 +4511,7 @@ "type": "tidelift" } ], - "time": "2022-09-01T01:52:16+00:00" + "time": "2022-10-05T15:16:54+00:00" }, { "name": "theseer/tokenizer", @@ -4560,16 +4565,16 @@ }, { "name": "vimeo/psalm", - "version": "4.28.0", + "version": "4.29.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "52e96bea381e6cb07a672aefec791a5817694a26" + "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/52e96bea381e6cb07a672aefec791a5817694a26", - "reference": "52e96bea381e6cb07a672aefec791a5817694a26", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", + "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", "shasum": "" }, "require": { @@ -4662,9 +4667,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.28.0" + "source": "https://github.com/vimeo/psalm/tree/4.29.0" }, - "time": "2022-10-07T16:13:24+00:00" + "time": "2022-10-11T17:09:17+00:00" }, { "name": "webmozart/assert", diff --git a/lib/Dashboard/Widget.php b/lib/Dashboard/Widget.php index 883c8dd..e39c9ea 100644 --- a/lib/Dashboard/Widget.php +++ b/lib/Dashboard/Widget.php @@ -30,6 +30,9 @@ use OCA\AnnouncementCenter\Manager; use OCA\AnnouncementCenter\Model\Announcement; use OCP\AppFramework\Services\IInitialState; use OCP\Dashboard\IAPIWidget; +use OCP\Dashboard\IButtonWidget; +use OCP\Dashboard\IIconWidget; +use OCP\Dashboard\Model\WidgetButton; use OCP\Dashboard\Model\WidgetItem; use OCP\IDateTimeFormatter; use OCP\IL10N; @@ -37,7 +40,7 @@ use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Util; -class Widget implements IAPIWidget { +class Widget implements IAPIWidget, IButtonWidget, IIconWidget { private Manager $manager; private IUserManager $userManager; private IURLGenerator $url; @@ -99,6 +102,26 @@ class Widget implements IAPIWidget { /** * @inheritDoc */ + public function getIconUrl(): string { + return $this->url->getAbsoluteURL($this->url->imagePath('announcementcenter', 'announcementcenter-dark.svg')); + } + + /** + * @return WidgetButton[] + */ + public function getWidgetButtons(string $userId): array { + $buttons = []; + $buttons[] = new WidgetButton( + WidgetButton::TYPE_MORE, + $this->getUrl(), + $this->l10n->t('Read more') + ); + return $buttons; + } + + /** + * @inheritDoc + */ public function load(): void { $this->initialState->provideLazyInitialState(Application::APP_ID . '_dashboard', function () { $announcements = $this->manager->getAnnouncements(); @@ -126,7 +149,7 @@ class Widget implements IAPIWidget { } public function getItems(string $userId, ?string $since = null, int $limit = 7): array { - $announcements = $this->manager->getAnnouncements((int) $since); + $announcements = $this->manager->getAnnouncements((int) $since, $limit); $data = array_map([$this, 'renderAnnouncementAPI'], $announcements); return $data; } diff --git a/lib/Manager.php b/lib/Manager.php index ea59b26..cd618ee 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -207,16 +207,17 @@ class Manager { /** * @param int $offsetId + * @param int $limit * @return Announcement[] */ - public function getAnnouncements(int $offsetId = 0): array { + public function getAnnouncements(int $offsetId = 0, int $limit = 7): array { $userGroups = $this->getUserGroups(); $memberOfAdminGroups = array_intersect($this->getAdminGroups(), $userGroups); if (!empty($memberOfAdminGroups)) { $userGroups = []; } - $announcements = $this->announcementMapper->getAnnouncements($userGroups, $offsetId); + $announcements = $this->announcementMapper->getAnnouncements($userGroups, $offsetId, $limit); return $announcements; } diff --git a/lib/Model/AnnouncementMapper.php b/lib/Model/AnnouncementMapper.php index f88d0bc..fb761ab 100644 --- a/lib/Model/AnnouncementMapper.php +++ b/lib/Model/AnnouncementMapper.php @@ -71,16 +71,17 @@ class AnnouncementMapper extends QBMapper { /** * @param array $userGroups * @param int $offsetId + * @param int $limit * @return Announcement[] */ - public function getAnnouncements(array $userGroups, int $offsetId = 0): array { + public function getAnnouncements(array $userGroups, int $offsetId = 0, int $limit = 7): array { $query = $this->db->getQueryBuilder(); $query->select('a.announcement_id') ->from($this->getTableName(), 'a') ->orderBy('a.announcement_time', 'DESC') ->groupBy('a.announcement_id') - ->setMaxResults(7); + ->setMaxResults($limit); if (!empty($userGroups)) { $query->leftJoin('a', 'announcements_map', 'ag', $query->expr()->eq( |