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

feat(advanced-search): adding select value modal #6026

Conversation

gabe-lyons
Copy link
Contributor

This is a helper component that advanced search filters will use to select values.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Sep 22, 2022
@github-actions
Copy link

github-actions bot commented Sep 22, 2022

Unit Test Results (build & test)

584 tests   580 ✔️  12m 47s ⏱️
143 suites      4 💤
143 files        0

Results for commit 83f6d60.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I have some minor comments and nits but mostly around code style / cleaning a few things up. Otherwise looks good to me!

margin-right: 4px;
`;

export const SelectContainerModal = ({ onCloseModal, defaultValues, onOkOverride, titleOverride }: Props) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would you mind changing this or the file name so they're consistent?


// Renders a search result in the select dropdown.
const renderSearchResult = (entity: Container) => {
const displayName = entity.properties?.name || entity.properties?.qualifiedName || entity.urn;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use entityRegistry.getDisplayName()?

Comment on lines 89 to 93
const filteredContainers =
containerSearchResults?.filter((entity) => entity.urn === newUrn).map((entity) => entity) || [];

if (filteredContainers.length) {
const container = filteredContainers[0] as Container;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think you need this map function. also you could use containerSearchResults?.find(entity => entity.urn === newUrn) and then you'd have the container right then if it exists!

label: defaultValue.entity ? renderDropdownResult(defaultValue.entity) : defaultValue.urn,
value: {
ownerUrn: defaultValue.urn,
ownerEntityType: EntityType.CorpUser,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be a CorpGroup ever?

const [selectedOwners, setSelectedOwners] = useState<SelectedOwner[]>(
defaultValuesToSelectedOwners(defaultValues || []),
);
console.log({ selectedOwners });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this bad boy

Comment on lines 194 to 198
console.log({
deselecting: 'deselecting',
selectedValue,
selectedOwners,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can remove this one

);
}

if (filterField === 'container') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be done in a followup, but it might be nice to have an enum or constants for these different types of filterFields instead of just strings here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see you commented the same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in the final pr 👍

<Button onClick={onCloseModal} type="text">
Cancel
</Button>
<Button disabled={stagedValue.length === 0} onClick={() => onOkOverride?.(stagedValue)}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onOkOverride makes it seem like there's a default onOk method going on here but there's not. How would you feel about just calling the prop onOk and making it required? I think you can do this with ContainerSelectModal, SelectPlatformModal, and EditTextModal below as well

}: EditTagsModalProps) {
console.log({ defaultValues });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove

if (entity?.type === EntityType.Tag) {
return (
<TagLabel
name={(entity as Tag).properties?.name || (entity as Tag).name}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use entityRegistry.getDisplayName here?

);
}

if (filterField === 'container') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see you commented the same thing

datahub-web-react/src/app/search/EditTextModal.tsx Outdated Show resolved Hide resolved
@gabe-lyons gabe-lyons merged commit 6092875 into datahub-project:master Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants