@internetarchive/collection-browser 1.14.14-alpha.1 → 1.14.16-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/app-root.d.ts +0 -2
  5. package/dist/src/app-root.js +0 -8
  6. package/dist/src/app-root.js.map +1 -1
  7. package/dist/src/collection-browser.d.ts +24 -169
  8. package/dist/src/collection-browser.js +68 -684
  9. package/dist/src/collection-browser.js.map +1 -1
  10. package/dist/src/collection-facets/facet-row.d.ts +2 -2
  11. package/dist/src/collection-facets/facet-row.js +5 -10
  12. package/dist/src/collection-facets/facet-row.js.map +1 -1
  13. package/dist/src/collection-facets/facets-template.d.ts +2 -2
  14. package/dist/src/collection-facets/facets-template.js +2 -2
  15. package/dist/src/collection-facets/facets-template.js.map +1 -1
  16. package/dist/src/collection-facets/more-facets-content.d.ts +2 -9
  17. package/dist/src/collection-facets/more-facets-content.js +13 -18
  18. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  19. package/dist/src/collection-facets.d.ts +2 -3
  20. package/dist/src/collection-facets.js +5 -9
  21. package/dist/src/collection-facets.js.map +1 -1
  22. package/dist/src/data-source/collection-browser-data-source.d.ts +402 -0
  23. package/dist/src/data-source/collection-browser-data-source.js +742 -0
  24. package/dist/src/data-source/collection-browser-data-source.js.map +1 -0
  25. package/dist/src/data-source/models.d.ts +35 -0
  26. package/dist/src/data-source/models.js +2 -0
  27. package/dist/src/data-source/models.js.map +1 -0
  28. package/dist/src/tiles/hover/hover-pane-controller.d.ts +2 -2
  29. package/dist/src/tiles/hover/hover-pane-controller.js +1 -1
  30. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  31. package/dist/src/tiles/hover/tile-hover-pane.d.ts +2 -2
  32. package/dist/src/tiles/hover/tile-hover-pane.js +2 -2
  33. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  34. package/dist/src/tiles/list/tile-list.d.ts +3 -3
  35. package/dist/src/tiles/list/tile-list.js +7 -13
  36. package/dist/src/tiles/list/tile-list.js.map +1 -1
  37. package/dist/src/tiles/tile-dispatcher.d.ts +2 -2
  38. package/dist/src/tiles/tile-dispatcher.js +2 -3
  39. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  40. package/dist/test/collection-browser.test.js +43 -67
  41. package/dist/test/collection-browser.test.js.map +1 -1
  42. package/dist/test/collection-facets/facet-row.test.js +6 -17
  43. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  44. package/dist/test/collection-facets.test.js +0 -5
  45. package/dist/test/collection-facets.test.js.map +1 -1
  46. package/dist/test/tiles/list/tile-list.test.js +0 -5
  47. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  48. package/index.ts +4 -0
  49. package/package.json +3 -3
  50. package/src/app-root.ts +0 -10
  51. package/src/collection-browser.ts +79 -841
  52. package/src/collection-facets/facet-row.ts +4 -9
  53. package/src/collection-facets/facets-template.ts +3 -3
  54. package/src/collection-facets/more-facets-content.ts +15 -20
  55. package/src/collection-facets.ts +5 -10
  56. package/src/data-source/collection-browser-data-source.ts +1133 -0
  57. package/src/data-source/models.ts +45 -0
  58. package/src/tiles/hover/hover-pane-controller.ts +3 -3
  59. package/src/tiles/hover/tile-hover-pane.ts +3 -3
  60. package/src/tiles/list/tile-list.ts +13 -18
  61. package/src/tiles/tile-dispatcher.ts +3 -4
  62. package/test/collection-browser.test.ts +57 -79
  63. package/test/collection-facets/facet-row.test.ts +5 -18
  64. package/test/collection-facets.test.ts +0 -5
  65. package/test/tiles/list/tile-list.test.ts +0 -5
  66. package/dist/test/mocks/mock-collection-name-cache.d.ts +0 -9
  67. package/dist/test/mocks/mock-collection-name-cache.js +0 -18
  68. package/dist/test/mocks/mock-collection-name-cache.js.map +0 -1
  69. package/test/mocks/mock-collection-name-cache.ts +0 -24
@@ -7,7 +7,6 @@ import {
7
7
  nothing,
8
8
  } from 'lit';
9
9
  import { customElement, property } from 'lit/decorators.js';
10
- import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
11
10
  import eyeIcon from '../assets/img/icons/eye';
12
11
  import eyeClosedIcon from '../assets/img/icons/eye-closed';
