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

Demo: add placeholder views #337

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
48265cd
Create basic state management setup
latonv Jun 20, 2023
43ac1a7
Facet state refactoring to minimize repetition
latonv Sep 20, 2023
91bf555
Move facet refactor to different branch
latonv Sep 21, 2023
c817ada
First pass extracting CB data source into a reactive controller
latonv Sep 22, 2023
e0d95af
Better abstraction for data source
latonv Sep 27, 2023
b19c88f
Setup for reactive controller lifecycle
latonv Oct 18, 2023
2854c82
Top-level exports for data source
latonv Oct 18, 2023
2c07607
Remove obsolete state management stub
latonv Oct 24, 2023
489ee52
Build out some more robust interfaces for state management
latonv Oct 25, 2023
948f4a2
Facet state adjustments
latonv Nov 2, 2023
91240b6
Facet state adjustments
latonv Nov 3, 2023
f86d31a
Migrate tile mapping function into new data source
latonv Nov 6, 2023
8421e0b
Add methods for tile mapping & check/unchecking to interface
latonv Nov 7, 2023
4bb59d1
Migrate tile mapping/checking methods into data source
latonv Nov 10, 2023
3fed8b5
Keep track of data source size
latonv Nov 15, 2023
f67a807
Adjust some cb methods to delegate to data source
latonv Nov 16, 2023
dba016e
Include data source size in interface
latonv Nov 16, 2023
f4def02
Minor adjustments to how cb retrieves cell models
latonv Nov 17, 2023
8dda6a7
Reorganize some properties
latonv Nov 17, 2023
334246d
Request host updates from reactive controller
latonv Nov 21, 2023
de81037
Fix some tests
latonv Nov 24, 2023
ba242f2
Add script for quicker test running
latonv Nov 24, 2023
f08df72
Streamline models
latonv Nov 24, 2023
446072d
Conform collection browser to search state model
latonv Nov 24, 2023
ab66930
Convert derived sortParam property into getter
latonv Nov 28, 2023
9d3483b
Fix some breaking tests related to sortParam
latonv Nov 28, 2023
9c65176
Fix a model property naming issue
latonv Nov 30, 2023
5490564
Connect up data source w/ cb query change handlers
latonv Nov 30, 2023
9138106
Model updates for cb host
latonv Dec 4, 2023
4517c50
Migrate several fetch methods over to data source
latonv Dec 5, 2023
4055bab
Fix some convenience methods in cb
latonv Dec 7, 2023
99fd951
Try migrating some page fetching routines
latonv Dec 11, 2023
710eee9
Adjust search state model to accommodate page fetch
latonv Dec 12, 2023
b88ba34
Migrate page fetching & related props into data source
latonv Dec 12, 2023
146103b
Clean up cb a bit and delegate all remaining page fetches
latonv Dec 12, 2023
d1f3c4a
Excise collection-name-cache in favor of data source map
latonv Dec 12, 2023
fcf3e35
Use basic map for collection titles
latonv Dec 12, 2023
030a8e5
Data source should not fetch facets when suppressed
latonv Dec 13, 2023
2832383
Remove filterMap from search state interface (it's part of the dataso…
latonv Dec 13, 2023
5ee8643
Cleanup to avoid passing data source around
latonv Dec 13, 2023
12a1e60
Cleaning up some lingering details in cb
latonv Dec 13, 2023
6572655
Migrate prefix filters over to data source
latonv Dec 15, 2023
675fcba
Improve data source documentation + general cleanliness
latonv Dec 15, 2023
2b673df
Remove a bit of dead code in cb
latonv Dec 15, 2023
2f19df1
Fetch controller
latonv Dec 19, 2023
619e47b
Cleaner data types for page target params
latonv Dec 19, 2023
43fa399
Export TileModel interface
latonv Dec 20, 2023
082ea45
Use updated search service models
latonv Dec 20, 2023
b58cf28
Ensure that profile pages are allowed to perform no-query searches
latonv Dec 20, 2023
c6c6160
Add profile target to query keys
latonv Dec 20, 2023
db1fc28
Ensure query change updates occur on profile target changes
latonv Dec 20, 2023
354c71e
Use hits/aggregations from page_elements branch if available
latonv Dec 20, 2023
c087fda
Rely on search service to handle page_element unpacking
latonv Dec 20, 2023
4240893
Emit event for any query state changes
latonv Dec 20, 2023
3f2ad00
Add debug logging & fix result count bug
latonv Dec 28, 2023
c75e755
Fix package version
latonv Dec 28, 2023
9588030
Fix broken test
latonv Dec 28, 2023
8b77dff
Properly reset endOfDataReached upon query change
latonv Dec 30, 2023
d60368e
Fix a bug where checking tile in manage view doesn't work
latonv Dec 30, 2023
c657f97
Ensure result views are refreshed when checking/unchecking all in man…
latonv Dec 30, 2023
1a40ab0
Sort Bar Test - Ensure Resize Observer fires ONLY when needed
iisa Jan 3, 2024
f0b9733
TESTS - Fix some, comment some out that need rework with the refactor…
iisa Jan 3, 2024
6004db0
demo: add placeholder views
iisa Jan 4, 2024
317b916
add empty frame placeholder to demo
iisa Jan 4, 2024
c7a3ed5
clean up anti-pattern: move `setPlaceholderType` out of render to wil…
iisa Jan 4, 2024
9b3bade
Checkpoint: 1.14.17-beta.3 - log tweaks, + clean demo
iisa Jan 4, 2024
4dabdfc
checkpoint: 1.14.17-beta.4 - facet fetch logging
iisa Jan 4, 2024
94a0335
checkpoint: 1.14.17-beta.5 - fix red herring, clear infinite scroller…
iisa Jan 4, 2024
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
7 changes: 6 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
export { CollectionBrowser } from './src/collection-browser';
export {
CollectionBrowserDataSource,
CollectionBrowserDataSourceInterface,
} from './src/data-source/collection-browser-data-source';
export { CollectionBrowserQueryState } from './src/data-source/models';
export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
export { CollectionDisplayMode, SortField } from './src/models';
export { CollectionDisplayMode, SortField, TileModel } from './src/models';
export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
export { CollectionTile } from './src/tiles/grid/collection-tile';
export { AccountTile } from './src/tiles/grid/account-tile';
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "The Internet Archive Collection Browser.",
"license": "AGPL-3.0-only",
"author": "Internet Archive",
"version": "1.14.15",
"version": "1.14.17-beta.5",
"main": "dist/index.js",
"module": "dist/index.js",
"scripts": {
Expand All @@ -14,6 +14,7 @@
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
"circular": "madge --circular --extensions ts .",
"test": "tsc && yarn run lint && yarn run circular && wtr --coverage",
"test:fast": "tsc && wtr --coverage",
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
"deploy": "yarn run deploy:run -e $(git branch --show-current)",
"deploy:run": "yarn run prepare:ghpages && touch ghpages/.nojekyll && yarn run deploy:gh",
Expand All @@ -23,7 +24,6 @@
"types": "dist/index.d.ts",
"dependencies": {
"@internetarchive/analytics-manager": "^0.1.2",
"@internetarchive/collection-name-cache": "^0.2.16",
"@internetarchive/feature-feedback": "^0.1.4",
"@internetarchive/field-parsers": "^0.1.4",
"@internetarchive/histogram-date-range": "^1.2.0",
Expand All @@ -32,7 +32,7 @@
"@internetarchive/infinite-scroller": "1.0.1",
"@internetarchive/local-cache": "^0.2.1",
"@internetarchive/modal-manager": "^0.2.8",
"@internetarchive/search-service": "^1.2.4",
"@internetarchive/search-service": "^1.2.5-alpha.10",
"@internetarchive/shared-resize-observer": "^0.2.0",
"@lit/localize": "^0.11.2",
"dompurify": "^2.3.6",
Expand Down
104 changes: 94 additions & 10 deletions src/app-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
SearchType,
StringField,
} from '@internetarchive/search-service';
import { LocalCache } from '@internetarchive/local-cache';
import { html, css, LitElement, PropertyValues, nothing } from 'lit';
import { customElement, property, query, state } from 'lit/decorators.js';
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
import { CollectionNameCache } from '@internetarchive/collection-name-cache';

import type { ModalManagerInterface } from '@internetarchive/modal-manager';
import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
Expand All @@ -28,13 +26,6 @@ export class AppRoot extends LitElement {

private resizeObserver = new SharedResizeObserver();

private localCache = new LocalCache();

private collectionNameCache = new CollectionNameCache({
searchService: this.searchService,
localCache: this.localCache,
});

@state() private toggleSlots: boolean = false;

@state() private currentPage?: number;
Expand Down Expand Up @@ -404,6 +395,55 @@ export class AppRoot extends LitElement {
</label>
</div>
</fieldset>
<fieldset class="Placeholder-type">
<legend>Placeholder type</legend>
<div class="checkbox-control">
<input
iisa marked this conversation as resolved.
Show resolved Hide resolved
type="button"
id="placeholder-empty-query"
@click=${() => this.showEmptyPlaceholder('empty query')}
value="empty query"
/>
</div>
${this.withinCollection
? html`
<div class="checkbox-control">
<input
type="button"
id="placeholder-collection-err"
@click=${() =>
this.showEmptyPlaceholder('collection error')}
value="collection error"
/>
</div>
<div class="checkbox-control">
<input
type="button"
id="placeholder-no-results"
@click=${() =>
this.showEmptyPlaceholder('empty collection')}
value="empty collection"
/>
</div>
`
: nothing}
<div class="checkbox-control">
<input
type="button"
id="placeholder-query-err"
@click=${() => this.showEmptyPlaceholder('query error')}
value="query error"
/>
</div>
<div class="checkbox-control">
<input
type="button"
id="placeholder-loading"
@click=${() => this.showEmptyPlaceholder('placeholder loading')}
value="placeholder loading"
/>
</div>
</fieldset>
</div>
<button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}>
Toggle Search Controls
Expand All @@ -415,7 +455,6 @@ export class AppRoot extends LitElement {
.baseImageUrl=${'https://archive.org'}
.searchService=${this.searchService}
.resizeObserver=${this.resizeObserver}
.collectionNameCache=${this.collectionNameCache}
.showHistogramDatePicker=${true}
.loggedIn=${this.loggedIn}
.modalManager=${this.modalManager}
Expand Down Expand Up @@ -499,6 +538,50 @@ export class AppRoot extends LitElement {
}
}

private async showEmptyPlaceholder(placeholderType: string) {
switch (placeholderType) {
case 'empty query':
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we are on demo for developers but we should not use string slugs for checking conditions. I would write these something like empty-query, empty-collection, empty-profile something like this.

this.collectionBrowser.baseQuery = '';
this.collectionBrowser.withinCollection = '';
this.collectionBrowser.withinProfile = '';
break;
case 'empty collection':
this.collectionBrowser.baseQuery = '';
this.collectionBrowser.withinProfile = '';
await this.collectionBrowser.updateComplete;

break;
case 'empty profile':
this.collectionBrowser.baseQuery = '';
this.collectionBrowser.withinCollection = '';
this.collectionBrowser.withinProfile = '@brewster';
break;
case 'collection error':
this.collectionBrowser.withinCollection = 'acdc';
await this.collectionBrowser.updateComplete;

this.collectionBrowser.baseQuery = '';
this.collectionBrowser.queryErrorMessage = 'foo message';
break;
case 'query error':
this.collectionBrowser.baseQuery = '';
this.collectionBrowser.withinCollection = '';
this.collectionBrowser.queryErrorMessage = 'foo message';
break;
case 'placeholder loading':
this.collectionBrowser.baseQuery = '';
this.collectionBrowser.setSearchResultsLoading(true);
this.collectionBrowser.setFacetsLoading(true);
this.collectionBrowser.suppressPlaceholders = true;
this.collectionBrowser.clearResultsOnEmptyQuery = true;
this.requestUpdate();
await this.collectionBrowser.updateComplete;
break;
default:
break;
}
}

private toggleFacetGroupOutline(e: Event) {
const target = e.target as HTMLInputElement;
if (target.checked) {
Expand Down Expand Up @@ -552,6 +635,7 @@ export class AppRoot extends LitElement {
const oldQuery = this.searchQuery;
this.searchQuery = ''; // Should just reset to the placeholder
await this.updateComplete;
this.collectionBrowser.suppressPlaceholders = false;
// For unclear reasons, Safari refuses to re-apply the old query until the next tick, hence:
await new Promise(res => {
setTimeout(res, 0);
Expand Down
Loading