Create Nodes/Icon

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2025-06-13 00:25:04 +01:00
parent a72a6b040c
commit 1a5d10e66d
39 changed files with 223 additions and 179 deletions

View File

@ -21,7 +21,7 @@
{% if node.isGroup %}
<div class="block second{{ has_second_icon ? ' double' }}">
<u>{{ get_image(node.icon['image'], node.icon['title']) }}</u>
<u>{{ get_image(node.icon.image, node.icon.title) }}</u>
</div>
&nbsp;{{ node.name }}
{% else %}

View File

@ -16,6 +16,7 @@ use PhpMyAdmin\Error\ErrorHandler;
use PhpMyAdmin\Favorites\RecentFavoriteTables;
use PhpMyAdmin\Favorites\TableType;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\Nodes\Icon;
use PhpMyAdmin\Navigation\Nodes\Node;
use PhpMyAdmin\Navigation\Nodes\NodeColumn;
use PhpMyAdmin\Navigation\Nodes\NodeColumnContainer;
@ -802,7 +803,12 @@ class NavigationTree
$groups[$key] = new Node($this->config, (string) $key, NodeType::Container, true);
$groups[$key]->separators = $node->separators;
$groups[$key]->separatorDepth = $node->separatorDepth - 1;
$groups[$key]->icon = ['image' => 'b_group', 'title' => __('Groups')];
$groups[$key]->icon = new Icon(
'b_group',
__('Groups'),
$node->icon->route,
array_merge($node->icon->params, ['tbl_group' => $key]),
);
$groups[$key]->pos2 = $node->pos2;
$groups[$key]->pos3 = $node->pos3;
if ($node instanceof NodeTableContainer || $node instanceof NodeViewContainer) {
@ -811,10 +817,6 @@ class NavigationTree
'route' => $node->links['text']['route'],
'params' => array_merge($node->links['text']['params'], ['tbl_group' => $key]),
],
'icon' => [
'route' => $node->links['icon']['route'],
'params' => array_merge($node->links['icon']['params'], ['tbl_group' => $key]),
],
];
}
@ -1016,6 +1018,8 @@ class NavigationTree
$paths = $node->getPaths();
$nodeIsContainer = $node->type === NodeType::Container;
$liClasses = '';
$iconLinks = [];
$textLink = [];
// Whether to show the node in the tree (true for all nodes but root)
// If false, the node's children will still be shown, but as children of the node's parent
@ -1065,27 +1069,10 @@ class NavigationTree
$args[$parent->urlParamName] = $parent->realName;
}
$iconLinks = [];
$iconLinks[] = [
'route' => $node->links['icon']['route'],
'params' => array_merge(
$node->links['icon']['params'],
array_intersect_key($args, $node->links['icon']['params']),
),
'image' => $node->icon['image'],
'title' => $node->icon['title'],
];
$iconLinks[] = $node->icon->withDifferentParams($args);
if ($node instanceof NodeTable && isset($node->links['second_icon'], $node->secondIcon)) {
$iconLinks[] = [
'route' => $node->links['second_icon']['route'],
'params' => array_merge(
$node->links['second_icon']['params'],
array_intersect_key($args, $node->links['second_icon']['params']),
),
'image' => $node->secondIcon['image'],
'title' => $node->secondIcon['title'],
];
if ($node instanceof NodeTable && $node->secondIcon !== null) {
$iconLinks[] = $node->secondIcon->withDifferentParams($args);
}
$textLink = [
@ -1136,8 +1123,8 @@ class NavigationTree
'node_is_container' => $nodeIsContainer,
'has_second_icon' => isset($node->secondIcon),
'recursive' => ['html' => $recursiveHtml ?? '', 'has_wrapper' => $wrap, 'is_hidden' => ! $node->visible],
'icon_links' => $iconLinks ?? [],
'text_link' => $textLink ?? [],
'icon_links' => $iconLinks,
'text_link' => $textLink,
'pagination_params' => $paginationParams,
'node_is_group' => $nodeIsGroup ?? false,
'link_classes' => $linkClasses ?? '',

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Navigation\Nodes;
use function array_intersect_key;
use function array_merge;
readonly class Icon
{
/** @param array<string, mixed> $params */
public function __construct(
public string $image,
public string $title,
public string $route,
public array $params = [],
) {
}
/** @param array<string, mixed> $params */
public function withDifferentParams(array $params): self
{
$params = array_merge($this->params, array_intersect_key($params, $this->params));
return new self($this->image, $this->title, $this->route, $params);
}
}

View File

@ -71,11 +71,8 @@ class Node
/**
* For the IMG tag, used when rendering the node.
*
* @var array<string, string>
* @psalm-var array{image: string, title: string}
*/
public array $icon = ['image' => '', 'title' => ''];
public Icon $icon;
/**
* An array of A tags, used when rendering the node.
@ -83,12 +80,10 @@ class Node
* @var array<string, mixed>
* @psalm-var array{
* text: array{route: string, params: array<string, mixed>},
* icon: array{route: string, params: array<string, mixed>},
* second_icon?: array{route: string, params: array<string, mixed>},
* title?: string
* }
*/
public array $links = ['text' => ['route' => '', 'params' => []], 'icon' => ['route' => '', 'params' => []]];
public array $links = ['text' => ['route' => '', 'params' => []]];
/** @var string HTML title */
public string $title = '';
@ -125,6 +120,7 @@ class Node
public bool $isGroup = false,
) {
$this->realName = $name;
$this->icon = new Icon('', '', '');
}
/**

View File

@ -27,16 +27,17 @@ class NodeColumn extends Node
parent::__construct($config, $item['name']);
$this->icon = ['image' => $this->getColumnIcon($item['key']), 'title' => __('Column')];
$this->icon = new Icon(
$this->getColumnIcon($item['key']),
__('Column'),
'/table/structure/change',
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
);
$this->links = [
'text' => [
'route' => '/table/structure/change',
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
],
'icon' => [
'route' => '/table/structure/change',
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
],
'title' => __('Structure'),
];
$this->urlParamName = 'field';

View File

@ -22,25 +22,25 @@ class NodeColumnContainer extends Node
{
parent::__construct($config, __('Columns'), NodeType::Container);
$this->icon = ['image' => 'pause', 'title' => __('Columns')];
$this->icon = new Icon('pause', __('Columns'), '/table/structure', ['db' => null, 'table' => null]);
$this->links = [
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
];
$this->realName = 'columns';
$newLabel = _pgettext('Create new column', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_column italics');
$new->icon = ['image' => 'b_column_add', 'title' => $newLabel];
$new->icon = new Icon(
'b_column_add',
$newLabel,
'/table/add-field',
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
);
$new->links = [
'text' => [
'route' => '/table/add-field',
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
],
'icon' => [
'route' => '/table/add-field',
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
],
];
$this->addChild($new);
}

View File

@ -48,14 +48,18 @@ class NodeDatabase extends Node
{
parent::__construct($config, $name);
$this->icon = ['image' => 's_db', 'title' => __('Database operations')];
$this->icon = new Icon(
's_db',
__('Database operations'),
'/database/operations',
['db' => null],
);
$this->links = [
'text' => [
'route' => $this->config->settings['DefaultTabDatabase'],
'params' => ['db' => null],
],
'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
'title' => __('Structure'),
];

View File

@ -45,10 +45,9 @@ class NodeDatabaseContainer extends Node
$newLabel = _pgettext('Create new database', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_database italics');
$new->icon = ['image' => 'b_newdb', 'title' => $newLabel];
$new->icon = new Icon('b_newdb', $newLabel, '/server/databases');
$new->links = [
'text' => ['route' => '/server/databases', 'params' => []],
'icon' => ['route' => '/server/databases', 'params' => []],
];
$this->addChild($new);
}

View File

@ -21,16 +21,17 @@ class NodeEvent extends NodeDatabaseChild
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_events', 'title' => __('Event')];
$this->icon = new Icon(
'b_events',
__('Event'),
'/database/events',
['edit_item' => 1, 'db' => null, 'item_name' => null],
);
$this->links = [
'text' => [
'route' => '/database/events',
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/events',
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
],
];
$this->classes = 'event';
$this->urlParamName = 'item_name';

View File

@ -21,19 +21,17 @@ class NodeEventContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Events'));
$this->icon = ['image' => 'b_events', 'title' => __('Events')];
$this->icon = new Icon('b_events', __('Events'), '/database/events', ['db' => null]);
$this->links = [
'text' => ['route' => '/database/events', 'params' => ['db' => null]],
'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
];
$this->realName = 'events';
$newLabel = _pgettext('Create new event', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_event italics');
$new->icon = ['image' => 'b_event_add', 'title' => $newLabel];
$new->icon = new Icon('b_event_add', $newLabel, '/database/events', ['add_item' => 1, 'db' => null]);
$new->links = [
'text' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
'icon' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
];
$this->addChild($new);
}

View File

@ -21,16 +21,17 @@ class NodeFunction extends NodeDatabaseChild
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_routines', 'title' => __('Function')];
$this->icon = new Icon(
'b_routines',
__('Function'),
'/database/routines',
['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
);
$this->links = [
'text' => [
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
],
];
$this->classes = 'function';
$this->urlParamName = 'item_name';

View File

@ -21,25 +21,30 @@ class NodeFunctionContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Functions'));
$this->icon = ['image' => 'b_routines', 'title' => __('Functions')];
$this->icon = new Icon(
'b_routines',
__('Functions'),
'/database/routines',
['type' => 'FUNCTION', 'db' => null],
);
$this->links = [
'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
];
$this->realName = 'functions';
$newLabel = _pgettext('Create new function', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_function italics');
$new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
$new->icon = new Icon(
'b_routine_add',
$newLabel,
'/database/routines',
['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
);
$new->links = [
'text' => [
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
],
'icon' => [
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
],
];
$this->addChild($new);
}

View File

@ -21,10 +21,14 @@ class NodeIndex extends Node
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_index', 'title' => __('Index')];
$this->icon = new Icon(
'b_index',
__('Index'),
'/table/indexes',
['db' => null, 'table' => null, 'index' => null],
);
$this->links = [
'text' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
'icon' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
];
$this->classes = 'index';
$this->urlParamName = 'index';

View File

@ -22,25 +22,25 @@ class NodeIndexContainer extends Node
{
parent::__construct($config, __('Indexes'), NodeType::Container);
$this->icon = ['image' => 'b_index', 'title' => __('Indexes')];
$this->icon = new Icon('b_index', __('Indexes'), '/table/structure', ['db' => null, 'table' => null]);
$this->links = [
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
];
$this->realName = 'indexes';
$newLabel = _pgettext('Create new index', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_index italics');
$new->icon = ['image' => 'b_index_add', 'title' => $newLabel];
$new->icon = new Icon(
'b_index_add',
$newLabel,
'/table/indexes',
['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
);
$new->links = [
'text' => [
'route' => '/table/indexes',
'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
],
'icon' => [
'route' => '/table/indexes',
'params' => ['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
],
];
$this->addChild($new);
}

View File

@ -21,16 +21,17 @@ class NodeProcedure extends NodeDatabaseChild
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_routines', 'title' => __('Procedure')];
$this->icon = new Icon(
'b_routines',
__('Procedure'),
'/database/routines',
['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
);
$this->links = [
'text' => [
'route' => '/database/routines',
'params' => ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/routines',
'params' => ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
],
];
$this->classes = 'procedure';
$this->urlParamName = 'item_name';

View File

@ -21,19 +21,27 @@ class NodeProcedureContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Procedures'));
$this->icon = ['image' => 'b_routines', 'title' => __('Procedures')];
$this->icon = new Icon(
'b_routines',
__('Procedures'),
'/database/routines',
['type' => 'PROCEDURE', 'db' => null],
);
$this->links = [
'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
];
$this->realName = 'procedures';
$newLabel = _pgettext('Create new procedure', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_procedure italics');
$new->icon = ['image' => 'b_routine_add', 'title' => $newLabel];
$new->icon = new Icon(
'b_routine_add',
$newLabel,
'/database/routines',
['add_item' => 1, 'db' => null],
);
$new->links = [
'text' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
'icon' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
];
$this->addChild($new);
}

View File

@ -23,23 +23,26 @@ class NodeTable extends NodeDatabaseChild
{
/**
* For the second IMG tag, used when rendering the node.
*
* @var array<string, string>|null
* @psalm-var array{image: string, title: string}|null
*/
public array|null $secondIcon = null;
public Icon|null $secondIcon = null;
/** @param string $name An identifier for the new node */
public function __construct(Config $config, string $name)
{
parent::__construct($config, $name);
$icon = $this->addIcon($this->config->settings['NavigationTreeDefaultTabTable']);
$icon = $this->addIcon(
$this->config->settings['NavigationTreeDefaultTabTable'],
['db' => null, 'table' => null],
);
if ($icon !== null) {
$this->icon = $icon;
}
$this->secondIcon = $this->addIcon($this->config->settings['NavigationTreeDefaultTabTable2']);
$this->secondIcon = $this->addIcon(
$this->config->settings['NavigationTreeDefaultTabTable2'],
['db' => null, 'table' => null],
);
$this->title = Util::getTitleForTarget($this->config->settings['DefaultTabTable']);
$this->links = [
@ -47,14 +50,6 @@ class NodeTable extends NodeDatabaseChild
'route' => $this->config->settings['DefaultTabTable'],
'params' => ['pos' => 0, 'db' => null, 'table' => null],
],
'icon' => [
'route' => $this->config->settings['NavigationTreeDefaultTabTable'],
'params' => ['db' => null, 'table' => null],
],
'second_icon' => [
'route' => $this->config->settings['NavigationTreeDefaultTabTable2'],
'params' => ['db' => null, 'table' => null],
],
'title' => $this->title,
];
$this->classes = 'nav_node_table';
@ -267,18 +262,17 @@ class NodeTable extends NodeDatabaseChild
/**
* Add an icon to navigation tree
*
* @param '/table/sql'|'/table/search'|'/table/change'|'/sql'|'/table/structure'|'' $page Page name to redirect
*
* @return array{image: string, title: string}|null
* @param '/table/sql'|'/table/search'|'/table/change'|'/sql'|'/table/structure'|'' $page Page name to redirect
* @param array<string, mixed> $params
*/
private function addIcon(string $page): array|null
private function addIcon(string $page, array $params): Icon|null
{
return match ($page) {
'/table/structure' => ['image' => 'b_props', 'title' => __('Structure')],
'/table/search' => ['image' => 'b_search', 'title' => __('Search')],
'/table/change' => ['image' => 'b_insrow', 'title' => __('Insert')],
'/table/sql' => ['image' => 'b_sql', 'title' => __('SQL')],
'/sql' => ['image' => 'b_browse', 'title' => __('Browse')],
'/table/structure' => new Icon('b_props', __('Structure'), $page, $params),
'/table/search' => new Icon('b_search', __('Search'), $page, $params),
'/table/change' => new Icon('b_insrow', __('Insert'), $page, $params),
'/table/sql' => new Icon('b_sql', __('SQL'), $page, $params),
'/sql' => new Icon('b_browse', __('Browse'), $page, $params),
default => null,
};
}

View File

@ -21,20 +21,18 @@ class NodeTableContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Tables'));
$this->icon = ['image' => 'b_browse', 'title' => __('Tables')];
$this->icon = new Icon('b_browse', __('Tables'), '/database/structure', ['tbl_type' => 'table', 'db' => null]);
$this->links = [
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
];
$this->realName = 'tables';
$this->classes = 'tableContainer subContainer';
$newLabel = _pgettext('Create new table', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_table italics');
$new->icon = ['image' => 'b_table_add', 'title' => $newLabel];
$new->icon = new Icon('b_table_add', $newLabel, '/table/create', ['db' => null]);
$new->links = [
'text' => ['route' => '/table/create', 'params' => ['db' => null]],
'icon' => ['route' => '/table/create', 'params' => ['db' => null]],
];
$this->addChild($new);
}

View File

@ -21,16 +21,17 @@ class NodeTrigger extends Node
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_triggers', 'title' => __('Trigger')];
$this->icon = new Icon(
'b_triggers',
__('Trigger'),
'/triggers',
['export_item' => 1, 'db' => null, 'item_name' => null],
);
$this->links = [
'text' => [
'route' => '/triggers',
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/triggers',
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
],
];
$this->classes = 'trigger';
$this->urlParamName = 'item_name';

View File

@ -22,19 +22,17 @@ class NodeTriggerContainer extends Node
{
parent::__construct($config, __('Triggers'), NodeType::Container);
$this->icon = ['image' => 'b_triggers', 'title' => __('Triggers')];
$this->icon = new Icon('b_triggers', __('Triggers'), '/triggers', ['db' => null, 'table' => null]);
$this->links = [
'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
];
$this->realName = 'triggers';
$newLabel = _pgettext('Create new trigger', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_trigger italics');
$new->icon = ['image' => 'b_trigger_add', 'title' => $newLabel];
$new->icon = new Icon('b_trigger_add', $newLabel, '/triggers', ['add_item' => 1, 'db' => null]);
$new->links = [
'text' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
'icon' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
];
$this->addChild($new);
}

View File

@ -21,10 +21,9 @@ class NodeView extends NodeDatabaseChild
{
parent::__construct($config, $name);
$this->icon = ['image' => 'b_props', 'title' => __('View')];
$this->icon = new Icon('b_props', __('View'), '/table/structure', ['db' => null, 'table' => null]);
$this->links = [
'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
];
$this->classes = 'view';
$this->urlParamName = 'table';

View File

@ -21,20 +21,18 @@ class NodeViewContainer extends NodeDatabaseChildContainer
{
parent::__construct($config, __('Views'));
$this->icon = ['image' => 'b_views', 'title' => __('Views')];
$this->icon = new Icon('b_views', __('Views'), '/database/structure', ['tbl_type' => 'view', 'db' => null]);
$this->links = [
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
];
$this->classes = 'viewContainer subContainer';
$this->realName = 'views';
$newLabel = _pgettext('Create new view', 'New');
$new = $this->getInstanceForNewNode($newLabel, 'new_view italics');
$new->icon = ['image' => 'b_view_add', 'title' => $newLabel];
$new->icon = new Icon('b_view_add', $newLabel, '/view/create', ['db' => null]);
$new->links = [
'text' => ['route' => '/view/create', 'params' => ['db' => null]],
'icon' => ['route' => '/view/create', 'params' => ['db' => null]],
];
$this->addChild($new);
}

View File

@ -19,11 +19,13 @@ final class NodeColumnContainerTest extends AbstractTestCase
self::assertSame('Columns', $nodeColumnContainer->name);
self::assertSame(NodeType::Container, $nodeColumnContainer->type);
self::assertFalse($nodeColumnContainer->isGroup);
self::assertSame(['image' => 'pause', 'title' => 'Columns'], $nodeColumnContainer->icon);
self::assertSame('pause', $nodeColumnContainer->icon->image);
self::assertSame('Columns', $nodeColumnContainer->icon->title);
self::assertSame('/table/structure', $nodeColumnContainer->icon->route);
self::assertSame(['db' => null, 'table' => null], $nodeColumnContainer->icon->params);
self::assertSame(
[
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
],
$nodeColumnContainer->links,
);
@ -35,17 +37,19 @@ final class NodeColumnContainerTest extends AbstractTestCase
self::assertSame('New', $newNode->title);
self::assertTrue($newNode->isNew);
self::assertSame('new_column italics', $newNode->classes);
self::assertSame(['image' => 'b_column_add', 'title' => 'New'], $newNode->icon);
self::assertSame('b_column_add', $newNode->icon->image);
self::assertSame('/table/add-field', $newNode->icon->route);
self::assertSame('New', $newNode->icon->title);
self::assertSame(
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
$newNode->icon->params,
);
self::assertSame(
[
'text' => [
'route' => '/table/add-field',
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
],
'icon' => [
'route' => '/table/add-field',
'params' => ['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
],
],
$newNode->links,
);

View File

@ -26,17 +26,19 @@ final class NodeColumnTest extends AbstractTestCase
self::assertSame(NodeType::Object, $nodeColumn->type);
self::assertFalse($nodeColumn->isGroup);
self::assertSame('actor_id (PRI, smallint)', $nodeColumn->displayName);
self::assertSame(['image' => 'b_primary', 'title' => 'Column'], $nodeColumn->icon);
self::assertSame('b_primary', $nodeColumn->icon->image);
self::assertSame('Column', $nodeColumn->icon->title);
self::assertSame('/table/structure/change', $nodeColumn->icon->route);
self::assertSame(
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
$nodeColumn->icon->params,
);
self::assertSame(
[
'text' => [
'route' => '/table/structure/change',
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
],
'icon' => [
'route' => '/table/structure/change',
'params' => ['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
],
'title' => 'Structure',
],
$nodeColumn->links,
@ -54,7 +56,8 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => '',
]);
self::assertSame('last_update (timestamp, curren...)', $nodeColumn->displayName);
self::assertSame(['image' => 'pause', 'title' => 'Column'], $nodeColumn->icon);
self::assertSame('pause', $nodeColumn->icon->image);
self::assertSame('Column', $nodeColumn->icon->title);
}
public function testColumnNodeWithTruncatedDefaultValue2(): void
@ -67,7 +70,8 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => 'nullable',
]);
self::assertSame('email (UNI, varchar, defaul..., nullable)', $nodeColumn->displayName);
self::assertSame(['image' => 'bd_primary', 'title' => 'Column'], $nodeColumn->icon);
self::assertSame('bd_primary', $nodeColumn->icon->image);
self::assertSame('Column', $nodeColumn->icon->title);
}
public function testColumnNodeWithoutTruncatedDefaultValue(): void
@ -80,6 +84,7 @@ final class NodeColumnTest extends AbstractTestCase
'nullable' => '',
]);
self::assertSame('email (varchar, column)', $nodeColumn->displayName);
self::assertSame(['image' => 'pause', 'title' => 'Column'], $nodeColumn->icon);
self::assertSame('pause', $nodeColumn->icon->image);
self::assertSame('Column', $nodeColumn->icon->title);
}
}

