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 5 commits
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 @@ -21,5 +21,6 @@ public class FeatureFlags {
private boolean schemaFieldEntityFetchEnabled = false;
private boolean businessAttributeEntityEnabled = false;
private boolean dataContractsEnabled = false;
private boolean editableDatasetNameEnabled = false;
private boolean showSeparateSiblings = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public CompletableFuture<AppConfig> get(final DataFetchingEnvironment environmen
.setNestedDomainsEnabled(_featureFlags.isNestedDomainsEnabled())
.setPlatformBrowseV2(_featureFlags.isPlatformBrowseV2())
.setDataContractsEnabled(_featureFlags.isDataContractsEnabled())
.setEditableDatasetNameEnabled(_featureFlags.isEditableDatasetNameEnabled())
.setShowSeparateSiblings(_featureFlags.isShowSeparateSiblings())
.build();

Expand Down
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.concurrency.GraphQLConcurrencyUtils;
Expand All @@ -20,6 +22,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 @@ -70,6 +73,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 @@ -236,6 +241,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
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/app.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ type FeatureFlagsConfig {
"""
dataContractsEnabled: Boolean!

"""
Whether dataset names are editable
"""
editableDatasetNameEnabled: Boolean!

"""
If turned on, all siblings will be separated with no way to get to a "combined" sibling view
"""
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 @@ -3482,6 +3482,11 @@ type DatasetEditableProperties {
Description of the Dataset
"""
description: String

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

"""
Expand Down Expand Up @@ -4850,6 +4855,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 @@ -220,6 +220,7 @@ export class DatasetEntity implements Entity<Dataset> {
},
]}
sidebarSections={this.getSidebarSections()}
isNameEditable={true}
/>
);

Expand Down Expand Up @@ -283,7 +284,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 @@ -311,7 +312,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 @@ -361,7 +362,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 @@ -17,6 +17,7 @@ import { capitalizeFirstLetterOnly } from '../../../../../shared/textUtil';
import { useUserContext } from '../../../../../context/useUserContext';
import { useEntityRegistry } from '../../../../../useEntityRegistry';
import EntityHeaderLoadingSection from './EntityHeaderLoadingSection';
import { useIsEditableDatasetNameEnabled } from '../../../../../useAppConfig';

const TitleWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -71,6 +72,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 All @@ -94,8 +97,9 @@ export const EntityHeader = ({ headerDropdownItems, headerActionItems, isNameEdi
const entityName = entityData?.name;
const subType = capitalizeFirstLetterOnly(entityData?.subTypes?.typeNames?.[0]) || undefined;

const isEditableDatasetNameEnabled = useIsEditableDatasetNameEnabled();
const canEditName =
isNameEditable && getCanEditName(entityType, entityData, me?.platformPrivileges as PlatformPrivileges);
isEditableDatasetNameEnabled && isNameEditable && getCanEditName(entityType, entityData, me?.platformPrivileges as PlatformPrivileges);
const entityRegistry = useEntityRegistry();

return (
Expand All @@ -106,7 +110,7 @@ export const EntityHeader = ({ headerDropdownItems, headerActionItems, isNameEdi
<>
<PlatformContent />
<TitleWrapper>
<EntityName isNameEditable={canEditName} />
<EntityName isNameEditable={canEditName || false} />
{entityData?.deprecation?.deprecated && (
<DeprecationPill
urn={urn}
Expand Down
5 changes: 5 additions & 0 deletions datahub-web-react/src/app/useAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export function useIsAppConfigContextLoaded() {
return appConfig.loaded;
}

export function useIsEditableDatasetNameEnabled() {
const appConfig = useAppConfig();
return appConfig.config.featureFlags.editableDatasetNameEnabled;
}

export function useIsShowSeparateSiblingsEnabled() {
const appConfig = useAppConfig();
return appConfig.config.featureFlags.showSeparateSiblings;
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/appConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const DEFAULT_APP_CONFIG = {
platformBrowseV2: false,
businessAttributeEntityEnabled: false,
dataContractsEnabled: false,
editableDatasetNameEnabled: false,
showSeparateSiblings: false,
},
};
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/app.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ query appConfig {
platformBrowseV2
businessAttributeEntityEnabled
dataContractsEnabled
editableDatasetNameEnabled
showSeparateSiblings
}
}
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 @@ -2328,6 +2328,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
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,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
Loading