Skip to content

Commit

Permalink
fix(ui) Fix changing color and icon for domains in UI (#12792)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 authored Mar 5, 2025
1 parent 9cb5886 commit 1068e2b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class DomainType
Constants.OWNERSHIP_ASPECT_NAME,
Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME,
Constants.STRUCTURED_PROPERTIES_ASPECT_NAME,
Constants.FORMS_ASPECT_NAME);
Constants.FORMS_ASPECT_NAME,
Constants.DISPLAY_PROPERTIES_ASPECT_NAME);
private final EntityClient _entityClient;

public DomainType(final EntityClient entityClient) {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/domain/DomainsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export const DomainsList = () => {
},
ownership: null,
entities: null,
displayProperties: null,
},
pageSize,
);
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/domain/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const updateListDomainsCache = (
children: null,
dataProducts: null,
parentDomains: null,
displayProperties: null,
},
1000,
parentDomain,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Input, Modal } from 'antd';
import { debounce } from 'lodash';
import React from 'react';
import styled from 'styled-components';

Expand Down Expand Up @@ -53,13 +52,6 @@ const IconColorPicker: React.FC<IconColorPickerProps> = ({
const [stagedColor, setStagedColor] = React.useState<string>(color || '#000000');
const [stagedIcon, setStagedIcon] = React.useState<string>(icon || 'account_circle');

// a debounced version of updateDisplayProperties that takes in the same arguments
// eslint-disable-next-line react-hooks/exhaustive-deps
const debouncedUpdateDisplayProperties = React.useCallback(
debounce((...args) => updateDisplayProperties(...args).then(() => setTimeout(() => refetch(), 1000)), 500),
[],
);

return (
<Modal
open={open}
Expand All @@ -77,7 +69,7 @@ const IconColorPicker: React.FC<IconColorPickerProps> = ({
},
},
},
});
}).then(() => refetch());
onChangeColor?.(stagedColor);
onChangeIcon?.(stagedIcon);
onClose();
Expand All @@ -93,44 +85,10 @@ const IconColorPicker: React.FC<IconColorPickerProps> = ({
marginBottom: 30,
marginTop: 15,
}}
onChange={(e) => {
setStagedColor(e.target.value);
debouncedUpdateDisplayProperties?.({
variables: {
urn,
input: {
colorHex: e.target.value,
icon: {
iconLibrary: IconLibrary.Material,
name: stagedIcon,
style: 'Outlined',
},
},
},
});
}}
onChange={(e) => setStagedColor(e.target.value)}
/>
<Title>Choose an icon for {name || 'Domain'}</Title>
<ChatIconPicker
color={stagedColor}
onIconPick={(i) => {
console.log('picking icon', i);
debouncedUpdateDisplayProperties?.({
variables: {
urn,
input: {
colorHex: stagedColor,
icon: {
iconLibrary: IconLibrary.Material,
name: capitalize(snakeToCamel(i)),
style: 'Outlined',
},
},
},
});
setStagedIcon(i);
}}
/>
<ChatIconPicker color={stagedColor} onIconPick={(i) => setStagedIcon(i)} />
</Modal>
);
};
Expand Down
6 changes: 6 additions & 0 deletions datahub-web-react/src/graphql/domain.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ query getDomain($urn: String!) {
forms {
...formsFields
}
displayProperties {
...displayPropertiesFields
}
...domainEntitiesFields
...notes
}
Expand All @@ -64,6 +67,9 @@ query listDomains($input: ListDomainsInput!) {
ownership {
...ownershipFields
}
displayProperties {
...displayPropertiesFields
}
...domainEntitiesFields
}
}
Expand Down
9 changes: 9 additions & 0 deletions datahub-web-react/src/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ fragment parentNodesFields on ParentNodesResult {
properties {
name
}
displayProperties {
...displayPropertiesFields
}
}
}

Expand All @@ -238,6 +241,9 @@ fragment parentDomainsFields on ParentDomainsResult {
urn
type
... on Domain {
displayProperties {
...displayPropertiesFields
}
properties {
name
description
Expand Down Expand Up @@ -1259,6 +1265,9 @@ fragment entityDomain on DomainAssociation {
...parentDomainsFields
}
...domainEntitiesFields
displayProperties {
...displayPropertiesFields
}
}
associatedUrn
}
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/glossaryNode.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ query getGlossaryNode($urn: String!) {
}
}
}
displayProperties {
...displayPropertiesFields
}
...notes
}
}
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/preview.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ fragment entityPreview on Entity {
parentDomains {
...parentDomainsFields
}
displayProperties {
...displayPropertiesFields
}
...domainEntitiesFields
}
... on Container {
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ fragment searchResultsWithoutSchemaField on Entity {
parentDomains {
...parentDomainsFields
}
displayProperties {
...displayPropertiesFields
}
...domainEntitiesFields
structuredProperties {
properties {
Expand Down
2 changes: 2 additions & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ entities:
- structuredProperties
- forms
- testResults
- displayProperties
- name: container
doc: A container of related data assets.
category: core
Expand Down Expand Up @@ -300,6 +301,7 @@ entities:
- forms
- testResults
- subTypes
- displayProperties
- name: dataHubIngestionSource
category: internal
keyAspect: dataHubIngestionSourceKey
Expand Down

0 comments on commit 1068e2b

Please sign in to comment.