Skip to content

Commit dc6e44f

Browse files
authored
Merge pull request #243 from nextcloud/fix/dashboard-widget-content
fix: show the content of the dashboard widget again
2 parents 4dfbb80 + 1ea44cc commit dc6e44f

5 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
used to render issue and pull request bodies.
1818
- Update bundled JavaScript dependencies to close the remaining high-severity
1919
advisories (dompurify, js-yaml, nanoid).
20+
- Show the message of the dashboard widget again, `NcEmptyContent` no longer has the
21+
`title` prop it was passed in.
22+
- Ask users who did not connect a GitHub account to connect one in the dashboard widget,
23+
instead of reporting an error and requesting the GitHub API without a token.
2024

2125
## 3.2.7 - 2026-08-18
2226

‎lib/Controller/GithubAPIController.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct(
3636
*/
3737
#[NoAdminRequired]
3838
public function getNotifications(?string $since = null): DataResponse {
39+
if (!$this->githubAPIService->isUserConnected($this->userId)) {
40+
// the dashboard widget shows its "connect" prompt on 400
41+
return new DataResponse([], Http::STATUS_BAD_REQUEST);
42+
}
3943
$result = $this->githubAPIService->getNotifications($this->userId, false, $since);
4044
if (isset($result['error'])) {
4145
$response = new DataResponse($result['error'], 401);

‎lib/Service/GithubAPIService.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public function __construct(
4545
$this->client = $clientService->newClient();
4646
}
4747

48+
/**
49+
* Whether the user connected a GitHub account, with OAuth or with a personal access token
50+
*/
51+
public function isUserConnected(string $userId): bool {
52+
return $this->secretService->getEncryptedUserValue($userId, 'token') !== '';
53+
}
54+
4855
/**
4956
* Request an avatar image
5057
* @param string $userId

‎src/views/Dashboard.vue‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@markRead="onMarkRead">
1414
<template #empty-content>
1515
<NcEmptyContent v-if="emptyContentMessage"
16-
:title="emptyContentMessage">
16+
:name="emptyContentMessage">
1717
<template #icon>
1818
<component :is="emptyContentIcon" />
1919
</template>
@@ -89,7 +89,6 @@ export default {
8989
loop: null,
9090
state: 'loading',
9191
settingsUrl: generateUrl('/settings/user/connected-accounts'),
92-
darkThemeColor: OCA.Accessibility?.theme === 'dark' ? '181818' : 'ffffff',
9392
itemMenu: {
9493
markRead: {
9594
text: t('integration_github', 'Mark as read'),

‎tests/unit/Controller/GithubAPIControllerTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ public function testGetNotifications(): void {
105105
$this->assertEquals($correctResult, $result->getData());
106106
}
107107

108+
public function testGetNotificationsWithoutAGithubAccount(): void {
109+
\OC::$server->get(IConfig::class)->deleteUserValue(self::TEST_USER1, self::APP_NAME, 'token');
110+
$this->iClient->expects($this->never())->method('get');
111+
112+
$result = $this->githubApiController->getNotifications();
113+
114+
$this->assertEquals(400, $result->getStatus());
115+
}
116+
108117
public function testUnsubscribeNotification(): void {
109118
$id = 12345;
110119

0 commit comments

Comments
 (0)