Skip to content

Commit f1b7ac4

Browse files
authored
Merge pull request #11890 from nextcloud/flip-about-shortcuts-add-version
feat: show mail version in settings
2 parents 67d1d2a + d206d4d commit f1b7ac4

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

lib/Controller/PageController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use OCA\Mail\Service\QuickActionsService;
2626
use OCA\Mail\Service\SmimeService;
2727
use OCA\Viewer\Event\LoadViewer;
28+
use OCP\App\IAppManager;
2829
use OCP\AppFramework\Controller;
2930
use OCP\AppFramework\Http\Attribute\OpenAPI;
3031
use OCP\AppFramework\Http\ContentSecurityPolicy;
@@ -74,7 +75,8 @@ class PageController extends Controller {
7475
private InternalAddressService $internalAddressService;
7576
private QuickActionsService $quickActionsService;
7677

77-
public function __construct(string $appName,
78+
public function __construct(
79+
string $appName,
7880
IRequest $request,
7981
IURLGenerator $urlGenerator,
8082
IConfig $config,
@@ -97,6 +99,7 @@ public function __construct(string $appName,
9799
InternalAddressService $internalAddressService,
98100
IAvailabilityCoordinator $availabilityCoordinator,
99101
QuickActionsService $quickActionsService,
102+
private IAppManager $appManager,
100103
) {
101104
parent::__construct($appName, $request);
102105

@@ -144,6 +147,11 @@ public function index(): TemplateResponse {
144147
$this->config->getSystemValue('version', '0.0.0')
145148
);
146149

150+
$this->initialStateService->provideInitialState(
151+
'mailVersion',
152+
$this->appManager->getAppVersion('mail'),
153+
);
154+
147155
$mailAccounts = $this->accountService->findByUserId($this->currentUserId);
148156
$accountsJson = [];
149157
foreach ($mailAccounts as $mailAccount) {

src/components/AppSettingsMenu.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@
230230
</NcCheckboxRadioSwitch>
231231
</p>
232232
</NcAppSettingsSection>
233-
<NcAppSettingsSection id="about-settings" :name="t('mail', 'About')">
234-
<p>{{ t('mail', 'This application includes CKEditor, an open-source editor. Copyright © CKEditor contributors. Licensed under GPLv2.') }}</p>
235-
</NcAppSettingsSection>
236233
<NcAppSettingsSection id="keyboard-shortcut-settings" :name="t('mail', 'Keyboard shortcuts')">
237234
<dl>
238235
<div>
@@ -279,6 +276,13 @@
279276
</div>
280277
</dl>
281278
</NcAppSettingsSection>
279+
<NcAppSettingsSection id="about-settings" :name="t('mail', 'About')">
280+
<p>{{ t('mail', 'This application includes CKEditor, an open-source editor. Copyright © CKEditor contributors. Licensed under GPLv2.') }}</p>
281+
</NcAppSettingsSection>
282+
<p
283+
class="app-settings-section__version">
284+
{{ t('mail', 'Mail version: {version}', { version: mailVersion }) }}
285+
</p>
282286
<NcDialog
283287
:open.sync="textBlockDialogOpen"
284288
:name="t('mail', 'New text block')"
@@ -444,6 +448,10 @@ export default {
444448
return this.mainStore.getPreference('allow-new-accounts', true)
445449
},
446450
451+
mailVersion() {
452+
return this.mainStore.getPreference('mailVersion', '0.0.0')
453+
},
454+
447455
layoutMode: {
448456
get() {
449457
return this.mainStore.getPreference('layout-mode', 'vertical-split')
@@ -769,6 +777,12 @@ p.app-settings {
769777
770778
.app-settings-section {
771779
list-style: none;
780+
781+
&__version {
782+
margin-block-end: calc(2 * var(--default-grid-baseline));
783+
text-align: center;
784+
color: var(--color-text-maxcontrast);
785+
}
772786
}
773787
774788
.text-block-buttons {

src/init.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export default function initAfterAppCreation() {
2222
key: 'ncVersion',
2323
value: loadState('mail', 'ncVersion'),
2424
})
25+
mainStore.savePreferenceMutation({
26+
key: 'mailVersion',
27+
value: loadState('mail', 'mailVersion'),
28+
})
2529

2630
mainStore.savePreferenceMutation({
2731
key: 'sort-order',

tests/Unit/Controller/PageControllerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use OCA\Mail\Service\OutboxService;
2626
use OCA\Mail\Service\QuickActionsService;
2727
use OCA\Mail\Service\SmimeService;
28+
use OCP\App\IAppManager;
2829
use OCP\AppFramework\Http\ContentSecurityPolicy;
2930
use OCP\AppFramework\Http\RedirectResponse;
3031
use OCP\AppFramework\Http\TemplateResponse;
@@ -112,6 +113,7 @@ class PageControllerTest extends TestCase {
112113
private QuickActionsService|MockObject $quickActionsService;
113114

114115
private IAvailabilityCoordinator&MockObject $availabilityCoordinator;
116+
private IAppManager $appManager;
115117

116118
protected function setUp(): void {
117119
parent::setUp();
@@ -139,6 +141,8 @@ protected function setUp(): void {
139141
$this->internalAddressService = $this->createMock(InternalAddressService::class);
140142
$this->availabilityCoordinator = $this->createMock(IAvailabilityCoordinator::class);
141143
$this->quickActionsService = $this->createMock(QuickActionsService::class);
144+
$this->appManager = $this->createMock(IAppManager::class);
145+
$this->appManager->method('getAppVersion')->willReturn('0.0.1-dev.0');
142146

143147
$this->controller = new PageController(
144148
$this->appName,
@@ -164,6 +168,7 @@ protected function setUp(): void {
164168
$this->internalAddressService,
165169
$this->availabilityCoordinator,
166170
$this->quickActionsService,
171+
$this->appManager,
167172
);
168173
}
169174

@@ -314,11 +319,12 @@ public function testIndex(): void {
314319
->method('findAll')
315320
->with($this->userId)
316321
->willReturn([]);
317-
$this->initialState->expects($this->exactly(24))
322+
$this->initialState->expects($this->exactly(25))
318323
->method('provideInitialState')
319324
->withConsecutive(
320325
['debug', true],
321326
['ncVersion', '26.0.0'],
327+
['mailVersion', '0.0.1-dev.0'],
322328
['accounts', $accountsJson],
323329
['account-settings', []],
324330
['tags', []],

0 commit comments

Comments
 (0)