Skip to content

Commit 797bdb8

Browse files
Fixed directory owner update & UI issues. #8034
1 parent c80be9b commit 797bdb8

File tree

7 files changed

+18
-27
lines changed

7 files changed

+18
-27
lines changed

docs/en_US/directory_dialog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
`Directory Dialog`:index:
55
*************************
66

7-
Use the Directory dialog to Create an alias for a file system directory path.
7+
Use the Directory dialog to create an alias for a file system directory path.
88
To create directories, you must have the CREATE ANY DIRECTORY system privilege.
99
When you create a directory, you are automatically granted READ and WRITE privileges
1010
on the directory, and you can grant READ and WRITE privileges to other users and roles.
3.82 KB
Loading
2.68 KB
Loading

web/pgadmin/browser/server_groups/servers/directories/__init__.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,9 @@ def create(self, gid, sid):
316316
"/".join([self.template_path, self._ALTER_SQL]),
317317
data=data, conn=self.conn
318318
)
319-
320-
# Checking if we are not executing empty query
321-
if SQL and SQL.strip('\n') and SQL.strip(' '):
322-
status, res = self.conn.execute_scalar(SQL)
323-
if not status:
324-
return jsonify(
325-
node=self.blueprint.generate_browser_node(
326-
dr_id,
327-
sid,
328-
data['name'],
329-
icon="icon-directory"
330-
),
331-
success=0,
332-
errormsg=gettext(
333-
'Directory created successfully.'
334-
),
335-
info=gettext(
336-
res
337-
)
338-
)
319+
status, res = self.conn.execute_scalar(SQL)
320+
if not status:
321+
return internal_server_error(errormsg=res)
339322

340323
return jsonify(
341324
node=self.blueprint.generate_browser_node(

web/pgadmin/browser/server_groups/servers/directories/static/js/directory.ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { isEmptyString } from '../../../../../../static/js/validators';
1414
export default class DirectorySchema extends BaseUISchema {
1515
constructor(getPrivilegeRoleSchema, treeNodeInfo, fieldOptions={}, initValues={}) {
1616
super({
17+
diruser: undefined,
1718
name: undefined,
18-
owner: undefined,
1919
path: undefined,
2020
diracl: [],
2121
...initValues,

web/pgadmin/browser/server_groups/servers/directories/templates/directories/sql/default/alter.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
{### SQL to alter directory ###}
22
{% import 'macros/privilege.macros' as PRIVILEGE %}
33
{% if data %}
4-
{### Owner on directory ###}
5-
{% if data.diruser %}
6-
ALTER DIRECTORY {{ conn|qtIdent(data.name) }}
7-
OWNER TO {{ conn|qtIdent(data.diruser) }};
8-
{% endif %}
94

105
{### ACL on directory ###}
116
{% if data.diracl %}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
{### SQL to create directory object ###}
22
{% if data %}
3+
34
CREATE DIRECTORY {{ conn|qtIdent(data.name) }} AS {{ data.path|qtLiteral(conn) }};
5+
6+
{### Owner on directory ###}
7+
{% if data.diruser %}
8+
ALTER DIRECTORY {{ conn|qtIdent(data.name) }}
9+
OWNER TO {{ conn|qtIdent(data.diruser) }};
10+
{% endif %}
11+
12+
{% endif %}
13+
14+
{# ======== The SQl Below will fetch id for given directory ======== #}
15+
{% if directory %}
16+
SELECT dir.oid FROM pg_catalog.edb_dir dir WHERE dirname = {{directory|qtLiteral(conn)}};
417
{% endif %}

0 commit comments

Comments
 (0)