@internetarchive/bookreader 5.0.0-56 → 5.0.0-57

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 5.0.0-57
2
+ - Fix - do not show Download pane when there aren't any available @iisa
3
+
1
4
  # 5.0.0-56
2
5
  - Fix DOMException in sandboxed iframe in chrome @cdrini
3
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-56",
3
+ "version": "5.0.0-57",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -164,7 +164,6 @@ export class BookNavigator extends LitElement {
164
164
  */
165
165
  initializeBookSubmenus() {
166
166
  const providers = {
167
- downloads: new DownloadProvider(this.baseProviderConfig),
168
167
  share: new SharingProvider(this.baseProviderConfig),
169
168
  visualAdjustments: new VisualAdjustmentProvider({
170
169
  ...this.baseProviderConfig,
@@ -175,6 +174,10 @@ export class BookNavigator extends LitElement {
175
174
  }),
176
175
  };
177
176
 
177
+ if (this.shouldShowDownloadsMenu()) {
178
+ providers.downloads = new DownloadProvider(this.baseProviderConfig);
179
+ }
180
+
178
181
  if (this.bookreader.options.enableSearch) {
179
182
  providers.search = new SearchProvider({
180
183
  ...this.baseProviderConfig,
@@ -325,6 +328,7 @@ export class BookNavigator extends LitElement {
325
328
  * @returns {bool}
326
329
  */
327
330
  shouldShowDownloadsMenu() {
331
+ if (!this.downloadableTypes.length) { return false; }
328
332
  if (this.bookIsRestricted === false) { return true; }
329
333
  if (this.isAdmin) { return true; }
330
334
  const { user_loan_record = {} } = this.lendingStatus;
@@ -148,6 +148,9 @@ describe('<book-navigator>', () => {
148
148
  el.bookreader = brStub;
149
149
  await el.elementUpdated;
150
150
 
151
+ el.downloadableTypes = ['foo/bar'];
152
+ await el.elementUpdated;
153
+
151
154
  el.initializeBookSubmenus();
152
155
  await el.elementUpdated;
153
156
  const defaultMenus = Object.keys(el.menuProviders);
@@ -229,6 +232,27 @@ describe('<book-navigator>', () => {
229
232
  expect(baseConfigKeys).toContain('isAdmin');
230
233
  expect(baseConfigKeys).toContain('onProviderChange');
231
234
  });
235
+
236
+ test('Downloads panel - does not show if no available `downloadableTypes`', async () => {
237
+ const el = fixtureSync(container());
238
+ const $brContainer = document.createElement('div');
239
+ const brStub = {
240
+ resize: sinon.fake(),
241
+ currentIndex: sinon.fake(),
242
+ jumpToIndex: sinon.fake(),
243
+ options: {},
244
+ refs: {
245
+ $brContainer
246
+ }
247
+ };
248
+ el.bookreader = brStub;
249
+ await el.elementUpdated;
250
+
251
+ el.initializeBookSubmenus();
252
+ await el.elementUpdated;
253
+ const defaultMenus = Object.keys(el.menuProviders);
254
+ expect(defaultMenus.find(menu => menu === 'downloads')).toBeUndefined;
255
+ });
232
256
  });
233
257
 
234
258
  describe('Controlling Menu Side Panel & Shortcuts', () => {