13
12
  import type {
@@ -16,6 +15,7 @@ import type {
16
15
  FacetEventDetails,
17
16
  FacetState,
18
17
  } from '../models';
18
+ import type { CollectionTitles } from '../data-source/models';
19
19
 
20
20
  @customElement('facet-row')
21
21
  export class FacetRow extends LitElement {
@@ -31,7 +31,7 @@ export class FacetRow extends LitElement {
31
31
 
32
32
  /** The collection name cache for converting collection identifiers to titles */
33
33
  @property({ type: Object })
34
- collectionNameCache?: CollectionNameCacheInterface;
34
+ collectionTitles?: CollectionTitles;
35
35
 
36
36
  //
37
37
  // COMPONENT LIFECYCLE METHODS
@@ -56,18 +56,13 @@ export class FacetRow extends LitElement {
56
56
  const showOnlyCheckboxId = `${facetType}:${bucket.key}-show-only`;
57
57
  const negativeCheckboxId = `${facetType}:${bucket.key}-negative`;
58
58
 
59
- // For collections, we need to asynchronously load the collection name
60
- // so we use the `async-collection-name` widget.
59
+ // For collections, we render the collection title as a link.
61
60
  // For other facet types, we just have a static value to use.
62
61
  const bucketTextDisplay =
63
62
  facetType !== 'collection'
64
63
  ? html`${bucket.displayText ?? bucket.key}`
65
64
  : html`<a href="/details/${bucket.key}">
66
- <async-collection-name
67
- .collectionNameCache=${this.collectionNameCache}
68
- .identifier=${bucket.key}
69
- placeholder="-"
70
- ></async-collection-name>
65
+ ${this.collectionTitles?.get(bucket.key) ?? bucket.key}
71
66
  </a> `;
72
67
 
73
68
  const facetHidden = bucket.state === 'hidden';
@@ -8,7 +8,6 @@ import {
8
8
  } from 'lit';
9
9
  import { customElement, property } from 'lit/decorators.js';
10
10
  import { repeat } from 'lit/directives/repeat.js';
11
- import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
12
11
  import {
13
12
  FacetGroup,
14
13
  FacetBucket,
@@ -16,6 +15,7 @@ import {
16
15
  getDefaultSelectedFacets,
17
16
  FacetEventDetails,
18
17
  } from '../models';
18
+ import type { CollectionTitles } from '../data-source/models';
19
19
  import { FacetRow } from './facet-row';
20
20
 
21
21
  @customElement('facets-template')
@@ -27,7 +27,7 @@ export class FacetsTemplate extends LitElement {
27
27
  @property({ type: String }) renderOn?: string;
28
28
 
29
29
  @property({ type: Object })
30
- collectionNameCache?: CollectionNameCacheInterface;
30
+ collectionTitles?: CollectionTitles;
31
31
 
32
32
  private facetClicked(e: CustomEvent<FacetEventDetails>) {
33
33
  const { bucket, negative } = e.detail;
@@ -126,7 +126,7 @@ export class FacetsTemplate extends LitElement {
126
126
  bucket => html`<facet-row
127
127
  .facetType=${facetGroup.key}
128
128
  .bucket=${bucket}
129
- .collectionNameCache=${this.collectionNameCache}
129
+ .collectionTitles=${this.collectionTitles}
130
130
  @facetClick=${this.facetClicked}
131
131
  ></facet-row>`
132
132
  )}
@@ -13,13 +13,13 @@ import { customElement, property, state } from 'lit/decorators.js';
13
13
  import {
14
14
  Aggregation,
15
15
  Bucket,
16
+ PageType,
16
17
  SearchServiceInterface,
17
18
  SearchParams,
18
19
  SearchType,
19
20
  AggregationSortType,
20
21
  FilterMap,
21
22
  } from '@internetarchive/search-service';
22
- import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
23
23
  import type { ModalManagerInterface } from '@internetarchive/modal-manager';
24
24
  import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
25
25
  import {
@@ -32,6 +32,7 @@ import {
32
32
  valueFacetSort,
33
33
  defaultFacetSort,
34
34
  } from '../models';
35
+ import type { CollectionTitles } from '../data-source/models';
35
36
  import '@internetarchive/ia-activity-indicator/ia-activity-indicator';
36
37
  import './more-facets-pagination';
37
38
  import './facets-template';
@@ -61,7 +62,7 @@ export class MoreFacetsContent extends LitElement {
61
62
  @property({ type: String }) withinCollection?: string;
62
63
 
63
64
  @property({ type: Object })
64
- collectionNameCache?: CollectionNameCacheInterface;
65
+ collectionTitles?: CollectionTitles;
65
66
 
66
67
  @property({ type: Object }) selectedFacets?: SelectedFacets;
67
68
 
@@ -142,7 +143,10 @@ export class MoreFacetsContent extends LitElement {
142
143
  const aggregationsSize = 65535; // todo - do we want to have all the records at once?
143
144
 
144
145
  const collectionParams = this.withinCollection
145
- ? { pageType: 'collection_details', pageTarget: this.withinCollection }
146
+ ? {
147
+ pageType: 'collection_details' as PageType,
148
+ pageTarget: this.withinCollection,
149
+ }
146
150
  : null;
147
151
 
148
152
  const params: SearchParams = {
@@ -159,6 +163,13 @@ export class MoreFacetsContent extends LitElement {
159
163
 
160
164
  this.facetGroup = this.aggregationFacetGroups;
161
165
  this.facetsLoading = false;
166
+
167
+ const collectionTitles = results?.success?.response?.collectionTitles;
168
+ if (collectionTitles) {
169
+ for (const [id, title] of Object.entries(collectionTitles)) {
170
+ this.collectionTitles?.set(id, title);
171
+ }
172
+ }
162
173
  }
163
174
 
164
175
  private pageNumberClicked(e: CustomEvent<{ page: number }>) {
@@ -285,9 +296,6 @@ export class MoreFacetsContent extends LitElement {
285
296
  !suppressedCollections[bucketKey] && !bucketKey?.startsWith('fav-')
286
297
  );
287
298
  });
288
-
289
- // asynchronously load the collection name
290
- this.preloadCollectionNames(castedBuckets);
291
299
  }
292
300
 
293
301
  // find length and pagination size for modal pagination
@@ -320,26 +328,13 @@ export class MoreFacetsContent extends LitElement {
320
328
  return facetGroups;
321
329
  }
322
330
 
323
- /**
324
- * for collections, we need to asynchronously load the collection name
325
- * so we use the `async-collection-name` widget and for the rest, we have a static value to use
326
- *
327
- * @param castedBuckets
328
- */
329
- private preloadCollectionNames(castedBuckets: any[]) {
330
- const collectionIds = castedBuckets?.map(option => option.key);
331
- const collectionIdsArray = Array.from(new Set(collectionIds)) as string[];
332
-
333
- this.collectionNameCache?.preloadIdentifiers(collectionIdsArray);
334
- }
335
-
336
331
  private get getMoreFacetsTemplate(): TemplateResult {
337
332
  return html`
338
333
  <facets-template
339
334
  .facetGroup=${this.mergedFacets?.shift()}
340
335
  .selectedFacets=${this.selectedFacets}
341
336
  .renderOn=${'modal'}
342
- .collectionNameCache=${this.collectionNameCache}
337
+ .collectionTitles=${this.collectionTitles}
343
338
  @selectedFacetsChanged=${(e: CustomEvent) => {
344
339
  this.selectedFacets = e.detail;
345
340
  }}
@@ -22,8 +22,6 @@ import type {
22
22
  } from '@internetarchive/search-service';
23
23
  import '@internetarchive/histogram-date-range';
24
24
  import '@internetarchive/feature-feedback';
25
- import '@internetarchive/collection-name-cache';
26
- import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
27
25
  import {
28
26
  ModalConfig,
29
27
  ModalManagerInterface,
@@ -47,6 +45,7 @@ import {
47
45
  suppressedCollections,
48
46
  defaultFacetSort,
49
47
  } from './models';
48
+ import type { CollectionTitles } from './data-source/models';
50
49
  import './collection-facets/more-facets-content';
51
50
  import './collection-facets/facets-template';
52
51
  import './collection-facets/facet-tombstone-row';
@@ -118,7 +117,7 @@ export class CollectionFacets extends LitElement {
118
117
  analyticsHandler?: AnalyticsManagerInterface;
119
118
 
120
119
  @property({ type: Object, attribute: false })
121
- collectionNameCache?: CollectionNameCacheInterface;
120
+ collectionTitles?: CollectionTitles;
122
121
 
123
122
  @state() openFacets: Record<FacetOption, boolean> = {
124
123
  subject: false,
@@ -188,11 +187,7 @@ export class CollectionFacets extends LitElement {
188
187
  data-id=${collxn}
189
188
  @click=${this.partOfCollectionClicked}
190
189
  >
191
- <async-collection-name
192
- .collectionNameCache=${this.collectionNameCache}
193
- .identifier=${collxn}
194
- placeholder=${collxn}
195
- ></async-collection-name>
190
+ ${this.collectionTitles?.get(collxn) ?? collxn}
196
191
  </a>
197
192
  </li>`;
198
193
  })}
@@ -652,7 +647,7 @@ export class CollectionFacets extends LitElement {
652
647
  .modalManager=${this.modalManager}
653
648
  .searchService=${this.searchService}
654
649
  .searchType=${this.searchType}
655
- .collectionNameCache=${this.collectionNameCache}
650
+ .collectionTitles=${this.collectionTitles}
656
651
  .selectedFacets=${this.selectedFacets}
657
652
  .sortedBy=${sortedBy}
658
653
  @facetsChanged=${(e: CustomEvent) => {
@@ -694,7 +689,7 @@ export class CollectionFacets extends LitElement {
694
689
  .facetGroup=${facetGroup}
695
690
  .selectedFacets=${this.selectedFacets}
696
691
  .renderOn=${'page'}
697
- .collectionNameCache=${this.collectionNameCache}
692
+ .collectionTitles=${this.collectionTitles}
698
693
  @selectedFacetsChanged=${(e: CustomEvent) => {
699
694
  const event = new CustomEvent<SelectedFacets>('facetsChanged', {
700
695
  detail: e.detail,