@internetarchive/ia-book-actions 1.2.0 → 1.3.0-alpha1

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": "1.2.0",
3
+ "version": "1.3.0-alpha1",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -266,6 +266,7 @@ export class CollapsibleActionGroup extends ActionsHandler {
266
266
 
267
267
  get getPrimaryItems() {
268
268
  return this.primaryActions
269
+ .slice(1)
269
270
  .map(
270
271
  action =>
271
272
  html`<li>${this.renderActionButton(action, this.initialButton)}</li>`
@@ -36,7 +36,7 @@ export default class ActionsConfig {
36
36
  firstBrowseConfig() {
37
37
  return {
38
38
  id: 'browseBook',
39
- text: 'Borrow (auto-renewing)',
39
+ text: 'Borrow',
40
40
  className: 'primary',
41
41
  analyticsEvent: {
42
42
  category: this.analyticsCategories.preview,
@@ -116,6 +116,8 @@ export default class ActionsHandler extends LitElement {
116
116
  const { category, action } = detail.event;
117
117
  this.loanAnanlytics?.sendEvent(category, action, this.identifier);
118
118
 
119
+ this.setStickyAdminAccess(true);
120
+
119
121
  // keep existing params and add new one
120
122
  const url = new URL(window.location.href);
121
123
  url.searchParams.append('admin', 1);
@@ -125,6 +127,8 @@ export default class ActionsHandler extends LitElement {
125
127
  this.addEventListener('exitAdminAccess', ({ detail }) => {
126
128
  const { category, action } = detail.event;
127
129
  this.loanAnanlytics?.sendEvent(category, action, this.identifier);
130
+
131
+ this.setStickyAdminAccess(false);
128
132
  });
129
133
 
130
134
  this.addEventListener('bookTitleBar', ({ detail }) => {
@@ -372,4 +376,16 @@ export default class ActionsHandler extends LitElement {
372
376
  '.archive.org'
373
377
  );
374
378
  }
379
+
380
+ /**
381
+ * Set sticky admin access on or off.
382
+ * @see WEBDEV-6835
383
+ *
384
+ * @param {boolean} value - Whether to enable or disable sticky admin access.
385
+ * @returns {void}
386
+ */
387
+ setStickyAdminAccess(value) {
388
+ const domain = window.location.hostname === 'localhost' ? 'localhost' : '.archive.org';
389
+ Cookies.setItem('sticky-admin-access', value, '', '/', domain);
390
+ }
375
391
  }
@@ -25,7 +25,7 @@ describe('Get Lending Actions', () => {
25
25
 
26
26
  expect(actions.primaryTitle).to.equal(bookTitles.available_1hr);
27
27
  expect(actions.primaryActions.length).to.equal(3);
28
- expect(actions.primaryActions[0].text).to.equal('Borrow (auto-renewing)');
28
+ expect(actions.primaryActions[0].text).to.equal('Borrow');
29
29
  expect(actions.primaryActions[1].text).to.equal('Borrow for 14 days');
30
30
  expect(actions.secondaryActions[1].text).to.equal('Purchase at ');
31
31
  });
@@ -111,7 +111,7 @@ describe('Get Lending Actions', () => {
111
111
  expect(actions.primaryTitle).to.equal(bookTitles.claim_waitlist);
112
112
  expect(actions.primaryActions.length).to.equal(3);
113
113
  expect(actions.primaryActions[0].text).to.equal('Borrow for 14 days');
114
- expect(actions.primaryActions[1].text).to.equal('Borrow (auto-renewing)');
114
+ expect(actions.primaryActions[1].text).to.equal('Borrow');
115
115
  expect(actions.primaryActions[2].text).to.equal('Leave Waitlist');
116
116
  expect(spy.called).to.be.true;
117
117
  });
@@ -138,7 +138,7 @@ describe('Get Lending Actions', () => {
138
138
  expect(actions.primaryTitle).to.equal(bookTitles.on_waitlist);
139
139
  expect(actions.primaryActions.length).to.equal(2);
140
140
  expect(actions.primaryActions[0].text).to.equal('Leave Waitlist');
141
- expect(actions.primaryActions[1].text).to.equal('Borrow (auto-renewing)');
141
+ expect(actions.primaryActions[1].text).to.equal('Borrow');
142
142
  expect(claimSpy.called).to.be.false;
143
143
  expect(waitlistSpy.called).to.be.true;
144
144
  });
@@ -162,7 +162,7 @@ describe('Get Lending Actions', () => {
162
162
  expect(actions.primaryTitle).to.equal(bookTitles.on_waitlist);
163
163
  expect(actions.primaryActions.length).to.equal(2);
164
164
  expect(actions.primaryActions[0].text).to.equal('Leave Waitlist');
165
- expect(actions.primaryActions[1].text).to.equal('Borrow (auto-renewing)');
165
+ expect(actions.primaryActions[1].text).to.equal('Borrow');
166
166
  expect(waitlistSpy.called).to.be.true;
167
167
  });
168
168
  });
@@ -228,7 +228,7 @@ describe('Borrow status actions', () => {
228
228
 
229
229
  // removed available_to_borrow from lending bar
230
230
  expect(el.lendingStatus.available_to_borrow).to.be.false;
231
- expect(el.primaryActions[0].text).to.equal('Borrow (auto-renewing)');
231
+ expect(el.primaryActions[0].text).to.equal('Borrow');
232
232
  });
233
233
 
234
234
  it('Check action for borrowable book without user', async () => {