Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to allow editable dataset name #10608

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import static com.linkedin.datahub.graphql.resolvers.mutate.MutationUtils.persistAspect;

import com.linkedin.businessattribute.BusinessAttributeInfo;
import com.linkedin.common.AuditStamp;
import com.linkedin.common.urn.CorpuserUrn;
import com.linkedin.common.urn.Urn;
import com.linkedin.common.urn.UrnUtils;
import com.linkedin.data.template.SetMode;
import com.linkedin.datahub.graphql.QueryContext;
import com.linkedin.datahub.graphql.authorization.AuthorizationUtils;
import com.linkedin.datahub.graphql.exception.AuthorizationException;
Expand All @@ -19,6 +21,7 @@
import com.linkedin.datahub.graphql.resolvers.mutate.util.DomainUtils;
import com.linkedin.datahub.graphql.resolvers.mutate.util.GlossaryUtils;
import com.linkedin.dataproduct.DataProductProperties;
import com.linkedin.dataset.EditableDatasetProperties;
import com.linkedin.domain.DomainProperties;
import com.linkedin.domain.Domains;
import com.linkedin.entity.client.EntityClient;
Expand Down Expand Up @@ -69,6 +72,8 @@ public CompletableFuture<Boolean> get(DataFetchingEnvironment environment) throw
return updateDataProductName(targetUrn, input, context);
case Constants.BUSINESS_ATTRIBUTE_ENTITY_NAME:
return updateBusinessAttributeName(targetUrn, input, environment.getContext());
case Constants.DATASET_ENTITY_NAME:
return updateDatasetName(targetUrn, input, environment.getContext());
default:
throw new RuntimeException(
String.format(
Expand Down Expand Up @@ -233,6 +238,37 @@ private Boolean updateGroupName(Urn targetUrn, UpdateNameInput input, QueryConte
"Unauthorized to perform this action. Please contact your DataHub administrator.");
}

// udpates editable dataset properties aspect's name field
private Boolean updateDatasetName(Urn targetUrn, UpdateNameInput input, QueryContext context) {
if (AuthorizationUtils.canEditProperties(targetUrn, context)) {
try {
if (input.getName() != null) {
final EditableDatasetProperties editableDatasetProperties =
new EditableDatasetProperties();
editableDatasetProperties.setName(input.getName());
final AuditStamp auditStamp = new AuditStamp();
Urn actor = UrnUtils.getUrn(context.getActorUrn());
auditStamp.setActor(actor, SetMode.IGNORE_NULL);
auditStamp.setTime(System.currentTimeMillis());
editableDatasetProperties.setLastModified(auditStamp);
persistAspect(
context.getOperationContext(),
targetUrn,
Constants.EDITABLE_DATASET_PROPERTIES_ASPECT_NAME,
editableDatasetProperties,
actor,
_entityService);
}
return true;
} catch (Exception e) {
throw new RuntimeException(
String.format("Failed to perform update against input %s", input), e);
}
}
throw new AuthorizationException(
"Unauthorized to perform this action. Please contact your DataHub administrator.");
}

private Boolean updateDataProductName(
Urn targetUrn, UpdateNameInput input, QueryContext context) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ private void mapDatasetProperties(
properties.setQualifiedName(gmsProperties.getQualifiedName());
dataset.setProperties(properties);
dataset.setDescription(properties.getDescription());
dataset.setName(properties.getName());
if (gmsProperties.getUri() != null) {
dataset.setUri(gmsProperties.getUri().toString());
}
Expand All @@ -248,6 +249,9 @@ private void mapEditableDatasetProperties(@Nonnull Dataset dataset, @Nonnull Dat
new EditableDatasetProperties(dataMap);
final DatasetEditableProperties editableProperties = new DatasetEditableProperties();
editableProperties.setDescription(editableDatasetProperties.getDescription());
if (editableDatasetProperties.getName() != null) {
editableProperties.setName(editableDatasetProperties.getName());
}
dataset.setEditableProperties(editableProperties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ public Collection<MetadataChangeProposal> apply(

if (datasetUpdateInput.getEditableProperties() != null) {
final EditableDatasetProperties editableDatasetProperties = new EditableDatasetProperties();
editableDatasetProperties.setDescription(
datasetUpdateInput.getEditableProperties().getDescription());
if (datasetUpdateInput.getEditableProperties().getDescription() != null) {
editableDatasetProperties.setDescription(
datasetUpdateInput.getEditableProperties().getDescription());
}
if (datasetUpdateInput.getEditableProperties().getName() != null) {
editableDatasetProperties.setName(datasetUpdateInput.getEditableProperties().getName());
}
editableDatasetProperties.setLastModified(auditStamp);
editableDatasetProperties.setCreated(auditStamp);
proposals.add(
Expand Down
9 changes: 9 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3456,6 +3456,11 @@ type DatasetEditableProperties {
Description of the Dataset
"""
description: String

"""
Editable name of the Dataset
"""
name: String
}

"""
Expand Down Expand Up @@ -4804,6 +4809,10 @@ input DatasetEditablePropertiesUpdate {
Writable description aka documentation for a Dataset
"""
description: String!
"""
Editable name of the Dataset
"""
name: String
}

"""
Expand Down
7 changes: 4 additions & 3 deletions datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export class DatasetEntity implements Entity<Dataset> {
},
]}
sidebarSections={this.getSidebarSections()}
isNameEditable={true}
/>
);

Expand Down Expand Up @@ -276,7 +277,7 @@ export class DatasetEntity implements Entity<Dataset> {
return (
<Preview
urn={data.urn}
name={data.properties?.name || data.name}
name={data.editableProperties?.name || data.properties?.name || data.name}
origin={data.origin}
subtype={data.subTypes?.typeNames?.[0]}
description={data.editableProperties?.description || data.properties?.description}
Expand Down Expand Up @@ -304,7 +305,7 @@ export class DatasetEntity implements Entity<Dataset> {
return (
<Preview
urn={data.urn}
name={data.properties?.name || data.name}
name={data.editableProperties?.name || data.properties?.name || data.name}
origin={data.origin}
description={data.editableProperties?.description || data.properties?.description}
platformName={
Expand Down Expand Up @@ -354,7 +355,7 @@ export class DatasetEntity implements Entity<Dataset> {
};

displayName = (data: Dataset) => {
return data?.properties?.name || data.name || data.urn;
return data?.editableProperties?.name || data?.properties?.name || data.name || data.urn;
};

platformLogoUrl = (data: Dataset) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export function getCanEditName(
return true; // TODO: add permissions for data products
case EntityType.BusinessAttribute:
return privileges?.manageBusinessAttributes;
case EntityType.Dataset:
return entityData?.privileges?.canEditProperties;
default:
return false;
}
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/browse.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ query getBrowseResults($input: BrowseInput!) {
description
}
editableProperties {
name
description
}
platform {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ fragment nonRecursiveDatasetFields on Dataset {
}
}
editableProperties {
name
description
}
ownership {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/preview.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fragment entityPreview on Entity {
...platformFields
}
editableProperties {
name
description
}
platformNativeType
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ fragment nonSiblingsDatasetSearchFields on Dataset {
...dataPlatformInstanceFields
}
editableProperties {
name
description
}
access {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ record EditableDatasetProperties includes ChangeAuditStamps {
"fieldName": "editedDescription",
}
description: optional string

/**
* Editable display name of the Dataset
*/
@Searchable = {
"fieldType": "TEXT_PARTIAL",
"fieldName": "editedName",
}
name: optional string
}
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,10 @@
"PRE" : "Designates pre-production fabrics",
"PROD" : "Designates production fabrics",
"QA" : "Designates quality assurance fabrics",
"RVW" : "Designates review fabrics",
"STG" : "Designates staging fabrics",
"TEST" : "Designates testing fabrics",
"UAT" : "Designates user acceptance testing fabrics",
"RVW" : "Designates review fabrics"
"UAT" : "Designates user acceptance testing fabrics"
}
}, {
"type" : "record",
Expand Down Expand Up @@ -2489,7 +2489,13 @@
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.AuditStamp",
"doc" : "Audit stamp containing who last modified the status and when."
"doc" : "Audit stamp containing who last modified the status and when.",
"Searchable" : {
"/time" : {
"fieldName" : "statusLastModifiedAt",
"fieldType" : "COUNT"
}
}
} ],
"Aspect" : {
"name" : "corpUserStatus"
Expand Down Expand Up @@ -2861,8 +2867,9 @@
}, {
"name" : "label",
"type" : "string",
"doc" : "Label of the field. Provides a more human-readable name for the field than field path. Some sources will\nprovide this metadata but not all sources have the concept of a label. If just one string is associated with\na field in a source, that is most likely a description.",
"doc" : "Label of the field. Provides a more human-readable name for the field than field path. Some sources will\nprovide this metadata but not all sources have the concept of a label. If just one string is associated with\na field in a source, that is most likely a description.\n\nNote that this field is deprecated and is not surfaced in the UI.",
"optional" : true,
"Deprecated" : true,
"Searchable" : {
"boostScore" : 0.2,
"fieldName" : "fieldLabels",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,10 @@
"PRE" : "Designates pre-production fabrics",
"PROD" : "Designates production fabrics",
"QA" : "Designates quality assurance fabrics",
"RVW" : "Designates review fabrics",
"STG" : "Designates staging fabrics",
"TEST" : "Designates testing fabrics",
"UAT" : "Designates user acceptance testing fabrics",
"RVW" : "Designates review fabrics"
"UAT" : "Designates user acceptance testing fabrics"
}
}, {
"type" : "record",
Expand Down Expand Up @@ -2242,6 +2242,15 @@
"fieldName" : "editedDescription",
"fieldType" : "TEXT"
}
}, {
"name" : "name",
"type" : "string",
"doc" : "Editable display name of the Dataset",
"optional" : true,
"Searchable" : {
"fieldName" : "editedName",
"fieldType" : "TEXT_PARTIAL"
}
} ],
"Aspect" : {
"name" : "editableDatasetProperties"
Expand Down Expand Up @@ -2801,7 +2810,13 @@
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.AuditStamp",
"doc" : "Audit stamp containing who last modified the status and when."
"doc" : "Audit stamp containing who last modified the status and when.",
"Searchable" : {
"/time" : {
"fieldName" : "statusLastModifiedAt",
"fieldType" : "COUNT"
}
}
} ],
"Aspect" : {
"name" : "corpUserStatus"
Expand Down Expand Up @@ -3249,8 +3264,9 @@
}, {
"name" : "label",
"type" : "string",
"doc" : "Label of the field. Provides a more human-readable name for the field than field path. Some sources will\nprovide this metadata but not all sources have the concept of a label. If just one string is associated with\na field in a source, that is most likely a description.",
"doc" : "Label of the field. Provides a more human-readable name for the field than field path. Some sources will\nprovide this metadata but not all sources have the concept of a label. If just one string is associated with\na field in a source, that is most likely a description.\n\nNote that this field is deprecated and is not surfaced in the UI.",
"optional" : true,
"Deprecated" : true,
"Searchable" : {
"boostScore" : 0.2,
"fieldName" : "fieldLabels",
Expand Down Expand Up @@ -5344,15 +5360,25 @@
"items" : "com.linkedin.common.Urn"
},
"doc" : "A specific set of users to apply the policy to (disjunctive)",
"optional" : true
"optional" : true,
"Searchable" : {
"/*" : {
"fieldType" : "URN"
}
}
}, {
"name" : "groups",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.Urn"
},
"doc" : "A specific set of groups to apply the policy to (disjunctive)",
"optional" : true
"optional" : true,
"Searchable" : {
"/*" : {
"fieldType" : "URN"
}
}
}, {
"name" : "resourceOwners",
"type" : "boolean",
Expand All @@ -5370,12 +5396,18 @@
"name" : "allUsers",
"type" : "boolean",
"doc" : "Whether the filter should apply to all users.",
"default" : false
"default" : false,
"Searchable" : {
"fieldType" : "BOOLEAN"
}
}, {
"name" : "allGroups",
"type" : "boolean",
"doc" : "Whether the filter should apply to all groups.",
"default" : false
"default" : false,
"Searchable" : {
"fieldType" : "BOOLEAN"
}
}, {
"name" : "roles",
"type" : {
Expand All @@ -5389,6 +5421,11 @@
"entityTypes" : [ "dataHubRole" ],
"name" : "IsAssociatedWithRole"
}
},
"Searchable" : {
"/*" : {
"fieldType" : "URN"
}
}
} ]
},
Expand Down
Loading
Loading