Skip to content

Commit

Permalink
fix(ui) Fix changing color and icon for domains in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 committed Mar 5, 2025
1 parent a0319af commit ea6c087
Show file tree
Hide file tree
Showing 8 changed files with 31 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
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 ea6c087

Please sign in to comment.