Merge pull request #995 from nextcloud/workflow-section
Workflow section + hidden empty sections
This commit is contained in:
commit
3ed102497e
8 changed files with 92 additions and 13 deletions
|
@ -7,7 +7,7 @@
|
|||
<licence>AGPL</licence>
|
||||
<author>Vincent Petry, Joas Schilling</author>
|
||||
<default_enable/>
|
||||
<version>1.1.2</version>
|
||||
<version>1.1.3</version>
|
||||
<dependencies>
|
||||
<owncloud min-version="9.2" max-version="9.2" />
|
||||
</dependencies>
|
||||
|
|
|
@ -39,7 +39,7 @@ class Admin implements ISettings {
|
|||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection() {
|
||||
return 'additional';
|
||||
return 'workflow';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ class AdminTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetSection() {
|
||||
$this->assertSame('additional', $this->admin->getSection());
|
||||
$this->assertSame('workflow', $this->admin->getSection());
|
||||
}
|
||||
|
||||
public function testGetPriority() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<description></description>
|
||||
<licence>AGPL</licence>
|
||||
<author>Morris Jobke</author>
|
||||
<version>1.1.0</version>
|
||||
<version>1.1.1</version>
|
||||
<namespace>WorkflowEngine</namespace>
|
||||
|
||||
<category>other</category>
|
||||
|
@ -20,4 +20,8 @@
|
|||
<dependencies>
|
||||
<owncloud min-version="9.2" max-version="9.2" />
|
||||
</dependencies>
|
||||
|
||||
<settings>
|
||||
<admin-section>OCA\WorkflowEngine\Settings\Section</admin-section>
|
||||
</settings>
|
||||
</info>
|
||||
|
|
57
apps/workflowengine/lib/Settings/Section.php
Normal file
57
apps/workflowengine/lib/Settings/Section.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
* @author Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
* @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\WorkflowEngine\Settings;
|
||||
|
||||
use OCP\IL10N;
|
||||
use OCP\Settings\ISection;
|
||||
|
||||
class Section implements ISection {
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
public function __construct(IL10N $l) {
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getID() {
|
||||
return 'workflow';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->l->t('Workflow');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPriority() {
|
||||
return 55;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
namespace OC;
|
||||
|
||||
|
||||
use OC\AppFramework\App;
|
||||
use OC\AppFramework\DependencyInjection\DIContainer;
|
||||
use OC\AppFramework\Utility\SimpleContainer;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
@ -49,7 +50,7 @@ class ServerContainer extends SimpleContainer {
|
|||
* @param DIContainer $container
|
||||
*/
|
||||
public function registerAppContainer($appName, DIContainer $container) {
|
||||
$this->appContainers[$appName] = $container;
|
||||
$this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ class Manager implements IManager {
|
|||
if(isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
|
||||
$this->remove(self::TABLE_ADMIN_SECTIONS, $appInfo['settings'][IManager::KEY_ADMIN_SECTION]);
|
||||
}
|
||||
if(isset($settings['settings'][IManager::KEY_ADMIN_SETTINGS])) {
|
||||
if(isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) {
|
||||
$this->remove(self::TABLE_ADMIN_SETTINGS, $appInfo['settings'][IManager::KEY_ADMIN_SETTINGS]);
|
||||
}
|
||||
}
|
||||
|
@ -327,10 +327,6 @@ class Manager implements IManager {
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function getAdminSections() {
|
||||
$query = $this->dbc->getQueryBuilder();
|
||||
$query->select(['class', 'priority'])
|
||||
->from(self::TABLE_ADMIN_SECTIONS);
|
||||
|
||||
// built-in sections
|
||||
$sections = [
|
||||
0 => [new Section('server', $this->l->t('Server settings'), 0)],
|
||||
|
@ -341,7 +337,15 @@ class Manager implements IManager {
|
|||
99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0)],
|
||||
];
|
||||
|
||||
$query = $this->dbc->getQueryBuilder();
|
||||
$query->selectDistinct('s.class')
|
||||
->addSelect('s.priority')
|
||||
->from(self::TABLE_ADMIN_SECTIONS, 's')
|
||||
->from(self::TABLE_ADMIN_SETTINGS, 'f')
|
||||
->where($query->expr()->eq('s.id', 'f.section'))
|
||||
;
|
||||
$result = $query->execute();
|
||||
|
||||
while($row = $result->fetch()) {
|
||||
if(!isset($sections[$row['priority']])) {
|
||||
$sections[$row['priority']] = [];
|
||||
|
|
|
@ -136,15 +136,28 @@ class ManagerTest extends TestCase {
|
|||
|
||||
public function testGetAdminSections() {
|
||||
$qb = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock();
|
||||
$expr = $this->getMockBuilder('OCP\DB\QueryBuilder\IExpressionBuilder')->getMock();
|
||||
$qb
|
||||
->expects($this->once())
|
||||
->method('select')
|
||||
->with(['class', 'priority'])
|
||||
->method('selectDistinct')
|
||||
->with('s.class')
|
||||
->willReturn($qb);
|
||||
$qb
|
||||
->expects($this->once())
|
||||
->method('addSelect')
|
||||
->with('s.priority')
|
||||
->willReturn($qb);
|
||||
$qb
|
||||
->expects($this->exactly(2))
|
||||
->method('from')
|
||||
->with('admin_sections')
|
||||
->willReturn($qb);
|
||||
$qb
|
||||
->expects($this->once())
|
||||
->method('expr')
|
||||
->willReturn($expr);
|
||||
$qb
|
||||
->expects($this->once())
|
||||
->method('where')
|
||||
->willReturn($qb);
|
||||
$stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock();
|
||||
$qb
|
||||
|
|
Loading…
Reference in a new issue