View File

@ -24,11 +24,12 @@ class NodeDatabaseTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/structure', 'params' => ['db' => null]],
'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
'title' => 'Structure',
],
$parent->links,
);
self::assertSame('/database/operations', $parent->icon->route);
self::assertSame(['db' => null], $parent->icon->params);
self::assertStringContainsString('database', $parent->classes);
}

View File

@ -21,10 +21,11 @@ class NodeEventContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/events', 'params' => ['db' => null]],
'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
],
$parent->links,
);
self::assertSame('/database/events', $parent->icon->route);
self::assertSame(['db' => null], $parent->icon->params);
self::assertSame('events', $parent->realName);
}
}

View File

@ -24,12 +24,10 @@ class NodeEventTest extends AbstractTestCase
'route' => '/database/events',
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/events',
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
],
],
$parent->links,
);
self::assertSame('/database/events', $parent->icon->route);
self::assertSame(['edit_item' => 1, 'db' => null, 'item_name' => null], $parent->icon->params);
}
}

View File

@ -21,10 +21,11 @@ class NodeFunctionContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
],
$parent->links,
);
self::assertSame('/database/routines', $parent->icon->route);
self::assertSame(['type' => 'FUNCTION', 'db' => null], $parent->icon->params);
self::assertSame('functions', $parent->realName);
}
}

