@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 +1 -1
- package/src/components/collapsible-action-group.js +1 -0
- package/src/core/services/actions-config.js +1 -1
- package/src/core/services/actions-handler/actions-handler.js +16 -0
- package/test/core/services/get-lending-actions.test.js +4 -4
- package/test/ia-book-actions.test.js +1 -1
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
231
|
+
expect(el.primaryActions[0].text).to.equal('Borrow');
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
it('Check action for borrowable book without user', async () => {
|