+
+
-
@@ -100,9 +101,14 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showError, showSuccess } from '@nextcloud/dialogs'
-import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
-import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
-import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
+import { confirmPassword } from '@nextcloud/password-confirmation'
+import {
+ NcSettingsSection,
+ NcCheckboxRadioSwitch,
+ NcEmptyContent,
+ NcLoadingIcon,
+} from '@nextcloud/vue'
+
import AlertCircleOutline from 'vue-material-design-icons/AlertCircleOutline.vue'
import BugReport from './BugReport.vue'
@@ -113,11 +119,13 @@ export default {
NcSettingsSection,
NcCheckboxRadioSwitch,
NcEmptyContent,
+ NcLoadingIcon,
BugReport,
AlertCircleOutline,
},
data() {
return {
+ loadingSettings: false,
settings: [],
mappedSettings: {},
remote_filesize_limit: null,
@@ -142,6 +150,7 @@ export default {
})
},
_getSettings() {
+ this.loadingSettings = true
axios.get(generateUrl('/apps/cloud_py_api/api/v1/settings')).then(res => {
this.settings = res.data
this.settings.forEach(setting => {
@@ -150,18 +159,23 @@ export default {
this.remote_filesize_limit = this.fromBytesToGBytes(Number(this.mappedSettings.remote_filesize_limit.value))
this.usePhpPathFromSettings = JSON.parse(this.mappedSettings.use_php_path_from_settings.value)
this.cpaLoglevel = JSON.parse(this.mappedSettings.cpa_loglevel.value)
+ }).finally(() => {
+ this.loadingSettings = false
})
},
saveChanges() {
- this._updateSettings(this.settings).then(res => {
- if (res.data.success) {
- showSuccess(this.t('cloud_py_api', 'Settings successfully updated'))
- }
- })
- .catch(err => {
+ confirmPassword().then(() => {
+ this._updateSettings(this.settings).then(res => {
+ if (res.data.success) {
+ showSuccess(this.t('cloud_py_api', 'Settings successfully updated'))
+ }
+ }).catch(err => {
console.debug(err)
showError(this.t('cloud_py_api', 'Some error occurred while updating settings'))
})
+ }).catch(() => {
+ showError(this.t('cloud_py_api', 'Password confirmation failed'))
+ })
},
fromBytesToGBytes(bytes) {
return (bytes / Math.pow(1024, 3)).toFixed(1)
diff --git a/src/components/settings/BugReport.vue b/src/components/settings/BugReport.vue
index c7afdbd7..e5dd57c0 100644
--- a/src/components/settings/BugReport.vue
+++ b/src/components/settings/BugReport.vue
@@ -27,8 +27,7 @@
{{ t('mediadc', 'Collect non sensitive system info for bug report') }}
-
@@ -41,7 +40,6 @@
{{ t('mediadc', 'System info') }}
{{ t('mediadc', 'Copy to clipboard') }}
diff --git a/src/main.js b/src/main.js
index 189755df..5dde3e31 100644
--- a/src/main.js
+++ b/src/main.js
@@ -24,7 +24,7 @@
import { generateFilePath } from '@nextcloud/router'
import { getRequestToken } from '@nextcloud/auth'
-import Nextcloudl10n from './mixins/Nextcludl10n.js'
+import { translate, translatePlural } from '@nextcloud/l10n'
import Vue from 'vue'
import AdminSettings from './components/settings/AdminSettings.vue'
@@ -34,7 +34,10 @@ __webpack_nonce__ = btoa(getRequestToken())
// eslint-disable-next-line
__webpack_public_path__ = generateFilePath('cloud_py_api', '', 'js/')
-Vue.mixin(Nextcloudl10n)
+Vue.prototype.t = translate
+Vue.prototype.n = translatePlural
+Vue.prototype.OC = window.OC
+Vue.prototype.OCA = window.OCA
const View = Vue.extend(AdminSettings)
new View().$mount('#cloud_py_api-admin-settings')
diff --git a/src/mixins/Nextcludl10n.js b/src/mixins/Nextcludl10n.js
deleted file mode 100644
index a883c8da..00000000
--- a/src/mixins/Nextcludl10n.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @copyright Copyright (c) 2022-2023 Andrey Borysenko
- *
- * @copyright Copyright (c) 2022-2023 Alexander Piskun
- *
- * @author 2022-2023 Andrey Borysenko
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-import { translate as t, translatePlural as n } from '@nextcloud/l10n'
-
-export default {
- methods: {
- t,
- n,
- },
-}
diff --git a/tests/Integration/Controller/SettingsControllerIntegrationTest.php b/tests/Integration/Controller/SettingsControllerIntegrationTest.php
index 010489ec..8b6f117f 100644
--- a/tests/Integration/Controller/SettingsControllerIntegrationTest.php
+++ b/tests/Integration/Controller/SettingsControllerIntegrationTest.php
@@ -28,15 +28,15 @@
namespace OCA\Cloud_Py_API\Tests\Integration\Service;
-use OCP\AppFramework\App;
-use OCP\AppFramework\Http\JSONResponse;
-
-use PHPUnit\Framework\TestCase;
-
use OCA\Cloud_Py_API\Controller\SettingsController;
use OCA\Cloud_Py_API\Db\Setting;
+
use OCA\Cloud_Py_API\Db\SettingMapper;
+use OCP\AppFramework\App;
+use OCP\AppFramework\Http\JSONResponse;
+use PHPUnit\Framework\TestCase;
+
class SettingsControllerIntegrationTest extends TestCase {
/** @var SettingsController */
private $controller;
diff --git a/tests/Integration/Db/SettingMapperTest.php b/tests/Integration/Db/SettingMapperTest.php
index 5757c0f8..d26873e5 100644
--- a/tests/Integration/Db/SettingMapperTest.php
+++ b/tests/Integration/Db/SettingMapperTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Integration\Db;
-use PHPUnit\Framework\TestCase;
-
use OCA\Cloud_Py_API\Db\SettingMapper;
+use PHPUnit\Framework\TestCase;
+
/**
* @covers \OCA\Cloud_Py_API\Db\SettingMapper
*/
diff --git a/tests/Unit/AppInfo/ApplicationTest.php b/tests/Unit/AppInfo/ApplicationTest.php
index 79901762..bbf8cdf7 100644
--- a/tests/Unit/AppInfo/ApplicationTest.php
+++ b/tests/Unit/AppInfo/ApplicationTest.php
@@ -28,8 +28,8 @@
namespace OCA\Cloud_Py_API\Tests\Unit\AppInfo;
-use PHPUnit\Framework\TestCase;
use OCA\Cloud_Py_API\AppInfo\Application;
+use PHPUnit\Framework\TestCase;
class ApplicationTest extends TestCase {
public function testConstructor() {
diff --git a/tests/Unit/Command/GetFileContentsCommandTest.php b/tests/Unit/Command/GetFileContentsCommandTest.php
index b2abe9f6..700be0ce 100644
--- a/tests/Unit/Command/GetFileContentsCommandTest.php
+++ b/tests/Unit/Command/GetFileContentsCommandTest.php
@@ -28,15 +28,15 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Command;
-use PHPUnit\Framework\TestCase;
-use PHPUnit\Framework\MockObject\MockObject;
-
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
+use OCA\Cloud_Py_API\Command\GetFileContentsCommand;
use OCP\Files\NotPermittedException;
+
use OCP\Lock\LockedException;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Console\Input\InputInterface;
-use OCA\Cloud_Py_API\Command\GetFileContentsCommand;
+use Symfony\Component\Console\Output\OutputInterface;
/**
* @covers \OCA\Cloud_Py_API\Command\GetFileContentsCommand
diff --git a/tests/Unit/Controller/SettingsControllerTest.php b/tests/Unit/Controller/SettingsControllerTest.php
index 475848e8..27552547 100644
--- a/tests/Unit/Controller/SettingsControllerTest.php
+++ b/tests/Unit/Controller/SettingsControllerTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Controller;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Controller\SettingsController;
use PHPUnit\Framework\MockObject\MockObject;
-use OCA\Cloud_Py_API\Controller\SettingsController;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Controller\SettingsController
diff --git a/tests/Unit/Migration/AppDataInitializationStepTest.php b/tests/Unit/Migration/AppDataInitializationStepTest.php
index c420a207..fdf1a6c1 100644
--- a/tests/Unit/Migration/AppDataInitializationStepTest.php
+++ b/tests/Unit/Migration/AppDataInitializationStepTest.php
@@ -28,12 +28,12 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Migration;
-use PHPUnit\Framework\TestCase;
-use PHPUnit\Framework\MockObject\MockObject;
-
use OCA\Cloud_Py_API\Migration\AppDataInitializationStep;
use OCA\Cloud_Py_API\Migration\data\AppInitialData;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @covers \OCA\Cloud_Py_API\Migration\AppDataInitializationStep
*/
diff --git a/tests/Unit/Migration/AppUpdateStepTest.php b/tests/Unit/Migration/AppUpdateStepTest.php
index e4a942c0..310da88b 100644
--- a/tests/Unit/Migration/AppUpdateStepTest.php
+++ b/tests/Unit/Migration/AppUpdateStepTest.php
@@ -28,12 +28,12 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Migration;
-use PHPUnit\Framework\TestCase;
-use PHPUnit\Framework\MockObject\MockObject;
-
use OCA\Cloud_Py_API\Migration\AppUpdateStep;
use OCA\Cloud_Py_API\Migration\data\AppInitialData;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @covers \OCA\Cloud_Py_API\Migration\AppUpdateStep
*/
diff --git a/tests/Unit/Migration/Version0001Date20221207183030Test.php b/tests/Unit/Migration/Version0001Date20221207183030Test.php
index 44ab136d..eac6a7f3 100644
--- a/tests/Unit/Migration/Version0001Date20221207183030Test.php
+++ b/tests/Unit/Migration/Version0001Date20221207183030Test.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Migration;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Migration\Version0001Date20221207183030;
use PHPUnit\Framework\MockObject\MockObject;
-use \OCA\Cloud_Py_API\Migration\Version0001Date20221207183030;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Migration\Version0001Date20221207183030
@@ -67,26 +67,26 @@ public function testChangeSchema() {
]],
['name', 'string', [
'notnull' => true,
- 'default' => ""
+ 'default' => ''
]],
['value', 'json', [
'notnull' => true
]],
['display_name', 'string', [
'notnull' => true,
- 'default' => ""
+ 'default' => ''
]],
['title', 'string', [
'notnull' => true,
- 'default' => ""
+ 'default' => ''
]],
['description', 'string', [
'notnull' => true,
- 'default' => ""
+ 'default' => ''
]],
['help_url', 'string', [
'notnull' => true,
- 'default' => ""
+ 'default' => ''
]]
);
$table->expects($this->once())
diff --git a/tests/Unit/Service/PythonServiceTest.php b/tests/Unit/Service/PythonServiceTest.php
index 5095de33..afe616b6 100644
--- a/tests/Unit/Service/PythonServiceTest.php
+++ b/tests/Unit/Service/PythonServiceTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Service;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Service\PythonService;
use PHPUnit\Framework\MockObject\MockObject;
-use OCA\Cloud_Py_API\Service\PythonService;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Service\PythonService
diff --git a/tests/Unit/Service/SettingsServiceTest.php b/tests/Unit/Service/SettingsServiceTest.php
index 7982be21..47ccee91 100644
--- a/tests/Unit/Service/SettingsServiceTest.php
+++ b/tests/Unit/Service/SettingsServiceTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Service;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Service\SettingsService;
use PHPUnit\Framework\MockObject\MockObject;
-use OCA\Cloud_Py_API\Service\SettingsService;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Service\SettingsService
diff --git a/tests/Unit/Service/UtilsServiceTest.php b/tests/Unit/Service/UtilsServiceTest.php
index 71604e1b..178f97ed 100644
--- a/tests/Unit/Service/UtilsServiceTest.php
+++ b/tests/Unit/Service/UtilsServiceTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Service;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Service\UtilsService;
use PHPUnit\Framework\MockObject\MockObject;
-use OCA\Cloud_Py_API\Service\UtilsService;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Service\UtilsService
@@ -239,9 +239,9 @@ public function testGetCustomAppDirectoryWithAppsPaths() {
$appsPaths = [
[
// test default apps folder
- "path" => dirname(getcwd()),
- "url" => "/apps",
- "writable" => true
+ 'path' => dirname(getcwd()),
+ 'url' => '/apps',
+ 'writable' => true
]
];
$this->config->expects($this->once())
diff --git a/tests/Unit/Settings/AdminSectionTest.php b/tests/Unit/Settings/AdminSectionTest.php
index 5a9c9c97..104651d7 100644
--- a/tests/Unit/Settings/AdminSectionTest.php
+++ b/tests/Unit/Settings/AdminSectionTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Settings;
-use PHPUnit\Framework\TestCase;
+use OCA\Cloud_Py_API\Settings\AdminSection;
use PHPUnit\Framework\MockObject\MockObject;
-use OCA\Cloud_Py_API\Settings\AdminSection;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Settings\AdminSection
diff --git a/tests/Unit/Settings/AdminSettingsTest.php b/tests/Unit/Settings/AdminSettingsTest.php
index 625f1174..9b6988ae 100644
--- a/tests/Unit/Settings/AdminSettingsTest.php
+++ b/tests/Unit/Settings/AdminSettingsTest.php
@@ -28,10 +28,10 @@
namespace OCA\Cloud_Py_API\Tests\Unit\Settings;
-use PHPUnit\Framework\TestCase;
-
use OCA\Cloud_Py_API\Settings\AdminSettings;
+
use OCP\AppFramework\Http\TemplateResponse;
+use PHPUnit\Framework\TestCase;
/**
* @covers \OCA\Cloud_Py_API\Settings\AdminSettings
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index bc0bc967..2b7b2e58 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -26,8 +26,8 @@
define('PHPUNIT_RUN', 1);
-require_once __DIR__.'/../../../lib/base.php';
-require_once __DIR__.'/../vendor/autoload.php';
+require_once __DIR__ . '/../../../lib/base.php';
+require_once __DIR__ . '/../vendor/autoload.php';
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
\OC_App::loadApp('cloud_py_api');
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index 2b691127..dc8f95e4 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -1,64 +1,47 @@
-
+
-
- $this->rootFolder
- IRootFolder
- IRootFolder
-
-
-
-
- $settingMapper
-
-
- $this->settingMapper
- $this->settingMapper
- SettingsMapper
-
-
-
-
- $schemaClosure
-
-
- Closure
-
-
- Closure
-
+
+
+
-
- getValue
+
+
+
+
+
+
-
- isset($setting)
+
+
+
+
+
+
+
+
+
+
-
- ?DatabaseStatistics
- TAR
+
+ databaseStatistics]]>
+
+
-
- $this->databaseStatistics
- DatabaseStatistics
-
-
- getValue
- getValue
- getValue
- getValue
+
+
+
+
+
-
- URLGenerator
+
+ urlGenerator]]>
+
-
- $this->urlGenerator
- UrlGenerator
-