human friendly name for bundles (#1491)
This commit is contained in:
@@ -80,23 +80,23 @@ final class PermissionController extends AbstractController
|
|||||||
|
|
||||||
// be careful, the order of the search keys is important!
|
// be careful, the order of the search keys is important!
|
||||||
$permissionOrder = [
|
$permissionOrder = [
|
||||||
new PermissionSection('User', '_user'),
|
|
||||||
new PermissionSection('User profile (own)', '_own_profile'),
|
|
||||||
new PermissionSection('User profile (other)', '_other_profile'),
|
|
||||||
new PermissionSection('Customer (Teamlead)', '_teamlead_customer'),
|
|
||||||
new PermissionSection('Customer (Team member)', '_team_customer'),
|
|
||||||
new PermissionSection('Customer (Admin)', '_customer'),
|
|
||||||
new PermissionSection('Project (Teamlead)', '_teamlead_project'),
|
|
||||||
new PermissionSection('Project (Team member)', '_team_project'),
|
|
||||||
new PermissionSection('Project (Admin)', '_project'),
|
|
||||||
new PermissionSection('Activity', '_activity'),
|
|
||||||
new PermissionSection('Timesheet (own)', '_own_timesheet'),
|
|
||||||
new PermissionSection('Timesheet (other)', '_other_timesheet'),
|
|
||||||
new PermissionSection('Timesheet', '_timesheet'),
|
|
||||||
new PermissionSection('Export', '_export'),
|
new PermissionSection('Export', '_export'),
|
||||||
new PermissionSection('Invoice', '_invoice'),
|
new PermissionSection('Invoice', '_invoice'),
|
||||||
new PermissionSection('Teams', '_team'),
|
new PermissionSection('Teams', '_team'),
|
||||||
new PermissionSection('Tags', '_tag'),
|
new PermissionSection('Tags', '_tag'),
|
||||||
|
new PermissionSection('User profile (other)', '_other_profile'),
|
||||||
|
new PermissionSection('User profile (own)', '_own_profile'),
|
||||||
|
new PermissionSection('User', '_user'),
|
||||||
|
new PermissionSection('Customer (Admin)', '_customer'),
|
||||||
|
new PermissionSection('Customer (Team member)', '_team_customer'),
|
||||||
|
new PermissionSection('Customer (Teamlead)', '_teamlead_customer'),
|
||||||
|
new PermissionSection('Project (Admin)', '_project'),
|
||||||
|
new PermissionSection('Project (Team member)', '_team_project'),
|
||||||
|
new PermissionSection('Project (Teamlead)', '_teamlead_project'),
|
||||||
|
new PermissionSection('Activity', '_activity'),
|
||||||
|
new PermissionSection('Timesheet', '_timesheet'),
|
||||||
|
new PermissionSection('Timesheet (other)', '_other_timesheet'),
|
||||||
|
new PermissionSection('Timesheet (own)', '_own_timesheet'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$event = new PermissionSectionsEvent();
|
$event = new PermissionSectionsEvent();
|
||||||
@@ -115,7 +115,7 @@ final class PermissionController extends AbstractController
|
|||||||
foreach ($this->manager->getPermissions() as $permission) {
|
foreach ($this->manager->getPermissions() as $permission) {
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
foreach ($event->getSections() as $section) {
|
foreach (array_reverse($event->getSections()) as $section) {
|
||||||
if ($section->filter($permission)) {
|
if ($section->filter($permission)) {
|
||||||
$permissionSorted[$section->getTitle()][] = $permission;
|
$permissionSorted[$section->getTitle()][] = $permission;
|
||||||
$found = true;
|
$found = true;
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ namespace App\Plugin;
|
|||||||
|
|
||||||
class Plugin
|
class Plugin
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@@ -24,60 +28,51 @@ class Plugin
|
|||||||
*/
|
*/
|
||||||
private $metadata;
|
private $metadata;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return PluginMetadata
|
|
||||||
*/
|
|
||||||
public function getMetadata(): ?PluginMetadata
|
public function getMetadata(): ?PluginMetadata
|
||||||
{
|
{
|
||||||
return $this->metadata;
|
return $this->metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setMetadata(PluginMetadata $metadata): Plugin
|
||||||
* @param PluginMetadata $metadata
|
|
||||||
* @return Plugin
|
|
||||||
*/
|
|
||||||
public function setMetadata(PluginMetadata $metadata)
|
|
||||||
{
|
{
|
||||||
$this->metadata = $metadata;
|
$this->metadata = $metadata;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPath(): ?string
|
public function getPath(): ?string
|
||||||
{
|
{
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setPath(string $path): Plugin
|
||||||
* @param string $path
|
|
||||||
* @return Plugin
|
|
||||||
*/
|
|
||||||
public function setPath(string $path)
|
|
||||||
{
|
{
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): ?string
|
public function getName(): ?string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setName(string $name): Plugin
|
||||||
* @param string $name
|
|
||||||
* @return Plugin
|
|
||||||
*/
|
|
||||||
public function setName(string $name)
|
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getId(): ?string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $id): Plugin
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class PluginManager
|
|||||||
{
|
{
|
||||||
$plugin = new Plugin();
|
$plugin = new Plugin();
|
||||||
$plugin
|
$plugin
|
||||||
|
->setId($bundle->getName())
|
||||||
->setName($bundle->getName())
|
->setName($bundle->getName())
|
||||||
->setPath($bundle->getPath())
|
->setPath($bundle->getPath())
|
||||||
->setMetadata(new PluginMetadata())
|
->setMetadata(new PluginMetadata())
|
||||||
@@ -100,6 +101,10 @@ class PluginManager
|
|||||||
|
|
||||||
$homepage = $json['homepage'] ?? Constants::HOMEPAGE . '/store/';
|
$homepage = $json['homepage'] ?? Constants::HOMEPAGE . '/store/';
|
||||||
|
|
||||||
|
if (array_key_exists('name', $json['extra']['kimai'])) {
|
||||||
|
$plugin->setName($json['extra']['kimai']['name']);
|
||||||
|
}
|
||||||
|
|
||||||
$plugin
|
$plugin
|
||||||
->getMetadata()
|
->getMetadata()
|
||||||
->setHomepage($homepage)
|
->setHomepage($homepage)
|
||||||
|
|||||||
@@ -26,7 +26,13 @@
|
|||||||
{{ tables.datatable_header(tableName, columns, null, {}) }}
|
{{ tables.datatable_header(tableName, columns, null, {}) }}
|
||||||
{% for plugin in plugins %}
|
{% for plugin in plugins %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ plugin.name }}</td>
|
<td>
|
||||||
|
{% if plugin.id != plugin.name %}
|
||||||
|
<span data-toggle="tooltip" data-placement="top" title="{{ plugin.id }}">{{ plugin.name }}</span>
|
||||||
|
{% else %}
|
||||||
|
{{ plugin.name }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>{{ widgets.label(plugin.metadata.version, 'primary') }}</td>
|
<td>{{ widgets.label(plugin.metadata.version, 'primary') }}</td>
|
||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}">{{ plugin.metadata.description }}</td>
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}">{{ plugin.metadata.description }}</td>
|
||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'required_version') }}">
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'required_version') }}">
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ class PluginCommandTest extends KernelTestCase
|
|||||||
public function testWithPlugins()
|
public function testWithPlugins()
|
||||||
{
|
{
|
||||||
$plugin1 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock();
|
$plugin1 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock();
|
||||||
$plugin1->expects($this->exactly(3))->method('getName')->willReturn('Test-Bundle');
|
$plugin1->expects($this->any())->method('getName')->willReturn('Test-Bundle');
|
||||||
$plugin1->expects($this->once())->method('getPath')->willReturn(__DIR__);
|
$plugin1->expects($this->once())->method('getPath')->willReturn(__DIR__);
|
||||||
|
|
||||||
$plugin2 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock();
|
$plugin2 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock();
|
||||||
$plugin2->expects($this->exactly(3))->method('getName')->willReturn('Another one');
|
$plugin2->expects($this->any())->method('getName')->willReturn('Another one');
|
||||||
$plugin2->expects($this->once())->method('getPath')->willReturn('BundleDirectory');
|
$plugin2->expects($this->once())->method('getPath')->willReturn('BundleDirectory');
|
||||||
|
|
||||||
$commandTester = $this->getCommandTester([$plugin1, $plugin2], []);
|
$commandTester = $this->getCommandTester([$plugin1, $plugin2], []);
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ class PluginManagerTest extends TestCase
|
|||||||
$meta = $plugin->getMetadata();
|
$meta = $plugin->getMetadata();
|
||||||
$this->assertEquals('0.9', $meta->getKimaiVersion());
|
$this->assertEquals('0.9', $meta->getKimaiVersion());
|
||||||
$this->assertEquals('1.0', $meta->getVersion());
|
$this->assertEquals('1.0', $meta->getVersion());
|
||||||
|
$this->assertEquals('TestPlugin', $plugin->getId());
|
||||||
|
$this->assertEquals('TestPlugin from composer.json', $plugin->getName());
|
||||||
$this->assertEquals('Just a test fixture for the PluginManager', $meta->getDescription());
|
$this->assertEquals('Just a test fixture for the PluginManager', $meta->getDescription());
|
||||||
$this->assertEquals('https://github.com/kevinpapst/kimai2', $meta->getHomepage());
|
$this->assertEquals('https://github.com/kevinpapst/kimai2', $meta->getHomepage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class PluginTest extends TestCase
|
|||||||
public function testEmptyObject()
|
public function testEmptyObject()
|
||||||
{
|
{
|
||||||
$plugin = new Plugin();
|
$plugin = new Plugin();
|
||||||
|
$this->assertNull($plugin->getId());
|
||||||
$this->assertNull($plugin->getName());
|
$this->assertNull($plugin->getName());
|
||||||
$this->assertNull($plugin->getPath());
|
$this->assertNull($plugin->getPath());
|
||||||
$this->assertNull($plugin->getMetadata());
|
$this->assertNull($plugin->getMetadata());
|
||||||
@@ -37,10 +38,12 @@ class PluginTest extends TestCase
|
|||||||
;
|
;
|
||||||
|
|
||||||
$plugin = new Plugin();
|
$plugin = new Plugin();
|
||||||
|
$this->assertInstanceOf(Plugin::class, $plugin->setId('foo2'));
|
||||||
$this->assertInstanceOf(Plugin::class, $plugin->setName('foo'));
|
$this->assertInstanceOf(Plugin::class, $plugin->setName('foo'));
|
||||||
$this->assertInstanceOf(Plugin::class, $plugin->setPath('bar'));
|
$this->assertInstanceOf(Plugin::class, $plugin->setPath('bar'));
|
||||||
$this->assertInstanceOf(Plugin::class, $plugin->setMetadata($metadata));
|
$this->assertInstanceOf(Plugin::class, $plugin->setMetadata($metadata));
|
||||||
|
|
||||||
|
$this->assertEquals('foo2', $plugin->getId());
|
||||||
$this->assertEquals('foo', $plugin->getName());
|
$this->assertEquals('foo', $plugin->getName());
|
||||||
$this->assertEquals('bar', $plugin->getPath());
|
$this->assertEquals('bar', $plugin->getPath());
|
||||||
$this->assertSame($metadata, $plugin->getMetadata());
|
$this->assertSame($metadata, $plugin->getMetadata());
|
||||||
|
|||||||
Reference in New Issue
Block a user