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

[Datahub]: Fix missing "record not found" message #884

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
9 changes: 9 additions & 0 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,12 @@ describe('userFeedback', () => {
})
})
})

describe('When the metadata does not exists', () => {
beforeEach(() => {
cy.visit('/dataset/xyz')
})
it('should display an error message', () => {
cy.get('gn-ui-search-results-error').should('exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@
<div class="container-lg mx-auto h-[1096px] sm:h-96"></div>
</div>
</div>
</div>
<div id="userFeedbacks" class="bg-primary-opacity-10 py-16 mt-[32px]">
<div class="container-lg px-4 lg:mx-auto">
<datahub-record-user-feedbacks
[organisationName$]="organisationName$"
[metadataUuid]="metadataUuid$ | async"
></datahub-record-user-feedbacks>
<div
*ngIf="loadFeedBacks$ | async"
id="userFeedbacks"
class="bg-primary-opacity-10 py-16 mt-[32px]"
>
<div class="container-lg px-4 lg:mx-auto">
<datahub-record-user-feedbacks
[organisationName$]="organisationName$"
[metadataUuid]="metadataUuid$ | async"
></datahub-record-user-feedbacks>
</div>
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export class RecordMetadataComponent {
mergeMap((uuid) => this.sourceService.getSourceLabel(uuid))
)

loadFeedBacks$ = this.metadataViewFacade.metadata$.pipe(
map((record) => record?.title),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is a use case, but what if the record doesn't have a title but all the other fields? Is there an error somewhere that we could catch instead of relying on the presence of the title?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree that it's not the best. It's just assuming that the title is the field that has the most chances to be filled...
I did try other solutions, such as using "error$" (but there was always at least one type of error that was preventing the feedbacks from loading in a working dataset). Using "isPresent$" or "metadata$" was also useless because there is indeed a metadata (made of uniqueIdentifier and title, even the fake ones).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, ok I see. Hmm... maybe @jahow has an idea for this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should rely on metadataViewFacade.isPresent$ instead :) see above in the HTML, other blocks are using it as well

Copy link
Collaborator Author

@cmoinier cmoinier May 27, 2024

Choose a reason for hiding this comment

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

I did try to use it, and it didn't work, because isPresent$ is always true when the feedbacks are loading (see second comment in this thread)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh sorry, so much for reading quickly... There might be an issue there because isPresent$ should be precisely used for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will investigate that then 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As per the last commit, isPresent works correctly again. It turns out that the "error" state was set to null while the feedbacks were loading. I removed that, and it doesn't seem to break anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, well done, this must be because of this reducer: https://github.com/geonetwork/geonetwork-ui/pull/849/files#diff-4a24c2ba947113aa39efacb131d5ce9ba63caee690c409d9d321c55b30cc0b51R83-R87

I think it makes sense that way since the error clearing has to happen only once when the complete metadata starts to load.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay. So is there something left to change on this PR then?

filter(Boolean)
)

errorTypes = ErrorType

selectedTabIndex$ = new BehaviorSubject(0)
Expand Down
Loading