Skip to content

Commit 624126e

Browse files
committed
Redesign the database and table privileges pages
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent a256228 commit 624126e

5 files changed

Lines changed: 153 additions & 175 deletions

File tree

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ phpMyAdmin - ChangeLog
88
- issue Make database and web server info separately configurable on `$cfg['ShowServerInfo']`
99
- issue Add a configuration option to (dis)allow shared bookmarks: `$cfg['AllowSharedBookmarks'] = true;`
1010
- issue Redesign the User Groups form page
11+
- issue Redesign the database and table privileges pages
1112

1213
5.2.2 (not yet released)
1314
- issue #17028 Fix total count of rows in not accurate

templates/database/privileges/index.twig

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
{% if is_superuser %}
2-
<form id="usersForm" action="{{ url('/server/privileges') }}">
3-
{{ get_hidden_inputs(db) }}
1+
<div class="container">
2+
{% if is_superuser %}
3+
<h2>
4+
{{ get_icon('b_usrcheck') }}
5+
{{ 'Users having access to "%s"'|trans|format('<a href="' ~ database_url ~ get_common({'db': db}, '&') ~ '">' ~ db|escape('html') ~ '</a>')|raw }}
6+
</h2>
47

5-
<div class="w-100">
6-
<fieldset class="pma-fieldset">
7-
<legend>
8-
{{ get_icon('b_usrcheck') }}
9-
{{ 'Users having access to "%s"'|trans|format('<a href="' ~ database_url ~ get_common({'db': db}, '&') ~ '">' ~ db|escape('html') ~ '</a>')|raw }}
10-
</legend>
8+
<form id="usersForm" action="{{ url('/server/privileges') }}" class="card mb-3">
9+
{{ get_hidden_inputs(db) }}
1110

11+
<div class="card-body">
1212
<div class="table-responsive jsresponsive">
1313
<table class="table table-striped table-hover w-auto">
1414
<thead>
@@ -92,10 +92,10 @@
9292
</a>
9393
</td>
9494
</tr>
95-
{% if privileges_amount > 1 %}
96-
<tr class="noclick">
97-
{% endif %}
98-
{% endfor %}
95+
{% if privileges_amount > 1 %}
96+
<tr class="noclick">
97+
{% endif %}
98+
{% endfor %}
9999
{% else %}
100100
<tr>
101101
<td colspan="7">
@@ -107,7 +107,7 @@
107107
</table>
108108
</div>
109109

110-
<div class="float-start">
110+
<div>
111111
<img class="selectallarrow" src="{{ image('arrow_' ~ text_dir ~ '.png') }}" alt="
112112
{%- trans 'With selected:' %}" width="38" height="22">
113113
<input type="checkbox" id="usersForm_checkall" class="checkall_box" title="{% trans 'Check all' %}">
@@ -117,25 +117,20 @@
117117
{{ get_icon('b_tblexport', 'Export'|trans) }}
118118
</button>
119119
</div>
120-
</fieldset>
121-
</div>
122-
</form>
123-
{% else %}
124-
{{ 'Not enough privilege to view users.'|trans|error }}
125-
{% endif %}
120+
</div>
121+
</form>
122+
{% else %}
123+
{{ 'Not enough privilege to view users.'|trans|error }}
124+
{% endif %}
126125

