-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix D&D resource display names (#5498)
- Loading branch information
Showing
17 changed files
with
306 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ts/admin-ui/cypress/fixtures/detection-discovery/results/discovery/nested-field-list.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address.zip", | ||
"user_assigned_data_categories": [], | ||
"name": "zip", | ||
"description": null, | ||
"monitor_config_id": "my_bigquery_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": "prj-bigquery-418515", | ||
"schema_name": "test_dataset_1", | ||
"table_name": "consent-reports-20", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address" | ||
}, | ||
|
||
{ | ||
"urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address.street.line_1", | ||
"user_assigned_data_categories": [], | ||
"name": "line_1", | ||
"description": null, | ||
"monitor_config_id": "my_bigquery_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": "prj-bigquery-418515", | ||
"schema_name": "test_dataset_1", | ||
"table_name": "consent-reports-20", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address" | ||
}, | ||
|
||
{ | ||
"urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address.street.line_2", | ||
"user_assigned_data_categories": [], | ||
"name": "line_2", | ||
"description": null, | ||
"monitor_config_id": "my_bigquery_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": "prj-bigquery-418515", | ||
"schema_name": "test_dataset_1", | ||
"table_name": "consent-reports-20", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": "my_bigquery_monitor.prj-bigquery-418515.test_dataset_1.consent-reports-20.address" | ||
} | ||
] | ||
} |
25 changes: 25 additions & 0 deletions
25
clients/admin-ui/cypress/fixtures/detection-discovery/results/no-db-layer/field-list.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"urn": "dynamo_monitor.test_dataset_5.test_table_1.test_field_1", | ||
"user_assigned_data_categories": [], | ||
"name": "test_field_1", | ||
"description": null, | ||
"monitor_config_id": "dynamo_monitor", | ||
"schema_name": "test_dataset_5", | ||
"table_name": "test_table_1", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:45:55.755000+00:00", | ||
"classifications": [], | ||
"diff_status": "classification_addition", | ||
"child_diff_statuses": {}, | ||
"parent_schema": "dynamo_monitor.test_dataset_5", | ||
"database_name": null, | ||
"data_type": null | ||
} | ||
], | ||
"total": 1, | ||
"page": 1, | ||
"size": 25, | ||
"pages": 1 | ||
} |
57 changes: 57 additions & 0 deletions
57
.../admin-ui/cypress/fixtures/detection-discovery/results/no-db-layer/nested-field-list.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"urn": "dynamo_monitor.test_dataset_5.test_table_1.address.zip", | ||
"user_assigned_data_categories": [], | ||
"name": "zip", | ||
"description": null, | ||
"monitor_config_id": "dynamo_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": null, | ||
"schema_name": "test_dataset_5", | ||
"table_name": "test_table_1", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": "dynamo_monitor.test_dataset_5.test_table_1.address" | ||
}, | ||
|
||
{ | ||
"urn": "dynamo_monitor.test_dataset_5.test_table_1.address.street.line_1", | ||
"user_assigned_data_categories": [], | ||
"name": "line_1", | ||
"description": null, | ||
"monitor_config_id": "dynamo_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": null, | ||
"schema_name": "test_dataset_5", | ||
"table_name": "test_table_1", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": "dynamo_monitor.test_dataset_5.test_table_1.address" | ||
}, | ||
|
||
{ | ||
"urn": "dynamo_monitor.test_dataset_5.test_table_1.address.street.line_2", | ||
"user_assigned_data_categories": [], | ||
"name": "line_2", | ||
"description": null, | ||
"monitor_config_id": "dynamo_monitor", | ||
"updated_at": null, | ||
"source_modified": "2024-03-27T21:47:09.915000+00:00", | ||
"classifications": [], | ||
"diff_status": "monitored", | ||
"child_diff_statuses": { "classification_addition": true }, | ||
"database_name": null, | ||
"schema_name": "test_dataset_5", | ||
"table_name": "test_table_1", | ||
"top_level_field_name": "address", | ||
"top_level_field_urn": null | ||
} | ||
] | ||
} |
58 changes: 44 additions & 14 deletions
58
clients/admin-ui/src/features/data-discovery-and-detection/utils/getResourceName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,52 @@ | ||
import { DiscoveryMonitorItem } from "~/features/data-discovery-and-detection/types/DiscoveryMonitorItem"; | ||
|
||
const TOP_LEVEL_FIELD_URN_PARTS = 5; | ||
const URN_SEPARATOR = "."; | ||
/** | ||
* Helper method for deriving a resource's display name from its URN | ||
*/ | ||
const getResourceName = ({ | ||
name, | ||
urn, | ||
monitor_config_id, | ||
database_name, | ||
schema_name, | ||
table_name, | ||
top_level_field_name, | ||
top_level_field_urn, | ||
}: DiscoveryMonitorItem) => { | ||
// use name as-is if resource is not a subfield | ||
if (!top_level_field_name) { | ||
return name; | ||
} | ||
|
||
const splitUrn = urn.split(URN_SEPARATOR); | ||
// for subfields, we want to show all subfield names separated by "." | ||
// format is "monitor.project?.dataset.table.field.[any number of subfields]" | ||
|
||
const getResourceName = (resource: DiscoveryMonitorItem) => { | ||
const URN_SEPARATOR = "."; | ||
const splitUrn = resource.urn.split(URN_SEPARATOR); | ||
if ( | ||
!resource.parent_table_urn || | ||
splitUrn.length === TOP_LEVEL_FIELD_URN_PARTS | ||
) { | ||
// use name as-is if it's not a subfield | ||
return resource.name; | ||
// this case *should* catch all subfields | ||
if (top_level_field_urn) { | ||
return urn.replace(`${top_level_field_urn}${URN_SEPARATOR}`, ""); | ||
} | ||
// TODO HJ-162: better handle case where field name contains "." | ||
|
||
// URN format is "monitor.project.dataset.field.[any number of subfields]" | ||
// for a subfield, we want to show all subfield names separated by "." | ||
return splitUrn.slice(TOP_LEVEL_FIELD_URN_PARTS).join(URN_SEPARATOR); | ||
// as a fallback, parse URN manually and remove higher-level segments | ||
const segmentsToRemove = [ | ||
monitor_config_id, | ||
database_name, | ||
schema_name, | ||
table_name, | ||
top_level_field_name, | ||
]; | ||
|
||
segmentsToRemove.forEach((part) => { | ||
if (part) { | ||
const index = splitUrn.indexOf(part); | ||
if (index > -1) { | ||
splitUrn.splice(index, 1); | ||
} | ||
} | ||
}); | ||
|
||
return splitUrn.join(URN_SEPARATOR); | ||
}; | ||
|
||
export default getResourceName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
clients/admin-ui/src/types/api/models/DatahubDocsSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
import type { PeriodicIntegrationFrequency } from "./PeriodicIntegrationFrequency"; | ||
|
||
/** | ||
* Datahub Schema for API docs. | ||
*/ | ||
export type DatahubDocsSchema = { | ||
/** | ||
* The URL of your DataHub server. | ||
*/ | ||
datahub_server_url: string; | ||
/** | ||
* The token used to authenticate with your DataHub server. | ||
*/ | ||
datahub_token: string; | ||
/** | ||
* The frequency at which the integration should run. Defaults to daily. | ||
*/ | ||
frequency?: PeriodicIntegrationFrequency; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.