Merge pull request #19734 from kamil-tekiela/Node-icons
Refactor Nodes and create 2 DTOs
This commit is contained in:
commit
d243fef4ed
@ -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>
|
||||
{{ node.name }}
|
||||
{% else %}
|
||||
|
||||
@ -16,6 +16,8 @@ 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\Link;
|
||||
use PhpMyAdmin\Navigation\Nodes\Node;
|
||||
use PhpMyAdmin\Navigation\Nodes\NodeColumn;
|
||||
use PhpMyAdmin\Navigation\Nodes\NodeColumnContainer;
|
||||
@ -43,7 +45,6 @@ use PhpMyAdmin\UserPrivilegesFactory;
|
||||
|
||||
use function __;
|
||||
use function _ngettext;
|
||||
use function array_intersect_key;
|
||||
use function array_key_exists;
|
||||
use function array_key_last;
|
||||
use function array_keys;
|
||||
@ -772,7 +773,7 @@ class NavigationTree
|
||||
|
||||
$newChild->realName = $child->realName;
|
||||
$newChild->icon = $child->icon;
|
||||
$newChild->links = $child->links;
|
||||
$newChild->link = $child->link;
|
||||
$newChild->pos2 = $child->pos2;
|
||||
$newChild->pos3 = $child->pos3;
|
||||
foreach ($child->children as $elm) {
|
||||
@ -802,20 +803,20 @@ 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) {
|
||||
$groups[$key]->links = [
|
||||
'text' => [
|
||||
'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]),
|
||||
],
|
||||
];
|
||||
$groups[$key]->link = new Link(
|
||||
'',
|
||||
$node->link->route,
|
||||
array_merge($node->link->params, ['tbl_group' => $key]),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($newChildren as $newChild) {
|
||||
@ -1016,6 +1017,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,37 +1068,13 @@ 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 = [
|
||||
'route' => $node->links['text']['route'],
|
||||
'params' => array_merge(
|
||||
$node->links['text']['params'],
|
||||
array_intersect_key($args, $node->links['text']['params']),
|
||||
),
|
||||
'title' => $node->links['title'] ?? $node->title,
|
||||
];
|
||||
$textLink = $node->link->withDifferentParams($args);
|
||||
}
|
||||
|
||||
$controlButtons .= $node->getHtmlForControlButtons($this->relationParameters->navigationItemsHidingFeature);
|
||||
@ -1136,8 +1115,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 ?? '',
|
||||
@ -1180,13 +1159,9 @@ class NavigationTree
|
||||
}
|
||||
|
||||
$paths = $node->getPaths();
|
||||
if (! isset($node->links['text'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $node->links['title'] ?? '';
|
||||
$options[] = [
|
||||
'title' => $title,
|
||||
'title' => $node->link->title,
|
||||
'name' => $node->realName,
|
||||
'data' => ['apath' => $paths['aPath'], 'vpath' => $paths['vPath'], 'pos' => $this->pos],
|
||||
'isSelected' => $node->realName === $selected,
|
||||
|
||||
28
src/Navigation/Nodes/Icon.php
Normal file
28
src/Navigation/Nodes/Icon.php
Normal 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);
|
||||
}
|
||||
}
|
||||
24
src/Navigation/Nodes/Link.php
Normal file
24
src/Navigation/Nodes/Link.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Navigation\Nodes;
|
||||
|
||||
use function array_intersect_key;
|
||||
use function array_merge;
|
||||
|
||||
readonly class Link
|
||||
{
|
||||
/** @param array<string, mixed> $params */
|
||||
public function __construct(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->title, $this->route, $params);
|
||||
}
|
||||
}
|
||||
@ -71,27 +71,11 @@ 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.
|
||||
*
|
||||
* @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 Link $link;
|
||||
|
||||
/** @var string HTML title */
|
||||
public string $title = '';
|
||||
/** @var string Extra CSS classes for the node */
|
||||
public string $classes = '';
|
||||
/** @var bool Whether this node is a link for creating new objects */
|
||||
@ -125,6 +109,8 @@ class Node
|
||||
public bool $isGroup = false,
|
||||
) {
|
||||
$this->realName = $name;
|
||||
$this->icon = new Icon('', '', '');
|
||||
$this->link = new Link('', '', []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +124,6 @@ class Node
|
||||
string $classes,
|
||||
): Node {
|
||||
$node = new Node($this->config, $name);
|
||||
$node->title = $name;
|
||||
$node->isNew = true;
|
||||
$node->classes = $classes;
|
||||
|
||||
|
||||
@ -27,18 +27,17 @@ class NodeColumn extends Node
|
||||
|
||||
parent::__construct($config, $item['name']);
|
||||
|
||||
$this->icon = ['image' => $this->getColumnIcon($item['key']), 'title' => __('Column')];
|
||||
$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->icon = new Icon(
|
||||
$this->getColumnIcon($item['key']),
|
||||
__('Column'),
|
||||
'/table/structure/change',
|
||||
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
__('Structure'),
|
||||
'/table/structure/change',
|
||||
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
);
|
||||
$this->urlParamName = 'field';
|
||||
}
|
||||
|
||||
|
||||
@ -22,26 +22,27 @@ class NodeColumnContainer extends Node
|
||||
{
|
||||
parent::__construct($config, __('Columns'), NodeType::Container);
|
||||
|
||||
$this->icon = ['image' => 'pause', 'title' => __('Columns')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->icon = new Icon('pause', __('Columns'), '/table/structure', ['db' => null, 'table' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/table/structure',
|
||||
['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->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],
|
||||
],
|
||||
];
|
||||
$new->icon = new Icon(
|
||||
'b_column_add',
|
||||
$newLabel,
|
||||
'/table/add-field',
|
||||
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/table/add-field',
|
||||
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,16 +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'),
|
||||
];
|
||||
$this->link = new Link(
|
||||
__('Structure'),
|
||||
$this->config->settings['DefaultTabDatabase'],
|
||||
['db' => null],
|
||||
);
|
||||
|
||||
$this->classes = 'database';
|
||||
$this->urlParamName = 'db';
|
||||
|
||||
@ -45,11 +45,8 @@ 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->links = [
|
||||
'text' => ['route' => '/server/databases', 'params' => []],
|
||||
'icon' => ['route' => '/server/databases', 'params' => []],
|
||||
];
|
||||
$new->icon = new Icon('b_newdb', $newLabel, '/server/databases');
|
||||
$new->link = new Link($newLabel, '/server/databases');
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,17 +21,17 @@ class NodeEvent extends NodeDatabaseChild
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_events', 'title' => __('Event')];
|
||||
$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->icon = new Icon(
|
||||
'b_events',
|
||||
__('Event'),
|
||||
'/database/events',
|
||||
['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/events',
|
||||
['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->classes = 'event';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
@ -21,20 +21,22 @@ class NodeEventContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
parent::__construct($config, __('Events'));
|
||||
|
||||
$this->icon = ['image' => 'b_events', 'title' => __('Events')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_events', __('Events'), '/database/events', ['db' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/events',
|
||||
['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->links = [
|
||||
'text' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/database/events', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$new->icon = new Icon('b_event_add', $newLabel, '/database/events', ['add_item' => 1, 'db' => null]);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/database/events',
|
||||
['add_item' => 1, 'db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,17 +21,17 @@ class NodeFunction extends NodeDatabaseChild
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Function')];
|
||||
$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->icon = new Icon(
|
||||
'b_routines',
|
||||
__('Function'),
|
||||
'/database/routines',
|
||||
['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/routines',
|
||||
['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->classes = 'function';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
@ -21,26 +21,32 @@ class NodeFunctionContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
parent::__construct($config, __('Functions'));
|
||||
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Functions')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'FUNCTION', 'db' => null]],
|
||||
];
|
||||
$this->icon = new Icon(
|
||||
'b_routines',
|
||||
__('Functions'),
|
||||
'/database/routines',
|
||||
['type' => 'FUNCTION', 'db' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/routines',
|
||||
['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->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],
|
||||
],
|
||||
];
|
||||
$new->icon = new Icon(
|
||||
'b_routine_add',
|
||||
$newLabel,
|
||||
'/database/routines',
|
||||
['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
|
||||
);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/database/routines',
|
||||
['item_type' => 'FUNCTION', 'add_item' => 1, 'db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,11 +21,17 @@ class NodeIndex extends Node
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_index', 'title' => __('Index')];
|
||||
$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->icon = new Icon(
|
||||
'b_index',
|
||||
__('Index'),
|
||||
'/table/indexes',
|
||||
['db' => null, 'table' => null, 'index' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/table/indexes',
|
||||
['db' => null, 'table' => null, 'index' => null],
|
||||
);
|
||||
$this->classes = 'index';
|
||||
$this->urlParamName = 'index';
|
||||
}
|
||||
|
||||
@ -22,26 +22,27 @@ class NodeIndexContainer extends Node
|
||||
{
|
||||
parent::__construct($config, __('Indexes'), NodeType::Container);
|
||||
|
||||
$this->icon = ['image' => 'b_index', 'title' => __('Indexes')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_index', __('Indexes'), '/table/structure', ['db' => null, 'table' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/table/structure',
|
||||
['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->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],
|
||||
],
|
||||
];
|
||||
$new->icon = new Icon(
|
||||
'b_index_add',
|
||||
$newLabel,
|
||||
'/table/indexes',
|
||||
['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
|
||||
);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/table/indexes',
|
||||
['create_index' => 1, 'added_fields' => 2, 'db' => null, 'table' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,17 +21,17 @@ class NodeProcedure extends NodeDatabaseChild
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Procedure')];
|
||||
$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->icon = new Icon(
|
||||
'b_routines',
|
||||
__('Procedure'),
|
||||
'/database/routines',
|
||||
['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/routines',
|
||||
['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->classes = 'procedure';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
@ -21,20 +21,32 @@ class NodeProcedureContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
parent::__construct($config, __('Procedures'));
|
||||
|
||||
$this->icon = ['image' => 'b_routines', 'title' => __('Procedures')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
];
|
||||
$this->icon = new Icon(
|
||||
'b_routines',
|
||||
__('Procedures'),
|
||||
'/database/routines',
|
||||
['type' => 'PROCEDURE', 'db' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/routines',
|
||||
['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->links = [
|
||||
'text' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$new->icon = new Icon(
|
||||
'b_routine_add',
|
||||
$newLabel,
|
||||
'/database/routines',
|
||||
['add_item' => 1, 'db' => null],
|
||||
);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/database/routines',
|
||||
['add_item' => 1, 'db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,40 +23,32 @@ 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->title = Util::getTitleForTarget($this->config->settings['DefaultTabTable']);
|
||||
$this->secondIcon = $this->addIcon(
|
||||
$this->config->settings['NavigationTreeDefaultTabTable2'],
|
||||
['db' => null, 'table' => null],
|
||||
);
|
||||
|
||||
$this->links = [
|
||||
'text' => [
|
||||
'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->link = new Link(
|
||||
Util::getTitleForTarget($this->config->settings['DefaultTabTable']),
|
||||
$this->config->settings['DefaultTabTable'],
|
||||
['pos' => 0, 'db' => null, 'table' => null],
|
||||
);
|
||||
$this->classes = 'nav_node_table';
|
||||
$this->urlParamName = 'table';
|
||||
}
|
||||
@ -267,18 +259,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,
|
||||
};
|
||||
}
|
||||
|
||||
@ -21,21 +21,23 @@ class NodeTableContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
parent::__construct($config, __('Tables'));
|
||||
|
||||
$this->icon = ['image' => 'b_browse', 'title' => __('Tables')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
|
||||
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'table', 'db' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_browse', __('Tables'), '/database/structure', ['tbl_type' => 'table', 'db' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/structure',
|
||||
['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->links = [
|
||||
'text' => ['route' => '/table/create', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/table/create', 'params' => ['db' => null]],
|
||||
];
|
||||
$new->icon = new Icon('b_table_add', $newLabel, '/table/create', ['db' => null]);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/table/create',
|
||||
['db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,17 +21,17 @@ class NodeTrigger extends Node
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_triggers', 'title' => __('Trigger')];
|
||||
$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->icon = new Icon(
|
||||
'b_triggers',
|
||||
__('Trigger'),
|
||||
'/triggers',
|
||||
['export_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/triggers',
|
||||
['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
);
|
||||
$this->classes = 'trigger';
|
||||
$this->urlParamName = 'item_name';
|
||||
}
|
||||
|
||||
@ -22,20 +22,22 @@ class NodeTriggerContainer extends Node
|
||||
{
|
||||
parent::__construct($config, __('Triggers'), NodeType::Container);
|
||||
|
||||
$this->icon = ['image' => 'b_triggers', 'title' => __('Triggers')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_triggers', __('Triggers'), '/triggers', ['db' => null, 'table' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/triggers',
|
||||
['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->links = [
|
||||
'text' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
'icon' => ['route' => '/triggers', 'params' => ['add_item' => 1, 'db' => null]],
|
||||
];
|
||||
$new->icon = new Icon('b_trigger_add', $newLabel, '/triggers', ['add_item' => 1, 'db' => null]);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/triggers',
|
||||
['add_item' => 1, 'db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,11 +21,12 @@ class NodeView extends NodeDatabaseChild
|
||||
{
|
||||
parent::__construct($config, $name);
|
||||
|
||||
$this->icon = ['image' => 'b_props', 'title' => __('View')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/sql', 'params' => ['pos' => 0, 'db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_props', __('View'), '/table/structure', ['db' => null, 'table' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/sql',
|
||||
['pos' => 0, 'db' => null, 'table' => null],
|
||||
);
|
||||
$this->classes = 'view';
|
||||
$this->urlParamName = 'table';
|
||||
}
|
||||
|
||||
@ -21,21 +21,23 @@ class NodeViewContainer extends NodeDatabaseChildContainer
|
||||
{
|
||||
parent::__construct($config, __('Views'));
|
||||
|
||||
$this->icon = ['image' => 'b_views', 'title' => __('Views')];
|
||||
$this->links = [
|
||||
'text' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
|
||||
'icon' => ['route' => '/database/structure', 'params' => ['tbl_type' => 'view', 'db' => null]],
|
||||
];
|
||||
$this->icon = new Icon('b_views', __('Views'), '/database/structure', ['tbl_type' => 'view', 'db' => null]);
|
||||
$this->link = new Link(
|
||||
'',
|
||||
'/database/structure',
|
||||
['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->links = [
|
||||
'text' => ['route' => '/view/create', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/view/create', 'params' => ['db' => null]],
|
||||
];
|
||||
$new->icon = new Icon('b_view_add', $newLabel, '/view/create', ['db' => null]);
|
||||
$new->link = new Link(
|
||||
$newLabel,
|
||||
'/view/create',
|
||||
['db' => null],
|
||||
);
|
||||
$this->addChild($new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,35 +19,31 @@ 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(
|
||||
[
|
||||
'text' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/table/structure', 'params' => ['db' => null, 'table' => null]],
|
||||
],
|
||||
$nodeColumnContainer->links,
|
||||
);
|
||||
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('/table/structure', $nodeColumnContainer->link->route);
|
||||
self::assertSame(['db' => null, 'table' => null], $nodeColumnContainer->link->params);
|
||||
self::assertSame('columns', $nodeColumnContainer->realName);
|
||||
self::assertCount(1, $nodeColumnContainer->children);
|
||||
self::assertArrayHasKey(0, $nodeColumnContainer->children);
|
||||
$newNode = $nodeColumnContainer->children[0];
|
||||
self::assertSame('New', $newNode->name);
|
||||
self::assertSame('New', $newNode->title);
|
||||
self::assertSame('New', $newNode->link->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(
|
||||
[
|
||||
'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,
|
||||
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
$newNode->icon->params,
|
||||
);
|
||||
self::assertSame('/table/add-field', $newNode->link->route);
|
||||
self::assertSame(
|
||||
['field_where' => 'last', 'after_field' => '', 'db' => null, 'table' => null],
|
||||
$newNode->link->params,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,21 +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(
|
||||
[
|
||||
'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,
|
||||
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
$nodeColumn->icon->params,
|
||||
);
|
||||
self::assertSame('/table/structure/change', $nodeColumn->link->route);
|
||||
self::assertSame(
|
||||
['change_column' => 1, 'db' => null, 'table' => null, 'field' => null],
|
||||
$nodeColumn->link->params,
|
||||
);
|
||||
self::assertSame('Structure', $nodeColumn->link->title);
|
||||
self::assertSame('field', $nodeColumn->urlParamName);
|
||||
}
|
||||
|
||||
@ -54,7 +52,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 +66,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 +80,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,14 +21,11 @@ class NodeDatabaseTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeDatabase(new Config(), 'default');
|
||||
self::assertSame(
|
||||
[
|
||||
'text' => ['route' => '/database/structure', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/database/operations', 'params' => ['db' => null]],
|
||||
'title' => 'Structure',
|
||||
],
|
||||
$parent->links,
|
||||
);
|
||||
self::assertSame('/database/structure', $parent->link->route);
|
||||
self::assertSame(['db' => null], $parent->link->params);
|
||||
self::assertSame('Structure', $parent->link->title);
|
||||
self::assertSame('/database/operations', $parent->icon->route);
|
||||
self::assertSame(['db' => null], $parent->icon->params);
|
||||
self::assertStringContainsString('database', $parent->classes);
|
||||
}
|
||||
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeEventContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeEventContainer(new Config());
|
||||
self::assertSame(
|
||||
[
|
||||
'text' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
'icon' => ['route' => '/database/events', 'params' => ['db' => null]],
|
||||
],
|
||||
$parent->links,
|
||||
);
|
||||
self::assertSame('/database/events', $parent->link->route);
|
||||
self::assertSame(['db' => null], $parent->link->params);
|
||||
self::assertSame('/database/events', $parent->icon->route);
|
||||
self::assertSame(['db' => null], $parent->icon->params);
|
||||
self::assertSame('events', $parent->realName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,18 +18,9 @@ class NodeEventTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeEvent(new Config(), 'default');
|
||||
self::assertSame(
|
||||
[
|
||||
'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],
|
||||
],
|
||||
],
|
||||
$parent->links,
|
||||
);
|
||||
self::assertSame('/database/events', $parent->link->route);
|
||||
self::assertSame(['edit_item' => 1, 'db' => null, 'item_name' => null], $parent->link->params);
|
||||
self::assertSame('/database/events', $parent->icon->route);
|
||||
self::assertSame(['edit_item' => 1, 'db' => null, 'item_name' => null], $parent->icon->params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeFunctionContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeFunctionContainer(new Config());
|
||||
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->link->route);
|
||||
self::assertSame(['type' => 'FUNCTION', 'db' => null], $parent->link->params);
|
||||
self::assertSame('/database/routines', $parent->icon->route);
|
||||
self::assertSame(['type' => 'FUNCTION', 'db' => null], $parent->icon->params);
|
||||
self::assertSame('functions', $parent->realName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,18 +18,15 @@ class NodeFunctionTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeFunction(new Config(), 'default');
|
||||
self::assertSame('/database/routines', $parent->link->route);
|
||||
self::assertSame(
|
||||
[
|
||||
'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],
|
||||
],
|
||||
],
|
||||
$parent->links,
|
||||
['item_type' => 'FUNCTION', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->link->params,
|
||||
);
|
||||
self::assertSame('/database/routines', $parent->icon->route);
|
||||
self::assertSame(
|
||||
['item_type' => 'FUNCTION', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->icon->params,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeIndexContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeIndexContainer(new Config());
|
||||
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->link->route);
|
||||
self::assertSame(['db' => null, 'table' => null], $parent->link->params);
|
||||
self::assertSame('/table/structure', $parent->icon->route);
|
||||
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
|
||||
self::assertSame('indexes', $parent->realName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,12 +18,9 @@ class NodeIndexTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeIndex(new Config(), 'default');
|
||||
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->link->route);
|
||||
self::assertSame(['db' => null, 'table' => null, 'index' => null], $parent->link->params);
|
||||
self::assertSame('/table/indexes', $parent->icon->route);
|
||||
self::assertSame(['db' => null, 'table' => null, 'index' => null], $parent->icon->params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeProcedureContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeProcedureContainer(new Config());
|
||||
self::assertSame(
|
||||
[
|
||||
'text' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
'icon' => ['route' => '/database/routines', 'params' => ['type' => 'PROCEDURE', 'db' => null]],
|
||||
],
|
||||
$parent->links,
|
||||
);
|
||||
self::assertSame('/database/routines', $parent->link->route);
|
||||
self::assertSame(['type' => 'PROCEDURE', 'db' => null], $parent->link->params);
|
||||
self::assertSame('procedures', $parent->realName);
|
||||
self::assertSame('/database/routines', $parent->icon->route);
|
||||
self::assertSame(['type' => 'PROCEDURE', 'db' => null], $parent->icon->params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,18 +18,15 @@ class NodeProcedureTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeProcedure(new Config(), 'default');
|
||||
self::assertSame('/database/routines', $parent->link->route);
|
||||
self::assertSame(
|
||||
[
|
||||
'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],
|
||||
],
|
||||
],
|
||||
$parent->links,
|
||||
['item_type' => 'PROCEDURE', 'edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->link->params,
|
||||
);
|
||||
self::assertSame('/database/routines', $parent->icon->route);
|
||||
self::assertSame(
|
||||
['item_type' => 'PROCEDURE', 'execute_dialog' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->icon->params,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeTableContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeTableContainer(new Config());
|
||||
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->link->route);
|
||||
self::assertSame(['tbl_type' => 'table', 'db' => null], $parent->link->params);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -23,15 +23,14 @@ class NodeTableTest extends AbstractTestCase
|
||||
$config->settings['NavigationTreeDefaultTabTable2'] = '/table/change';
|
||||
|
||||
$parent = new NodeTable($config, 'default');
|
||||
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('/sql', $parent->link->route);
|
||||
self::assertSame(['pos' => 0, 'db' => null, 'table' => null], $parent->link->params);
|
||||
self::assertSame('Browse', $parent->link->title);
|
||||
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 +45,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -531,7 +531,6 @@ final class NodeTest extends AbstractTestCase
|
||||
self::assertSame('New', $node->name);
|
||||
self::assertSame(NodeType::Object, $node->type);
|
||||
self::assertFalse($node->isGroup);
|
||||
self::assertSame('New', $node->title);
|
||||
self::assertTrue($node->isNew);
|
||||
self::assertSame('new_database italics', $node->classes);
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeTriggerContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeTriggerContainer(new Config());
|
||||
self::assertSame(
|
||||
[
|
||||
'text' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
'icon' => ['route' => '/triggers', 'params' => ['db' => null, 'table' => null]],
|
||||
],
|
||||
$parent->links,
|
||||
);
|
||||
self::assertSame('/triggers', $parent->link->route);
|
||||
self::assertSame(['db' => null, 'table' => null], $parent->link->params);
|
||||
self::assertSame('/triggers', $parent->icon->route);
|
||||
self::assertSame(['db' => null, 'table' => null], $parent->icon->params);
|
||||
self::assertSame('triggers', $parent->realName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,18 +18,15 @@ class NodeTriggerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeTrigger(new Config(), 'default');
|
||||
self::assertSame('/triggers', $parent->link->route);
|
||||
self::assertSame(
|
||||
[
|
||||
'text' => [
|
||||
'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,
|
||||
['edit_item' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->link->params,
|
||||
);
|
||||
self::assertSame('/triggers', $parent->icon->route);
|
||||
self::assertSame(
|
||||
['export_item' => 1, 'db' => null, 'item_name' => null],
|
||||
$parent->icon->params,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,13 +18,10 @@ class NodeViewContainerTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeViewContainer(new Config());
|
||||
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->link->route);
|
||||
self::assertSame(['tbl_type' => 'view', 'db' => null], $parent->link->params);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -18,15 +18,12 @@ class NodeViewTest extends AbstractTestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$parent = new NodeView(new Config(), 'default');
|
||||
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('/sql', $parent->link->route);
|
||||
self::assertSame(['pos' => 0, 'db' => null, 'table' => null], $parent->link->params);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user