Add support for selecting a schema in the backup database dialog with no tables, mviews, views or foreign tables. #7053

Fixed a UI border issue on the dependencies tab for columns with icon. #7055
This commit is contained in:
Nikhil Mohite 2024-01-12 17:19:27 +05:30 committed by GitHub
parent 701085adaf
commit ad0567bd85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 5 deletions

View File

@ -198,7 +198,7 @@ function CollectionArrow({ node, tree, selectedNodeIds }) {
};
return (
<span onClick={toggleNode} >
{node.isInternal ? <ToggleArrowIcon node={node} /> : null}
{node.isInternal && node?.children.length > 0 ? <ToggleArrowIcon node={node} /> : null}
</span>
);
}

View File

@ -149,7 +149,7 @@ const useStyles = makeStyles((theme) => ({
cellIcon: {
paddingLeft: '1.8em',
paddingTop: '0.35em',
height: 35,
borderRadius: 0,
backgroundPosition: '1%',
},
emptyPanel: {

View File

@ -580,8 +580,9 @@ def objects(sid, did, scid=None):
server_info['template_path'] = 'grant_wizard/ppas/#{0}#'.format(
server_info['version'])
res, msg = get_data(sid, did, scid, 'schema' if scid else 'database',
server_info)
res, msg, empty_schema_list = get_data(sid, did, scid,
'schema' if scid else 'database',
server_info, True)
tree_data = {
'table': [],
@ -643,6 +644,14 @@ def objects(sid, did, scid=None):
ch['children'] = children
for empty_schema in empty_schema_list:
schema_group.append({
'id': empty_schema,
'name': empty_schema,
'icon': 'icon-schema',
'children': [],
'is_schema': True,
})
return make_json_response(
data=schema_group,
success=200

View File

@ -274,7 +274,8 @@ def properties(sid, did, node_id, node_type):
)
def get_data(sid, did, node_id, node_type, server_data):
def get_data(sid, did, node_id, node_type, server_data,
return_emtpy_schema=False):
get_schema_sql_url = '/sql/get_schemas.sql'
# unquote encoded url parameter
@ -306,46 +307,80 @@ def get_data(sid, did, node_id, node_type, server_data):
if len(res) > 0:
res_data.extend(res['rows'])
empty_schema_list = []
for row in node_types:
is_empty_schema = True
if 'oid' in row:
node_id = row['oid']
if ntype == 'schema':
status, res = _get_rows_for_type(
conn, 'function', server_prop, node_id)
_append_rows(status, res, 'function')
status, res = _get_rows_for_type(
conn, 'procedure', server_prop, node_id)
_append_rows(status, res, 'procedure')
status, res = _get_rows_for_type(
conn, 'trigger_function', server_prop, node_id)
_append_rows(status, res, 'trigger function')
status, res = _get_rows_for_type(
conn, 'sequence', server_prop, node_id)
if len(res['rows']):
is_empty_schema = False
_append_rows(status, res, 'sequence')
status, res = _get_rows_for_type(
conn, 'table', server_prop, node_id)
if len(res['rows']):
is_empty_schema = False
_append_rows(status, res, 'table')
status, res = _get_rows_for_type(
conn, 'view', server_prop, node_id)
if len(res['rows']):
is_empty_schema = False
_append_rows(status, res, 'view')
status, res = _get_rows_for_type(
conn, 'mview', server_prop, node_id)
if len(res['rows']):
is_empty_schema = False
_append_rows(status, res, 'materialized view')
status, res = _get_rows_for_type(
conn, 'foreign_table', server_prop, node_id)
if len(res['rows']):
is_empty_schema = False
_append_rows(status, res, 'foreign table')
status, res = _get_rows_for_type(
conn, 'package', server_prop, node_id)
if (type(res) is list and len(res) > 0) or (
'rows' in res and len(res['rows']) > 0):
is_empty_schema = False
_append_rows(status, res, 'package')
if is_empty_schema and row['name'] not in empty_schema_list:
empty_schema_list.append(row['name'])
else:
status, res = _get_rows_for_type(conn, ntype, server_prop, node_id)
_append_rows(status, res, 'function')
@ -355,6 +390,9 @@ def get_data(sid, did, node_id, node_type, server_data):
msg = gettext('Unable to fetch the {} objects'.format(
", ".join(failed_objects))
)
if return_emtpy_schema:
return res_data, msg, empty_schema_list
return res_data, msg