127-
{% if is_createuser %}
128-
<div class="row">
129-
<div class="col-12">
130-
<fieldset class="pma-fieldset" id="fieldset_add_user">
131-
<legend>{% trans %}New{% context %}Create new user{% endtrans %}</legend>
132-
<a id="add_user_anchor" href="{{ url('/server/privileges', {
133-
'adduser': true,
134-
'dbname': db
135-
}) }}">
136-
{{ get_icon('b_usradd', 'Add user account'|trans) }}
137-
</a>
138-
</fieldset>
126+
{% if is_createuser %}
127+
<div>
128+
<a class="btn btn-primary" id="add_user_anchor" href="{{ url('/server/privileges', {
129+
'adduser': true,
130+
'dbname': db
131+
}) }}">
132+
{{ get_icon('b_usradd', 'Add user account'|trans) }}
133+
</a>
139134
</div>
140-
</div>
141-
{% endif %}
135+
{% endif %}
136+
</div>
Lines changed: 123 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,141 @@
1-
{% if is_superuser %}
2-
<form id="usersForm" action="{{ url('/server/privileges') }}">
3-
{{ get_hidden_inputs(db, table) }}
1+
<div class="container">
2+
{% if is_superuser %}
3+
<h2>
4+
{{ get_icon('b_usrcheck') }}
5+
{{ 'Users having access to "%s"'|trans|format('<a href="' ~ table_url ~ get_common({
6+
'db': db,
7+
'table': table
8+
}, '&') ~ '">' ~ db|escape('html') ~ '.' ~ table|escape('html') ~ '</a>')|raw }}
9+
</h2>
410

