-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
make Settings of Personal and Admin into own views #40544
Changes from all commits
1b774d7
f2f8a97
2b488d8
bb2353a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
'name' => '__root__', | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'reference' => 'b1797842784b250fb01ed5e3bf130705eb94751b', | ||
'reference' => '1b774d74ea236e5c276211ee4916484f931eedba', | ||
'type' => 'library', | ||
'install_path' => __DIR__ . '/../', | ||
'aliases' => array(), | ||
|
@@ -13,7 +13,7 @@ | |
'__root__' => array( | ||
'pretty_version' => 'dev-master', | ||
'version' => 'dev-master', | ||
'reference' => 'b1797842784b250fb01ed5e3bf130705eb94751b', | ||
'reference' => '1b774d74ea236e5c276211ee4916484f931eedba', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks wrong, please revert. |
||
'type' => 'library', | ||
'install_path' => __DIR__ . '/../', | ||
'aliases' => array(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* | ||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* @author Private Maker <privatemaker@posteo.net> | ||
* | ||
* @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/>. | ||
* | ||
*/ | ||
|
||
use OCP\IURLGenerator; | ||
|
||
style('settings', 'settings'); | ||
script('settings', 'settings'); | ||
\OCP\Util::addScript('settings', 'legacy-admin'); | ||
script('core', 'setupchecks'); | ||
script('files', 'jquery.fileupload'); | ||
?> | ||
|
||
<div id="app-navigation" role="navigation"> | ||
<ul tabindex="0"> | ||
<li class="app-navigation-caption"><?php p($l->t('Administration')); ?></li> | ||
<?php foreach ($_['forms']['admin'] as $form): | ||
if (isset($form['anchor'])): | ||
$urlGenerator = \OC::$server->get(IURLGenerator::class); | ||
$anchor = $urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); | ||
$class = 'nav-icon-' . $form['anchor']; | ||
$sectionName = $form['section-name']; ?> | ||
<li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?> data-section-id="<?php print_unescaped($form['anchor']); ?>" data-section-type="admin"> | ||
<a href="<?php p($anchor); ?>"<?php print_unescaped($form['active'] ? ' aria-current="page"' : ''); ?>> | ||
<?php if (!empty($form['icon'])) { ?> | ||
<img alt="" src="<?php print_unescaped($form['icon']); ?>"> | ||
<span><?php p($form['section-name']); ?></span> | ||
<?php } else { ?> | ||
<span class="no-icon"><?php p($form['section-name']); ?></span> | ||
<?php } ?> | ||
</a> | ||
</li> | ||
<?php endif ?> | ||
<?php endforeach ?> | ||
</ul> | ||
</div> | ||
<div id="app-content" tabindex="0" data-active-section-id="<?php print_unescaped($_['activeSectionId']) ?>"> | ||
<?php print_unescaped($_['content']); ?> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* | ||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* @author Private Maker <privatemaker@posteo.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -26,17 +27,13 @@ | |
\OCP\Util::addScript('settings', 'legacy-admin'); | ||
script('core', 'setupchecks'); | ||
script('files', 'jquery.fileupload'); | ||
|
||
?> | ||
|
||
<div id="app-navigation" role="navigation"> | ||
<ul tabindex="0"> | ||
<?php if (!empty($_['forms']['admin'])) { ?> | ||
<li class="app-navigation-caption"><?php p($l->t('Personal')); ?></li> | ||
<?php | ||
} | ||
foreach ($_['forms']['personal'] as $form) { | ||
if (isset($form['anchor'])) { | ||
<li class="app-navigation-caption"><?php p($l->t('Personal')); ?></li> | ||
privatemaker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<?php foreach ($_['forms']['personal'] as $form): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it weird that the underlying logic to render the setting sections is still executed for admin and personal, even if you visit the personal section and vice versa. |
||
if (isset($form['anchor'])): | ||
$anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); | ||
$class = 'nav-icon-' . $form['anchor']; | ||
$sectionName = $form['section-name']; ?> | ||
|
@@ -50,36 +47,8 @@ | |
<?php } ?> | ||
</a> | ||
</li> | ||
<?php | ||
} | ||
} | ||
?> | ||
|
||
<?php | ||
if (!empty($_['forms']['admin'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Admin right privilege / Administration privileges is broken. It's possible to make some admin sections visible to groups without granting the users full admin rights. That's called Administration privileges (in Nextcloud) / Admin right privilege (in our Documentation).
Main: Bob see the administration section but only one item. This PR: Bob does not see the administration section. It's still possible the admin the section if you know the right url, but there is no link somewhere. The menu item "Administration settings" is only added for users with admin permission, but not administration privileges. Adding a link below "Settings" is a bit tricky for Administration privileges because you need to figure out the internal url for the given section. |
||
?> | ||
<li class="app-navigation-caption"><?php p($l->t('Administration')); ?></li> | ||
<?php | ||
} | ||
foreach ($_['forms']['admin'] as $form) { | ||
if (isset($form['anchor'])) { | ||
$anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); | ||
$class = 'nav-icon-' . $form['anchor']; | ||
$sectionName = $form['section-name']; ?> | ||
<li <?php print_unescaped($form['active'] ? ' class="active"' : ''); ?> data-section-id="<?php print_unescaped($form['anchor']); ?>" data-section-type="admin"> | ||
<a href="<?php p($anchor); ?>"<?php print_unescaped($form['active'] ? ' aria-current="page"' : ''); ?>> | ||
<?php if (!empty($form['icon'])) { ?> | ||
<img alt="" src="<?php print_unescaped($form['icon']); ?>"> | ||
<span><?php p($form['section-name']); ?></span> | ||
<?php } else { ?> | ||
<span class="no-icon"><?php p($form['section-name']); ?></span> | ||
<?php } ?> | ||
</a> | ||
</li> | ||
<?php | ||
} | ||
} | ||
?> | ||
<?php endif ?> | ||
<?php endforeach ?> | ||
</ul> | ||
</div> | ||
<div id="app-content" tabindex="0" data-active-section-id="<?php print_unescaped($_['activeSectionId']) ?>"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> | ||
* | ||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de> | ||
* @author Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* @author Jan C. Borchardt <hey@jancborchardt.net> | ||
* @author Lukas Reschke <lukas@statuscode.ch> | ||
* @author Roeland Jago Douma <roeland@famdouma.nl> | ||
* @author Private Maker <privatemaker@posteo.net> | ||
* | ||
* @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/>. | ||
* | ||
*/ | ||
namespace OCA\Settings\Tests\Controller; | ||
|
||
use OCA\Settings\Controller\PersonalSettingsController; | ||
use OCA\Settings\Settings\Personal\ServerDevNotice; | ||
use OCP\AppFramework\Http\TemplateResponse; | ||
use OCP\Group\ISubAdmin; | ||
use OCP\IGroupManager; | ||
use OCP\INavigationManager; | ||
use OCP\IRequest; | ||
use OCP\IUser; | ||
use OCP\IUserSession; | ||
use OCP\Settings\IManager; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Test\TestCase; | ||
|
||
/** | ||
* Class PersonalSettingsControllerTest | ||
* | ||
* @group DB | ||
* | ||
* @package Tests\Settings\Controller | ||
*/ | ||
class PersonalSettingsControllerTest extends TestCase { | ||
|
||
/** @var PersonalSettingsController */ | ||
private $personalSettingsController; | ||
/** @var IRequest|MockObject */ | ||
private $request; | ||
/** @var INavigationManager|MockObject */ | ||
private $navigationManager; | ||
/** @var IManager|MockObject */ | ||
private $settingsManager; | ||
/** @var IUserSession|MockObject */ | ||
private $userSession; | ||
/** @var IGroupManager|MockObject */ | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->request = $this->createMock(IRequest::class); | ||
$this->navigationManager = $this->createMock(INavigationManager::class); | ||
$this->settingsManager = $this->createMock(IManager::class); | ||
$this->userSession = $this->createMock(IUserSession::class); | ||
|
||
$this->personalSettingsController = new PersonalSettingsController( | ||
'settings', | ||
$this->request, | ||
$this->navigationManager, | ||
$this->settingsManager, | ||
$this->userSession, | ||
); | ||
|
||
$user = \OC::$server->getUserManager()->createUser($this->adminUid, 'mylongrandompassword'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks weird ;) Adding
|
||
\OC_User::setUserId($user->getUID()); | ||
// \OC::$server->getGroupManager()->createGroup('admin')->addUser($user); | ||
} | ||
|
||
protected function tearDown(): void { | ||
// \OC::$server->getUserManager()->get($this->adminUid)->delete(); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function testIndex() { | ||
$user = $this->createMock(IUser::class); | ||
$this->userSession | ||
->method('getUser') | ||
->willReturn($user); | ||
$user->method('getUID')->willReturn('user123'); | ||
$this->settingsManager | ||
->expects($this->once()) | ||
->method('getPersonalSections') | ||
->willReturn([]); | ||
|
||
$idx = $this->personalSettingsController->index('test'); | ||
|
||
$expected = new TemplateResponse('settings', 'settings/personal', [ | ||
'forms' => ['personal' => []], | ||
'content' => '' | ||
]); | ||
$this->assertEquals($expected, $idx); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks wrong, please revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happens by
bash build/autoloader…
It's okay