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

fix(ui) Fix changing color and icon for domains in UI #12792

Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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
Loading