5-
<fieldset class="pma-fieldset">
6-
<legend>
7-
{{ get_icon('b_usrcheck') }}
8-
{{ 'Users having access to "%s"'|trans|format('<a href="' ~ table_url ~ get_common({
9-
'db': db,
10-
'table': table
11-
}, '&') ~ '">' ~ db|escape('html') ~ '.' ~ table|escape('html') ~ '</a>')|raw }}
12-
</legend>
13-
14-
<div class="table-responsive-md jsresponsive">
15-
<table class="table table-striped table-hover w-auto">
16-
<thead>
17-
<tr>
18-
<th></th>
19-
<th>{% trans 'User name' %}</th>
20-
<th>{% trans 'Host name' %}</th>
21-
<th>{% trans 'Type' %}</th>
22-
<th>{% trans 'Privileges' %}</th>
23-
<th>{% trans 'Grant' %}</th>
24-
<th colspan="2">{% trans 'Action' %}</th>
25-
</tr>
26-
</thead>
27-
28-
<tbody>
29-
{% for privilege in privileges %}
30-
{% set privileges_amount = privilege.privileges|length %}
11+
<form id="usersForm" action="{{ url('/server/privileges') }}" class="card mb-3">
12+
{{ get_hidden_inputs(db, table) }}
13+
<div class="card-body">
14+
<div class="table-responsive-md jsresponsive">
15+
<table class="table table-striped table-hover w-auto">
16+
<thead>
3117
<tr>
32-
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
33-
<input type="checkbox" class="checkall" name="selected_usr[]" id="checkbox_sel_users_{{ loop.index0 }}" value="
34-
{{- privilege.user ~ '&amp;#27;' ~ privilege.host }}">
35-
</td>
36-
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
37-
{% if privilege.user is empty %}
38-
<span class="text-danger">{% trans 'Any' %}</span>
39-
{% else %}
40-
{{ privilege.user }}
41-
{% endif %}
42-
</td>
43-
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
44-
{{ privilege.host }}
45-
</td>
46-
{% for priv in privilege.privileges %}
47-
<td>
48-
{% if priv.type == 'g' %}
49-
{% trans 'global' %}
50-
{% elseif priv.type == 'd' %}
51-
{% if priv.database == db|replace({'_': '\\_', '%': '\\%'}) %}
52-
{% trans 'database-specific' %}
53-
{% else %}
54-
{% trans 'wildcard' %}: <code>{{ priv.database }}</code>
55-
{% endif %}
56-
{% elseif priv.type == 't' %}
57-
{% trans 'table-specific' %}
58-
{% elseif priv.type == 'r' %}
59-
{% trans 'routine' %}
60-
{% endif %}
18+
<th></th>
19+
<th>{% trans 'User name' %}</th>
20+
<th>{% trans 'Host name' %}</th>
21+
<th>{% trans 'Type' %}</th>
22+
<th>{% trans 'Privileges' %}</th>
23+
<th>{% trans 'Grant' %}</th>
24+
<th colspan="2">{% trans 'Action' %}</th>
25+
</tr>
26+
</thead>
27+
28+
<tbody>
29+
{% for privilege in privileges %}
30+
{% set privileges_amount = privilege.privileges|length %}
31+
<tr>
32+
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
33+
<input type="checkbox" class="checkall" name="selected_usr[]" id="checkbox_sel_users_{{ loop.index0 }}" value="
34+
{{- privilege.user ~ '&amp;#27;' ~ privilege.host }}">
6135
</td>
62-
<td>
63-
<code>
64-
{% if priv.type == 'r' %}
65-
{{ priv.routine }}
66-
({{ priv.privileges|join(', ')|upper }})
67-
{% else %}
68-
{{ priv.privileges|join(', ')|raw }}
69-
{% endif %}
70-
</code>
36+
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
37+
{% if privilege.user is empty %}
38+
<span class="text-danger">{% trans 'Any' %}</span>
39+
{% else %}
40+
{{ privilege.user }}
41+
{% endif %}
7142
</td>
72-
<td>
73-
{{ priv.has_grant ? 'Yes'|trans : 'No'|trans }}
43+
<td{% if privileges_amount > 1 %} class="align-middle" rowspan="{{ privileges_amount }}"{% endif %}>
44+
{{ privilege.host }}
7445
</td>
75-
<td>
76-
{% if is_grantuser %}
77-
<a class="edit_user_anchor" href="{{ url('/server/privileges', {
46+
{% for priv in privilege.privileges %}
47+
<td>
48+
{% if priv.type == 'g' %}
49+
{% trans 'global' %}
50+
{% elseif priv.type == 'd' %}
51+
{% if priv.database == db|replace({'_': '\\_', '%': '\\%'}) %}
52+
{% trans 'database-specific' %}
53+
{% else %}
54+
{% trans 'wildcard' %}: <code>{{ priv.database }}</code>
55+
{% endif %}
56+
{% elseif priv.type == 't' %}
57+
{% trans 'table-specific' %}
58+
{% elseif priv.type == 'r' %}
59+
{% trans 'routine' %}
60+
{% endif %}
61+
</td>
62+
<td>
63+
<code>
64+
{% if priv.type == 'r' %}
65+
{{ priv.routine }}
66+
({{ priv.privileges|join(', ')|upper }})
67+
{% else %}
68+
{{ priv.privileges|join(', ')|raw }}
69+
{% endif %}
70+
</code>
71+
</td>
72+
<td>
73+
{{ priv.has_grant ? 'Yes'|trans : 'No'|trans }}
74+
</td>
75+
<td>
76+
{% if is_grantuser %}
77+
<a class="edit_user_anchor" href="{{ url('/server/privileges', {
78+
'username': privilege.user,
79+
'hostname': privilege.host,
80+
'dbname': priv.database != '*' ? priv.database,
81+
'tablename': priv.table is defined and priv.table != '*' ? priv.table,
82+
'routinename': priv.routine ?? ''
83+
}) }}">
84+
{{ get_icon('b_usredit', 'Edit privileges'|trans) }}
85+
</a>
86+
{% endif %}
87+
</td>
88+
<td class="text-center">
89+
<a class="export_user_anchor ajax" href="{{ url('/server/privileges', {
7890
'username': privilege.user,
7991
'hostname': privilege.host,
80-
'dbname': priv.database != '*' ? priv.database,
81-
'tablename': priv.table is defined and priv.table != '*' ? priv.table,
82-
'routinename': priv.routine ?? ''
92+
'export': true,
93+
'initial': ''
8394
}) }}">
84-
{{ get_icon('b_usredit', 'Edit privileges'|trans) }}
95+
{{ get_icon('b_tblexport', 'Export'|trans) }}
8596
</a>
86-
{% endif %}
87-
</td>
88-
<td class="text-center">
89-
<a class="export_user_anchor ajax" href="{{ url('/server/privileges', {
90-
'username': privilege.user,
91-
'hostname': privilege.host,
92-
'export': true,
93-
'initial': ''
94-
}) }}">
95-
{{ get_icon('b_tblexport', 'Export'|trans) }}
96-
</a>
97-
</td>
98-
</tr>
97+
</td>
98+
</tr>
9999
{% if privileges_amount > 1 %}
100100
<tr class="noclick">
101101
{% endif %}
102102
{% endfor %}
103-
{% else %}
104-
<tr>
105-
<td colspan="7">
106-
{% trans 'No user found.' %}
107-
</td>
108-
</tr>
109-
{% endfor %}
110-
</tbody>
111-
</table>
112-
</div>
103+
{% else %}
104+
<tr>
105+
<td colspan="7">
106+
{% trans 'No user found.' %}
107+
</td>
108+
</tr>
109+
{% endfor %}
110+
</tbody>
111+
</table>
112+
</div>
113113

