summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-25 13:26:52 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-08-25 16:07:34 +0200
commita6b44acdde9c991e7ebe17e58adee1829c5e113c (patch)
tree8f32674f8de2da67948dbe06f40d324fe2b2914a
parent71ed9aa258cc979a8de5f33489a9bc860b687c4e (diff)
Fix some issues
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--.github/workflows/lint-stylelint.yml46
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/Service/StatusService.php2
-rw-r--r--lib/Settings/AdminSettings.php4
-rw-r--r--src/components/AdminSettings.vue8
-rw-r--r--tests/Unit/Controller/AdminControllerTest.php156
-rw-r--r--tests/Unit/Service/StatusServiceTest.php2
7 files changed, 9 insertions, 210 deletions
diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml
deleted file mode 100644
index c3fcd06ad..000000000
--- a/.github/workflows/lint-stylelint.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-# This workflow is provided via the organization template repository
-#
-# https://github.com/nextcloud/.github
-# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
-# SPDX-FileCopyrightText: Nextcloud contributors
-# SPDX-License-Identifier: AGPL-3.0-or-later
-
-name: Lint
-
-on:
- pull_request:
- push:
- branches:
- - master
- - stable*
-
-jobs:
- lint:
- runs-on: ubuntu-latest
-
- name: stylelint
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Read package.json node and npm engines version
- uses: skjnldsv/read-package-engines-version-actions@v1.1
- id: versions
- with:
- fallbackNode: '^12'
- fallbackNpm: '^6'
-
- - name: Set up node $
- uses: actions/setup-node@v2
- with:
- node-version: $
-
- - name: Set up npm $
- run: npm i -g npm@"$"
-
- - name: Install dependencies
- run: npm ci
-
- - name: Lint
- run: npm run stylelint
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 13381396a..e8df86fe7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1
# Unreleased
## [18.x.x]
### Changed
+- Ported the admin settings to vue (#2353)
### Fixed
- Fix PHP 8.1 deprecations (#1861)
diff --git a/lib/Service/StatusService.php b/lib/Service/StatusService.php
index a15f30c76..803a3a7e4 100644
--- a/lib/Service/StatusService.php
+++ b/lib/Service/StatusService.php
@@ -48,7 +48,7 @@ class StatusService
$cronOff = !boolval($this->settings->getAppValue(
Application::NAME,
'useCronUpdates',
- Application::DEFAULT_SETTINGS['useCronUpdates']
+ (string)Application::DEFAULT_SETTINGS['useCronUpdates']
));
// check for cron modes which may lead to problems
diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php
index 118747ba8..c29b5d46c 100644
--- a/lib/Settings/AdminSettings.php
+++ b/lib/Settings/AdminSettings.php
@@ -30,8 +30,8 @@ class AdminSettings implements ISettings
$this->initialState->provideInitialState($setting, $this->config->getAppValue(
Application::NAME,
$setting,
- Application::DEFAULT_SETTINGS[$setting])
- );
+ (string)Application::DEFAULT_SETTINGS[$setting]
+ ));
}
return new TemplateResponse(Application::NAME, 'admin', []);
diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue
index d3496ffdd..b822829f9 100644
--- a/src/components/AdminSettings.vue
+++ b/src/components/AdminSettings.vue
@@ -87,8 +87,8 @@ export default {
appId: 'news',
key,
})
- if (value === true || value === false) {
- value = value ? '0' : '1'
+ if (key === 'useCronUpdates') {
+ value = value ? '1' : '0'
}
try {
const { data } = await axios.post(url, {
@@ -99,7 +99,7 @@ export default {
})
} catch (e) {
this.handleResponse({
- errorMessage: t('news', 'Unable to update share by mail config'),
+ errorMessage: t('news', 'Unable to update news config'),
error: e,
})
}
@@ -122,7 +122,7 @@ export default {
margin-bottom: 1rem;
}
- input {
+ .input-field {
max-width: 350px;
}
}
diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php
deleted file mode 100644
index a9d7bb127..000000000
--- a/tests/Unit/Controller/AdminControllerTest.php
+++ /dev/null
@@ -1,156 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-namespace OCA\News\Tests\Unit\Controller;
-
-use OCA\News\Controller\AdminController;
-use OCA\News\Service\ItemService;
-use OCP\IConfig;
-use OCP\IRequest;
-use PHPUnit\Framework\TestCase;
-
-class AdminControllerTest extends TestCase
-{
- /**
- * @var string
- */
- private $appName;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|IRequest
- */
- private $request;
-
- /**
- * @var AdminController
- */
- private $controller;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|IConfig
- */
- private $config;
-
- /**
- * @var \PHPUnit\Framework\MockObject\MockObject|ItemService
- */
- private $itemService;
-
- /**
- * Gets run before each test
- */
- public function setUp(): void
- {
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->itemService = $this->getMockBuilder(ItemService::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->controller = new AdminController($this->request, $this->config, $this->itemService);
- }
-
- /**
- * Test \OCA\News\Controller\AdminController::index
- */
- public function testIndex()
- {
- $expected = [
- 'autoPurgeMinimumInterval' => 1,
- 'autoPurgeCount' => 2,
- 'maxRedirects' => 3,
- 'feedFetcherTimeout' => 4,
- 'useCronUpdates' => false,
- 'exploreUrl' => 'test',
- 'updateInterval' => 3601
- ];
- $map = [
- ['news','autoPurgeMinimumInterval', 60, 1],
- ['news','autoPurgeCount', 200, 2],
- ['news','maxRedirects', 10, 3],
- ['news','feedFetcherTimeout', 60, 4],
- ['news','useCronUpdates', true, false,],
- ['news','exploreUrl', '', 'test'],
- ['news','updateInterval', 3600, 3601]
- ];
- $this->config->expects($this->exactly(count($map)))
- ->method('getAppValue')
- ->will($this->returnValueMap($map));
-
- $response = $this->controller->index();
- $data = $response->getParams();
- $name = $response->getTemplateName();
- $type = $response->getRenderAs();
-
- $this->assertEquals($type, 'blank');
- $this->assertEquals($name, 'admin');
- $this->assertEquals($expected, $data);
- }
-
-
- public function testUpdate()
- {
- $expected = [
- 'autoPurgeMinimumInterval' => 1,
- 'autoPurgeCount' => 2,
- 'maxRedirects' => 3,
- 'feedFetcherTimeout' => 4,
- 'useCronUpdates' => false,
- 'exploreUrl' => 'test',
- 'updateInterval' => 3601
- ];
-
- $this->config->expects($this->exactly(count($expected)))
- ->method('setAppValue')
- ->withConsecutive(
- ['news','autoPurgeMinimumInterval', 1],
- ['news','autoPurgeCount', 2],
- ['news','maxRedirects', 3],
- ['news','feedFetcherTimeout', 4],
- ['news','useCronUpdates', false],
- ['news','exploreUrl', 'test'],
- ['news','updateInterval', 3601]
- );
-
- $map = [
- ['news','autoPurgeMinimumInterval', 60, 1],
- ['news','autoPurgeCount', 200, 2],
- ['news','maxRedirects', 10, 3],
- ['news','feedFetcherTimeout', 60, 4],
- ['news','useCronUpdates', true, false,],
- ['news','exploreUrl', '', 'test'],
- ['news','updateInterval', 3600, 3601]
- ];
- $this->config->expects($this->exactly(count($map)))
- ->method('getAppValue')
- ->will($this->returnValueMap($map));
-
- $response = $this->controller->update(
- $expected['autoPurgeMinimumInterval'],
- $expected['autoPurgeCount'],
- $expected['maxRedirects'],
- $expected['feedFetcherTimeout'],
- $expected['useCronUpdates'],
- $expected['exploreUrl'],
- $expected['updateInterval']
- );
-
- $this->assertEquals($expected, $response);
- }
-
-}
diff --git a/tests/Unit/Service/StatusServiceTest.php b/tests/Unit/Service/StatusServiceTest.php
index dfe3dfd55..bb47ef537 100644
--- a/tests/Unit/Service/StatusServiceTest.php
+++ b/tests/Unit/Service/StatusServiceTest.php
@@ -60,7 +60,7 @@ class StatusServiceTest extends TestCase
->will($this->returnValueMap([
['news', 'installed_version', '', '1.0'],
['core', 'backgroundjobs_mode', '', 'cron'],
- ['news', 'useCronUpdates', true, true],
+ ['news', 'useCronUpdates', (string)true, (string)true],
]));
$this->connection->expects($this->exactly(1))