View File

@ -24,12 +24,13 @@ class NodeFunctionTest extends AbstractTestCase
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/routines',
'params' => ['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
],
],
$parent->links,
);
self::assertSame('/database/routines', $parent->icon->route);
self::assertSame(
['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
$parent->icon->params,
);
}
}

View File

@ -21,10 +21,11 @@ class NodeIndexContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
],
$parent->links,
);
self::assertSame('/table/structure', $parent->icon->route);
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertSame('indexes', $parent->realName);
}
}

View File

@ -21,9 +21,10 @@ class NodeIndexTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
'icon' => ['route' => '/table/indexes', 'params' => ['db' => null, 'table' => null, 'index' => null]],
],
$parent->links,
);
self::assertSame('/table/indexes', $parent->icon->route);
self::assertSame(['db' => null, 'table' => null, 'index' => null], $parent->icon->params);
}
}

View File

@ -21,10 +21,11 @@ class NodeProcedureContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
],
$parent->links,
);
self::assertSame('procedures', $parent->realName);
self::assertSame('/database/routines', $parent->icon->route);
self::assertSame(['type' => 'PROCEDURE', 'db' => null], $parent->icon->params);
}
}

View File

@ -24,12 +24,13 @@ class NodeProcedureTest extends AbstractTestCase
'route' => '/database/routines',
'params' => ['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/database/routines',
'params' => ['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
],
],
$parent->links,
);
self::assertSame('/database/routines', $parent->icon->route);
self::assertSame(
['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
$parent->icon->params,
);
}
}