114-
<div class="float-start">
115-
<img class="selectallarrow" src="{{ image('arrow_' ~ text_dir ~ '.png') }}" alt="
114+
<div>
115+
<img class="selectallarrow" src="{{ image('arrow_' ~ text_dir ~ '.png') }}" alt="
116116
{%- trans 'With selected:' %}" width="38" height="22">
117-
<input type="checkbox" id="usersForm_checkall" class="checkall_box" title="{% trans 'Check all' %}">
118-
<label for="usersForm_checkall">{% trans 'Check all' %}</label>
119-
<em class="with-selected">{% trans 'With selected:' %}</em>
120-
<button class="btn btn-link mult_submit" type="submit" name="submit_mult" value="export" title="{% trans 'Export' %}">
121-
{{ get_icon('b_tblexport', 'Export'|trans) }}
122-
</button>
117+
<input type="checkbox" id="usersForm_checkall" class="checkall_box" title="{% trans 'Check all' %}">
118+
<label for="usersForm_checkall">{% trans 'Check all' %}</label>
119+
<em class="with-selected">{% trans 'With selected:' %}</em>
120+
<button class="btn btn-link mult_submit" type="submit" name="submit_mult" value="export" title="{% trans 'Export' %}">
121+
{{ get_icon('b_tblexport', 'Export'|trans) }}
122+
</button>
123+
</div>
123124
</div>
124-
</fieldset>
125-
</form>
126-
{% else %}
127-
{{ 'Not enough privilege to view users.'|trans|error }}
128-
{% endif %}
125+
</form>
126+
{% else %}
127+
{{ 'Not enough privilege to view users.'|trans|error }}
128+
{% endif %}
129129

130-
{% if is_createuser %}
131-
<div class="row">
132-
<div class="col-12">
133-
<fieldset class="pma-fieldset" id="fieldset_add_user">
134-
<legend>{% trans %}New{% context %}Create new user{% endtrans %}</legend>
135-
<a id="add_user_anchor" href="{{ url('/server/privileges', {
136-
'adduser': true,
137-
'dbname': db,
138-
'tablename': table
139-
}) }}">
140-
{{ get_icon('b_usradd', 'Add user account'|trans) }}
141-
</a>
142-
</fieldset>
130+
{% if is_createuser %}
131+
<div>
132+
<a class="btn btn-primary" id="add_user_anchor" href="{{ url('/server/privileges', {
133+
'adduser': true,
134+
'dbname': db,
135+
'tablename': table
136+
}) }}">
137+
{{ get_icon('b_usradd', 'Add user account'|trans) }}
138+
</a>
143139
</div>
144-
</div>
145-
{% endif %}
140+
{% endif %}
141+
</div>

test/classes/Controllers/Database/PrivilegesControllerTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PhpMyAdmin\Url;
1616

1717
use function __;
18-
use function _pgettext;
1918

2019
/** @covers \PhpMyAdmin\Controllers\Database\PrivilegesController */
2120
class PrivilegesControllerTest extends AbstractTestCase
@@ -106,12 +105,6 @@ public function testIndex(): void
106105
__('Action'),
107106
$actual,
108107
);
109-
110-
//_pgettext('Create new user', 'New')
111-
$this->assertStringContainsString(
112-
_pgettext('Create new user', 'New'),
113-
$actual,
114-
);
115108
}
116109

117110
public function testWithInvalidDatabaseName(): void

0 commit comments

Comments
 (0)