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: org thumbnail loading time and contacts overrides #538

Merged
merged 8 commits into from
Jul 24, 2023

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Jul 20, 2023

Organisations observables now use shareReplay to avoid multiple call from toRecord method.

Contact is not overrided anymore to prevent wrong display in metadata view.

Only first resourceContact logoUrl is overrided.

@f-necas f-necas requested a review from fgravin July 20, 2023 11:08
@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2023

Affected libs: feature-catalog, feature-record, feature-router, feature-search, feature-map, feature-dataviz, util-shared, feature-auth, ui-elements, ui-catalog, ui-search, ui-widgets, feature-editor, ui-inputs, ui-map,
Affected apps: datahub, demo, webcomponents, metadata-editor, search, map-viewer, metadata-converter, datafeeder,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@f-necas f-necas marked this pull request as ready for review July 20, 2023 11:56
contactFromOrg, // FIXME: this should go into an organization field
...metadataRecord.resourceContacts,
]
if (org && !record.resourceContacts?.[0].logoUrl && org.logoUrl) {
Copy link
Member

Choose a reason for hiding this comment

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

You should take the email if not present.

@f-necas f-necas requested a review from fgravin July 20, 2023 12:29
const logoUrl = getAsUrl(`${org.logoUrl}`)
metadataRecord.resourceContacts[0].logoUrl = logoUrl // FIXME: this should go into an organization field
metadataRecord.resourceContacts[0].email ??= org.email
metadataRecord.contact.email ??= org.email
Copy link
Member

Choose a reason for hiding this comment

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

The if statement is not correct for the email set.

I would suggest to keep your mapContactFromOrganisation and change the name to hydrateContactWithOrg, and do all the stuff in there.

I would also not touch the record.contact, you are guessing record.contact and record.resourceContacts[0] are the same but it might not be the case.

Note that the group strategy seems quite different as it adds new contacts within the metadata, which is a bit weird IMO, anyway, the group has the priority in that case so it's ok.

website: metadataRecord.resourceContacts[0].website,
} as MetadataContact

metadataRecord.resourceContacts = [
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't add a new contact like for the group strategy, that was my point in the previous message.
BTW if you do that the name of the function is not meaningful.

The group strategy add a new contact from the group of the record (which could be different from the recource contact), while the metadata strategy just hydrates the first existing resource contact.

organisation: 'Ifremer',
},
{
email: '[email protected]',
logoUrl:
Copy link
Member

Choose a reason for hiding this comment

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

The test is wrong.
You should write what you expect first, and code the correct behavior, instead of coding and adapting the test so it can pass 😉

Here what we said

  1. logo of the contact if it exists
  2. logo of the organisation
  3. logo of the record

In your test, it set the logo of the record while it should use the logo of the organisation instead (because resourceContact[0].logoUrl = '')

Probably, during the mapping, the resource contact logoUrl is set to the record logo if null in the contact, before the mapping with the organisation, which breaks the priority.

fix: use record logo in last resort
@@ -54,12 +54,25 @@ export const mapLogo = (source: SourceWithUnknownProps) => {
return logo ? getAsUrl(`/geonetwork${logo}`) : null
}

export const hydrateWithRecordLogo = (
Copy link
Member

Choose a reason for hiding this comment

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

I would just call it hydrateContactsWithRecordLogo

Do the tests cover this function ? Probably

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed.

Yes this function is covered in both org-from-metadata and org from-groups classes.

const logoUrl =
firstResourceContact.logoUrl ||
(organisation.logoUrl ? getAsUrl(`${organisation.logoUrl}`) : null)
const mappedOrg = {
Copy link
Member

Choose a reason for hiding this comment

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

I think that we said that the organisation props would only hydrate missing contact props, didn't we ? 🤔
Would mean that the priority is the contact email, the contact logo, the contact name etc...

@fgravin fgravin merged commit 116e47c into main Jul 24, 2023
8 checks passed
@fgravin fgravin deleted the fix-org-thumbnail branch July 24, 2023 13:26
@fgravin fgravin linked an issue Jul 26, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Datahub]: Use organisation logo if no thumbnail
2 participants