Skip to content

Commit

Permalink
refactor(ui): Misc domains improvements (#6850)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored Dec 23, 2022
1 parent ea5ee6f commit c482ef0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/domain/CreateDomainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ClickableTag = styled(Tag)`

type Props = {
onClose: () => void;
onCreate: (urn: string, id: string | undefined, name: string, description: string) => void;
onCreate: (urn: string, id: string | undefined, name: string, description: string | undefined) => void;
};

const SUGGESTED_DOMAIN_NAMES = ['Engineering', 'Marketing', 'Sales', 'Product'];
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/domain/DomainItemMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function DomainItemMenu({ name, urn, onDelete }: Props) {
</Menu>
}
>
<MenuIcon fontSize={20} />
<MenuIcon data-testid={`dropdown-menu-${urn}`} fontSize={20} />
</Dropdown>
);
}
20 changes: 11 additions & 9 deletions datahub-web-react/src/app/domain/DomainListColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ export function DomainListMenuColumn(handleDelete: (urn: string) => void) {

export function DomainNameColumn(logoIcon: JSX.Element) {
return (record: DomainEntry) => (
<Link to={record.url}>
{logoIcon}
<DomainNameContainer>
<Typography.Text>{record.name}</Typography.Text>
</DomainNameContainer>
<Tooltip title={`There are ${record.entities} entities in this domain.`}>
<Tag>{record.entities} entities</Tag>
</Tooltip>
</Link>
<span data-testid={record.urn}>
<Link to={record.url}>
{logoIcon}
<DomainNameContainer>
<Typography.Text>{record.name}</Typography.Text>
</DomainNameContainer>
<Tooltip title={`There are ${record.entities} entities in this domain.`}>
<Tag>{record.entities} entities</Tag>
</Tooltip>
</Link>
</span>
);
}

Expand Down
11 changes: 5 additions & 6 deletions datahub-web-react/src/app/domain/DomainsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const DomainsList = () => {
query,
},
},
fetchPolicy: 'cache-first',
fetchPolicy: query && query.length > 0 ? 'no-cache' : 'cache-first',
});

const totalDomains = data?.listDomains?.total || 0;
Expand All @@ -76,7 +76,7 @@ export const DomainsList = () => {
};

const handleDelete = (urn: string) => {
removeFromListDomainsCache(client, urn, page, pageSize, query);
removeFromListDomainsCache(client, urn, page, pageSize);
setTimeout(function () {
refetch?.();
}, 2000);
Expand Down Expand Up @@ -116,9 +116,9 @@ export const DomainsList = () => {
const url = entityRegistry.getEntityUrl(EntityType.Domain, domain.urn);

return {
urn: domain.urn,
name: displayName,
entities: totalEntitiesText,
urn: domain.urn,
ownership: domain.ownership,
url,
};
Expand Down Expand Up @@ -147,7 +147,7 @@ export const DomainsList = () => {
fontSize: 12,
}}
onSearch={() => null}
onQueryChange={(q) => setQuery(q)}
onQueryChange={(q) => setQuery(q && q.length > 0 ? q : undefined)}
entityRegistry={entityRegistry}
hideRecommendations
/>
Expand Down Expand Up @@ -186,13 +186,12 @@ export const DomainsList = () => {
urn,
properties: {
name,
description,
description: description || null,
},
ownership: null,
entities: null,
},
pageSize,
query,
);
setTimeout(() => refetch(), 2000);
}}
Expand Down
8 changes: 2 additions & 6 deletions datahub-web-react/src/app/domain/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { ListDomainsDocument, ListDomainsQuery } from '../../graphql/domain.gene
/**
* Add an entry to the list domains cache.
*/
export const addToListDomainsCache = (client, newDomain, pageSize, query) => {
export const addToListDomainsCache = (client, newDomain, pageSize) => {
// Read the data from our cache for this query.
const currData: ListDomainsQuery | null = client.readQuery({
query: ListDomainsDocument,
variables: {
input: {
start: 0,
count: pageSize,
query,
},
},
});
Expand All @@ -26,7 +25,6 @@ export const addToListDomainsCache = (client, newDomain, pageSize, query) => {
input: {
start: 0,
count: pageSize,
query,
},
},
data: {
Expand All @@ -43,15 +41,14 @@ export const addToListDomainsCache = (client, newDomain, pageSize, query) => {
/**
* Remove an entry from the list domains cache.
*/
export const removeFromListDomainsCache = (client, urn, page, pageSize, query) => {
export const removeFromListDomainsCache = (client, urn, page, pageSize) => {
// Read the data from our cache for this query.
const currData: ListDomainsQuery | null = client.readQuery({
query: ListDomainsDocument,
variables: {
input: {
start: (page - 1) * pageSize,
count: pageSize,
query,
},
},
});
Expand All @@ -66,7 +63,6 @@ export const removeFromListDomainsCache = (client, urn, page, pageSize, query) =
input: {
start: (page - 1) * pageSize,
count: pageSize,
query,
},
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ describe("add remove domain", () => {
cy.clickOptionWithText("New Domain");
cy.addViaModel(test_domain, "Create new Domain")
cy.waitTextVisible("Created domain!")

cy.waitTextVisible(test_domain)

cy.waitTextVisible(test_domain)
.parents("[data-testid^='urn:li:domain:']")
.invoke('attr', 'data-testid')
Expand Down Expand Up @@ -55,9 +52,7 @@ describe("add remove domain", () => {
it("delete a domain and ensure dangling reference is deleted on entities", () => {
cy.login();
cy.goToDomainList();
cy.get('[data-testid="' + domain_created_urn + '"]').within(() => {
cy.get(".ant-dropdown-trigger").click();
});
cy.get('[data-testid="dropdown-menu-' + domain_created_urn + '"]').click();
cy.clickOptionWithText("Delete");
cy.clickOptionWithText("Yes");
cy.ensureTextNotPresent(test_domain)
Expand Down

0 comments on commit c482ef0

Please sign in to comment.