@internetarchive/ia-book-actions 0.0.30 → 0.0.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -8,8 +8,8 @@ export default async function ActionsHandlerService(options) {
8
8
  const option = {
9
9
  action: null,
10
10
  identifier: '',
11
- success() {},
12
- error() {},
11
+ success() { },
12
+ error() { },
13
13
  ...options,
14
14
  };
15
15
 
@@ -83,6 +83,8 @@ export default class ActionsHandler extends LitElement {
83
83
  const { category, action } = detail.event;
84
84
  this.sendEvent(category, action);
85
85
 
86
+ this.setStickyAdminAccess(true);
87
+
86
88
  // keep existing params and add new one
87
89
  const url = new URL(window.location.href);
88
90
  url.searchParams.append('admin', 1);
@@ -92,6 +94,8 @@ export default class ActionsHandler extends LitElement {
92
94
  this.addEventListener('exitAdminAccess', ({ detail }) => {
93
95
  const { category, action } = detail.event;
94
96
  this.sendEvent(category, action);
97
+
98
+ this.setStickyAdminAccess(false);
95
99
  });
96
100
 
97
101
  this.addEventListener('bookTitleBar', ({ detail }) => {
@@ -285,4 +289,16 @@ export default class ActionsHandler extends LitElement {
285
289
  '.archive.org'
286
290
  );
287
291
  }
292
+
293
+ /**
294
+ * Set sticky admin access on or off.
295
+ * @see WEBDEV-6835
296
+ *
297
+ * @param {boolean} value - Whether to enable or disable sticky admin access.
298
+ * @returns {void}
299
+ */
300
+ setStickyAdminAccess(value) {
301
+ const domain = window.location.hostname === 'localhost' ? 'localhost' : '.archive.org';
302
+ Cookies.setItem('sticky-admin-access', value, '', '/', domain);
303
+ }
288
304
  }
@@ -233,8 +233,8 @@ export class GetLendingActions {
233
233
  const title = lendingStatus.available_to_browse
234
234
  ? bookTitles.available_1hr
235
235
  : lendingStatus.available_to_borrow
236
- ? bookTitles.available_14d
237
- : bookTitles.unavailable;
236
+ ? bookTitles.available_14d
237
+ : bookTitles.unavailable;
238
238
 
239
239
  return {
240
240
  primaryTitle: title,
@@ -277,16 +277,16 @@ export class GetLendingActions {
277
277
  const allBrowsableCopiesTaken =
278
278
  lendingStatus.available_browsable_copies < 1 &&
279
279
  lendingStatus.available_browsable_copies <
280
- lendingStatus.max_browsable_copies;
280
+ lendingStatus.max_browsable_copies;
281
281
  // end config
282
282
 
283
283
  const title = browsingHasExpired
284
284
  ? bookTitles.session_expired
285
285
  : !canBrowse && allBrowsableCopiesTaken
286
- ? bookTitles.being_borrowed
287
- : !canBrowse && lendingStatus.available_to_waitlist
288
- ? bookTitles.available_waitlist
289
- : bookTitles.available_1hr;
286
+ ? bookTitles.being_borrowed
287
+ : !canBrowse && lendingStatus.available_to_waitlist
288
+ ? bookTitles.available_waitlist
289
+ : bookTitles.available_1hr;
290
290
 
291
291
  // one hour borrow config
292
292
  const oneHrBorrow = browsingHasExpired
@@ -300,8 +300,8 @@ export class GetLendingActions {
300
300
  const dropdownOptions = canBrowseAndBorrow
301
301
  ? [oneHrBorrow, borrow, printDisability]
302
302
  : canBrowseHasWaitlist
303
- ? [oneHrBorrow, waitlist, printDisability]
304
- : [];
303
+ ? [oneHrBorrow, waitlist, printDisability]
304
+ : [];
305
305
  const actions = canBrowseCantBorrowCantWaitlist
306
306
  ? [oneHrBorrow, printDisability]
307
307
  : dropdownOptions;
@@ -48,7 +48,7 @@ export default class IABookActions extends LitElement {
48
48
  this.lendingStatus = {};
49
49
  this.width = 0;
50
50
  this.bwbPurchaseUrl = '';
51
- this.lendingBarPostInit = () => {};
51
+ this.lendingBarPostInit = () => { };
52
52
  this.barType = 'action'; // 'title'|'action'
53
53
  this.sharedObserver = undefined;
54
54
  this.disableActionGroup = false;
@@ -96,11 +96,8 @@ export default class IABookActions extends LitElement {
96
96
  }
97
97
 
98
98
  startBrowseTimer() {
99
- const {
100
- browsingExpired,
101
- user_has_browsed,
102
- secondsLeftOnLoan,
103
- } = this.lendingStatus;
99
+ const { browsingExpired, user_has_browsed, secondsLeftOnLoan } =
100
+ this.lendingStatus;
104
101
  if (!user_has_browsed || browsingExpired) {
105
102
  return;
106
103
  }
@@ -356,7 +353,7 @@ export default class IABookActions extends LitElement {
356
353
  Please ${refreshButton} to try again or send us an email to
357
354
  <a
358
355
  href="mailto:info@archive.org?subject=Help: cannot access my borrowed book: ${this
359
- .identifier}"
356
+ .identifier}"
360
357
  >info@archive.org</a
361
358
  >`;
362
359
  }