Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Added support for Nextcloud 36

### Fixed

- Show the content of the dashboard widgets again, they stayed empty because of an error when loading
- Ask users who did not connect a Jira account to connect one in the dashboard widgets, instead of telling them there are no notifications

## 1.4.3 - 2026-07-27

### Changed
Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/JiraAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function getJiraAvatar(string $accountId = '', string $accountKey = ''):
* @return DataResponse
*/
public function getNotifications(?string $since = null, bool $filterProjects = false): DataResponse {
if (!$this->jiraAPIService->isUserConnected($this->userId)) {
// the dashboard widget shows its "connect" prompt on 400
return new DataResponse([], 400);
}
$result = $this->jiraAPIService->getNotifications($this->userId, $since, 7, $filterProjects);
if (!isset($result['error'])) {
$response = new DataResponse($result);
Expand Down
8 changes: 8 additions & 0 deletions lib/Service/JiraAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ public function getJiraResources(string $userId): array {
return ($resources && count($resources) > 0) ? $resources : [];
}

/**
* Whether the user connected a Jira account, with OAuth for Jira Cloud or with basic auth for a self-hosted Jira
*/
public function isUserConnected(string $userId): bool {
return $this->config->getUserValue($userId, Application::APP_ID, 'token') !== ''
|| $this->config->getUserValue($userId, Application::APP_ID, 'basic_auth_header') !== '';
}

/**
* @param string $userId
* @param ?string $since
Expand Down
8 changes: 3 additions & 5 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
:loading="state === 'loading'">
<template #empty-content>
<NcEmptyContent
v-if="emptyContentMessage">
v-if="emptyContentMessage"
:description="emptyContentMessage">
<template #icon>
<component :is="emptyContentIcon" />
</template>
<template #desc>
{{ emptyContentMessage }}
<template #action>
<div v-if="state === 'no-token' || state === 'error'" class="connect-button">
<a :href="settingsUrl">
<NcButton>
Expand Down Expand Up @@ -80,8 +80,6 @@ export default {
loop: null,
state: 'loading',
settingsUrl: generateUrl('/settings/user/connected-accounts'),
themingColor: OCA.Theming ? OCA.Theming.color.replace('#', '') : '0082C9',
darkThemeColor: OCA.Accessibility?.theme === 'dark' ? 'ffffff' : '181818',
windowVisibility: true,
}
},
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/Service/JiraAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,29 @@ public function testSearch() {
$this->assertEquals(1, sizeof($expected));
$this->assertEquals('FIRST-1', $expected[0]['key']);
}

private function stubUserConfig(string $token, string $basicAuthHeader): void {
$this->config->method('getUserValue')->willReturnCallback(
fn ($userId, $appName, $key, $default = '') => match ($key) {
'token' => $token,
'basic_auth_header' => $basicAuthHeader,
default => $default,
}
);
}

public function testUserWithoutAnyJiraAccountIsNotConnected(): void {
$this->stubUserConfig('', '');
$this->assertFalse($this->apiService->isUserConnected('user1'));
}

public function testUserWithAJiraCloudTokenIsConnected(): void {
$this->stubUserConfig('encrypted-token', '');
$this->assertTrue($this->apiService->isUserConnected('user1'));
}

public function testUserWithSelfHostedJiraCredentialsIsConnected(): void {
$this->stubUserConfig('', 'encrypted-basic-auth-header');
$this->assertTrue($this->apiService->isUserConnected('user1'));
}
}
Loading