View File

@ -21,10 +21,11 @@ class NodeTableContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
],
$parent->links,
);
self::assertSame('/database/structure', $parent->icon->route);
self::assertSame(['tbl_type' => 'table', 'db' => null], $parent->icon->params);
self::assertSame('tables', $parent->realName);
self::assertStringContainsString('tableContainer', $parent->classes);
}

View File

@ -26,12 +26,15 @@ class NodeTableTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
'icon' => ['route' => '/table/search', 'params' => ['db' => null, 'table' => null]],
'second_icon' => ['route' => '/table/change', 'params' => ['db' => null, 'table' => null]],
'title' => 'Browse',
],
$parent->links,
);
self::assertSame('/table/search', $parent->icon->route);
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertNotNull($parent->secondIcon);
self::assertSame('/table/change', $parent->secondIcon->route);
self::assertSame(['db' => null, 'table' => null], $parent->secondIcon->params);
self::assertStringContainsString('table', $parent->classes);
}
@ -46,8 +49,8 @@ class NodeTableTest extends AbstractTestCase
$config = Config::getInstance();
$config->settings['NavigationTreeDefaultTabTable'] = $target;
$node = new NodeTable($config, 'default');
self::assertSame($imageName, $node->icon['image']);
self::assertSame($imageTitle, $node->icon['title']);
self::assertSame($imageName, $node->icon->image);
self::assertSame($imageTitle, $node->icon->title);
}
/**

View File

@ -21,10 +21,11 @@ class NodeTriggerContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
],
$parent->links,
);
self::assertSame('/triggers', $parent->icon->route);
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertSame('triggers', $parent->realName);
}
}

View File

@ -24,12 +24,13 @@ class NodeTriggerTest extends AbstractTestCase
'route' => '/triggers',
'params' => ['edit_item' => 1, 'db' => null, 'item_name' => null],
],
'icon' => [
'route' => '/triggers',
'params' => ['export_item' => 1, 'db' => null, 'item_name' => null],
],
],
$parent->links,
);
self::assertSame('/triggers', $parent->icon->route);
self::assertSame(
['export_item' => 1, 'db' => null, 'item_name' => null],
$parent->icon->params,
);
}
}

View File

@ -21,10 +21,11 @@ class NodeViewContainerTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
],
$parent->links,
);
self::assertSame('/database/structure', $parent->icon->route);
self::assertSame(['tbl_type' => 'view', 'db' => null], $parent->icon->params);
self::assertSame('views', $parent->realName);
self::assertStringContainsString('viewContainer', $parent->classes);
}

View File

@ -21,12 +21,13 @@ class NodeViewTest extends AbstractTestCase
self::assertSame(
[
'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
],
$parent->links,
);
self::assertSame('b_props', $parent->icon['image']);
self::assertSame('View', $parent->icon['title']);
self::assertSame('b_props', $parent->icon->image);
self::assertSame('View', $parent->icon->title);
self::assertSame('/table/structure', $parent->icon->route);
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
self::assertStringContainsString('view', $parent->classes);
}
}