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

[BIG Refactoring] Add abstraction for search backend client #464

Merged
merged 24 commits into from
Aug 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
140a053
doc: better lib structure description
jahow Jul 25, 2023
0110ea4
refactor: remove dependency from util/i18n to util/app-config
jahow Jul 25, 2023
e9e68f7
test: fix error with app-config tests
jahow Aug 22, 2023
c7f3887
chore: remove build target from md-converter lib
jahow Jul 25, 2023
32ff780
ci: upgrade node to stable
jahow Aug 22, 2023
535e53b
fix: fix metadata-converter project name
jahow Aug 23, 2023
4dee454
feat: move pivot format to common module
jahow Aug 23, 2023
a8790c3
feat: introduce gn4 records repository with associated mapper
jahow Aug 23, 2023
505666a
refactor: remove old types
jahow Aug 23, 2023
b6dd663
refactor: move fixtures to common
jahow Aug 23, 2023
734d762
refactor: adjust fileds service to use repository
jahow Aug 23, 2023
454ee42
refactor: adjust search state & effects to use repository
jahow Aug 23, 2023
d7a2a29
refactor: adjust record view state & effects to use repository
jahow Aug 23, 2023
009e6dd
refactor: adjust links & data service to use pivot format
jahow Aug 23, 2023
4dc681a
refactor: adjust sort by component to use pivot format
jahow Aug 23, 2023
384b499
refactor: adjust all files to use pivot format
jahow Aug 23, 2023
c7418a6
test: deactivate two tests
jahow Aug 23, 2023
98ccc40
feat(search): better handle missing orgs/thumbnails
jahow Aug 24, 2023
ade09fb
fix(data-service): fix wrong protocol & improve error handling
jahow Aug 24, 2023
6d70763
e2e: simplify orgs tests & adapt headers test
jahow Aug 25, 2023
d24311e
fix(downloads): display link description first
fgravin Aug 25, 2023
4ebbe7c
fix(wc): remove ConfigFilters specificity
fgravin Aug 25, 2023
a09a3fb
refactor(es): clean useless interfaces
fgravin Aug 25, 2023
07c78fe
fix(sortby): avoid null value from sortBy$ observable
fgravin Aug 25, 2023
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
Prev Previous commit
Next Next commit
feat(search): better handle missing orgs/thumbnails
jahow committed Aug 25, 2023
commit 98ccc4055e38aab21a34fa659394b502ef35b420
33 changes: 33 additions & 0 deletions libs/ui/elements/src/lib/thumbnail/thumbnail.component.spec.ts
Original file line number Diff line number Diff line change
@@ -223,4 +223,37 @@ describe('ThumbnailComponent', () => {
expect(img.nativeElement.src).toEqual(placeholderUrl)
})
})

describe('several thumbnails urls', () => {
const url = 'http://test.com/img.png'
const placeholderUrl = 'http://localhost/assets/img/placeholder.png'
let img

describe('at least one is truthy', () => {
beforeEach(() => {
component.placeholderUrl = placeholderUrl
component.thumbnailUrl = [null, undefined, url]
component.fit = ['cover', 'contain', 'contain']
fixture.detectChanges()
img = de.query(By.css('img'))
})
it('uses the truthy url', () => {
expect(img.nativeElement.src).toEqual(url)
expect(img.nativeElement.style.objectFit).toEqual('contain')
})
})

describe('no truthy url', () => {
beforeEach(() => {
component.placeholderUrl = placeholderUrl
component.thumbnailUrl = [null, undefined]
component.fit = ['cover', 'contain']
fixture.detectChanges()
img = de.query(By.css('img'))
})
it('uses the truthy url', () => {
expect(img.nativeElement.src).toEqual(placeholderUrl)
})
})
})
})
14 changes: 10 additions & 4 deletions libs/ui/elements/src/lib/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
@@ -67,10 +67,16 @@ export class ThumbnailComponent implements OnInit, OnChanges {
const urls = Array.isArray(this.thumbnailUrl)
? this.thumbnailUrl
: [this.thumbnailUrl]
this.images = urls.map((url, index) => ({
url,
fit: (Array.isArray(this.fit) ? this.fit[index] : this.fit) || 'cover',
}))
this.images = urls
.map((url, index) => ({
url,
fit: (Array.isArray(this.fit) ? this.fit[index] : this.fit) || 'cover',
}))
.filter((img) => !!img.url)
if (!this.images.length) {
this.setPlaceholder()
return
}
this.setNewSrcImage(this.images[0])
}

Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
>
<gn-ui-thumbnail
*ngIf="hasLogo"
[thumbnailUrl]="record.ownerOrganization.logoUrl.toString()"
[thumbnailUrl]="record.ownerOrganization?.logoUrl?.toString()"
></gn-ui-thumbnail>
</div>
<div class="flex flex-col overflow-hidden items-start">
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
>
<gn-ui-thumbnail
class="relative h-full w-full object-cover object-left-top"
[thumbnailUrl]="[record.overviews?.[0]?.url.toString(), organization?.logoUrl?.toString()]"
[thumbnailUrl]="[record.overviews?.[0]?.url?.toString(), organization?.logoUrl?.toString()]"
[fit]="['cover', 'contain']"
></gn-ui-thumbnail>
</div>