Skip to content

Commit

Permalink
feat(nested-domains) Disable delete if domain has subdomains (datahub…
Browse files Browse the repository at this point in the history
  • Loading branch information
eboneil authored Aug 30, 2023
2 parents 9f38b2a + ed842a1 commit 5b4e16d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function EntityDropdown(props: Props) {

const pageUrl = window.location.href;
const isGlossaryEntity = entityType === EntityType.GlossaryNode || entityType === EntityType.GlossaryTerm;
const isDomainEntity = entityType === EntityType.Domain;
const entityHasChildren = !!entityData?.children?.total;
const canManageGlossaryEntity = !!entityData?.privileges?.canManageEntity;
const canCreateGlossaryEntity = !!entityData?.privileges?.canManageChildren;
Expand Down Expand Up @@ -210,11 +211,12 @@ function EntityDropdown(props: Props) {
onClick={onDeleteEntity}
>
<Tooltip
title={`Can't delete ${entityRegistry.getEntityName(
entityType,
)} with child entities.`}
title={`Can't delete ${entityRegistry.getEntityName(entityType)} with ${
isDomainEntity ? 'sub-domain' : 'child'
} entities.`}
overlayStyle={
isGlossaryEntity && canManageGlossaryEntity && entityHasChildren
(isGlossaryEntity && canManageGlossaryEntity && entityHasChildren) ||
(isDomainEntity && entityHasChildren)
? {}
: { display: 'none' }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ export function isDeleteDisabled(entityType: EntityType, entityData: GenericEnti
if (entityType === EntityType.DataProduct) {
return false; // TODO: update with permissions
}
if (entityType === EntityType.Domain) {
const entityHasChildren = !!entityData?.children?.total;
const canDeleteDomainEntity = !entityHasChildren;
return !canDeleteDomainEntity;
}
return false;
}
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/domain.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ query getDomain($urn: String!) {
}
}
}
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 0 }) {
total
}
}
}

Expand Down

0 comments on commit 5b4e16d

Please sign in to comment.