Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove legacy code that caused errors #1260

Merged
merged 1 commit into from
Aug 7, 2024
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
1 change: 0 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

return [
'routes' => [
['name' => 'Wizard#show', 'url' => '/wizard', 'verb' => 'GET'],
['name' => 'Wizard#disable', 'url' => '/wizard', 'verb' => 'DELETE'],
],
];
88 changes: 8 additions & 80 deletions lib/Controller/WizardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,107 +21,35 @@

namespace OCA\FirstRunWizard\Controller;

use OCA\FirstRunWizard\AppInfo\Application;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IRequest;

class WizardController extends Controller {

/** @var IConfig */
protected $config;

/** @var string */
protected $userId;

/** @var Defaults */
protected $theming;

/** @var IGroupManager */
protected $groupManager;

/** @var array|false|string[] */
protected $slides = [];

/**
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param string $userId
* @param Defaults $theming
* @param string|null $userId
*/
public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming, IGroupManager $groupManager) {
public function __construct(
$appName,
IRequest $request,
private IConfig $config,
private ?string $userId,
) {
parent::__construct($appName, $request);

$this->config = $config;
$this->userId = $userId;
$this->theming = $theming;
$this->groupManager = $groupManager;

$this->slides = explode(',', $this->config->getAppValue(Application::APP_ID, 'slides', 'video,values,apps,clients,final'));
}

/**
* @NoAdminRequired
* @return DataResponse
*/
public function disable() {
\assert($this->userId !== null);
$this->config->setUserValue($this->userId, 'firstrunwizard', 'show', 0);
return new DataResponse();
}

/**
* @NoAdminRequired
* @return JsonResponse
*/
public function show() {
$appStore = $this->config->getSystemValue('appstoreenabled', true);

$data = [
'desktop' => $this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl()),
'android' => $this->config->getSystemValue('customclient_android', $this->theming->getAndroidClientUrl()),
'fdroid' => $this->config->getSystemValue('customclient_fdroid', $this->theming->getFDroidClientUrl()),
'ios' => $this->config->getSystemValue('customclient_ios', $this->theming->getiOSClientUrl()),
'appStore' => $appStore,
'useTLS' => $this->request->getServerProtocol() === 'https',
'macOSProfile' => \OCP\Util::linkToRemote('dav') . 'provisioning/apple-provisioning.mobileconfig',
];

$slides = [];

$slides[] = $this->staticSlide('page.values', $data);
if ($appStore && $this->groupManager->isAdmin($this->userId)) {
$slides[] = $this->staticSlide('page.apps', $data);
}
$slides[] = $this->staticSlide('page.clients', $data);
$slides[] = $this->staticSlide('page.final', $data);

return new JSONResponse([
'hasVideo' => in_array('video', $this->slides, true),
'slides' => array_values(array_filter($slides, function ($slide) {
return $slide !== null;
}))
]);
}

public function staticSlide($name, $params) {
if (!in_array(substr($name, 5), $this->slides, true)) {
return null;
}

$template = new \OCP\Template($this->appName, $name, false);

foreach ($params as $key => $value) {
$template->assign($key, $value);
}

return [
'type' => 'inline',
'content' => $template->fetchPage($params)
];
}
}
2 changes: 1 addition & 1 deletion templates/personal-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<p><?php print_unescaped($l->t('Set up sync clients using an <a href="%s">app password</a>. That way you can make sure you are able to revoke access in case you lose that device.', [$appPasswordUrl])); ?></p>
</div>
<div class="section">
<h2><?php p($l->t('Connect other apps to %s', array($theme->getName()))); ?></h2>
<h2><?php p($l->t('Connect other apps to %s', [$theme->getName()])); ?></h2>

<p class="settings-hint"><?php print_unescaped($l->t('Besides the mobile apps and desktop client you can connect any other software that supports the WebDAV/CalDAV/CardDAV protocols to %s.', [$theme->getName()])); ?></p>

Expand Down
21 changes: 2 additions & 19 deletions tests/AppInfo/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\FirstRunWizard\Tests\AppInfo;
Expand Down
1 change: 0 additions & 1 deletion tests/AppInfo/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function testRoutes() {
$this->assertArrayHasKey('routes', $routes);
$this->assertIsArray($routes['routes']);
$this->assertSame([
['name' => 'Wizard#show', 'url' => '/wizard', 'verb' => 'GET'],
['name' => 'Wizard#disable', 'url' => '/wizard', 'verb' => 'DELETE'],
], $routes['routes']);
}
Expand Down
9 changes: 0 additions & 9 deletions tests/Controller/WizardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

namespace OCA\FirstRunWizard\Tests\Controller;

use OCA\FirstRunWizard\AppInfo\Application;
use OCA\FirstRunWizard\Controller\WizardController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IRequest;
Expand Down Expand Up @@ -60,8 +58,6 @@ protected function getController($user = 'test') {
$this->createMock(IRequest::class),
$this->config,
$user,
\OC::$server->query(Defaults::class),
$this->groupManager
);
}

Expand All @@ -77,11 +73,6 @@ public function dataDisable() {
* @param string $user
*/
public function testDisable($user) {
$this->config->expects($this->once())
->method('getAppValue')
->with(Application::APP_ID, 'slides', 'video,values,apps,clients,final')
->willReturnArgument(2);

$controller = $this->getController($user);

$this->config->expects($this->once())
Expand Down
Loading