@internetarchive/ia-book-actions 0.0.19-1 → 0.0.19-5

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.19-1",
3
+ "version": "0.0.19-5",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -14,12 +14,15 @@ export default css`
14
14
  align-items: center;
15
15
  }
16
16
  .action-buttons .ia-button {
17
- margin: 0 3px;
17
+ margin: 0;
18
18
  height: 3.5rem;
19
19
  }
20
20
  .primary,
21
21
  .secondary {
22
22
  position: relative;
23
+ background-color: var(--white, #fff);
24
+ border-radius: 5px;
25
+ margin: 0 3px;
23
26
  }
24
27
  .primary .initial {
25
28
  border-radius: 0.4rem 0 0 0.4rem;
@@ -112,6 +115,9 @@ export default css`
112
115
  display: inline-block;
113
116
  vertical-align: middle;
114
117
  }
118
+ .secondary .ia-button.exit-admin {
119
+ background-color: var(--primaryBGColor);
120
+ }
115
121
  .purchase small {
116
122
  display: block;
117
123
  font-size: 1rem;
@@ -50,7 +50,10 @@ export class CollapsibleActionGroup extends ActionsHandler {
50
50
  }
51
51
 
52
52
  updated(changed) {
53
- if (changed.has('width') && this.isBelowTabletContainer) {
53
+ if (
54
+ (changed.has('width') || changed.has('disabled')) &&
55
+ this.isBelowTabletContainer
56
+ ) {
54
57
  this.resetActions();
55
58
  }
56
59
  }
@@ -110,6 +113,9 @@ export class CollapsibleActionGroup extends ActionsHandler {
110
113
  <section class="action-buttons secondary">
111
114
  ${this.renderSecondaryActions}
112
115
  </section>
116
+ <section class="action-buttons secondary purchase">
117
+ ${this.renderPurchaseAction}
118
+ </section>
113
119
  </div>
114
120
  `;
115
121
  }
@@ -147,13 +153,27 @@ export class CollapsibleActionGroup extends ActionsHandler {
147
153
  return this.secondaryActions.map(action => this.renderActionLink(action));
148
154
  }
149
155
 
156
+ get renderPurchaseAction() {
157
+ if (!this.secondaryActions.length) return nothing;
158
+
159
+ if (this.secondaryActions.length === 2) {
160
+ return this.renderActionLink(this.secondaryActions[1], true);
161
+ }
162
+ if (this.secondaryActions[0].id === 'purchaseBook') {
163
+ return this.renderActionLink(this.secondaryActions[0], true);
164
+ }
165
+ return nothing;
166
+ }
167
+
150
168
  /**
151
- * Render action as a link for secondary actions like admin, purchase, printdisability links.
169
+ * Render action as a link for secondary actions like admin, printdisability links.
152
170
  * @param { Object } action
153
171
  * @param { Boolean } initialButton
154
172
  * @returns { HTMLElement }
155
173
  */
156
174
  renderActionLink(action, initialButton = false) {
175
+ if (!initialButton && action?.id === 'purchaseBook') return nothing; // handle purchase action differerntly
176
+
157
177
  return html`<a
158
178
  class="ia-button ${action.className} ${initialButton ? 'initial' : ''}"
159
179
  href="${action.url}"
@@ -226,7 +226,7 @@ export default class ActionsConfig {
226
226
  text: message,
227
227
  url: URLHelper.getBackHref(),
228
228
  target: '_self',
229
- className: 'ia-button',
229
+ className: 'exit-admin',
230
230
  analyticsEvent: {
231
231
  category: this.analyticsCategories.adminAccess,
232
232
  action: this.analyticsActions.doneBorrowing,
@@ -22,8 +22,6 @@ export default class ActionsHandler extends LitElement {
22
22
  }
23
23
 
24
24
  sendEvent(eventCategory, eventAction) {
25
- // eslint-disable-next-line no-console
26
- console?.log('Book action: ', { eventCategory, eventAction });
27
25
  window?.archive_analytics?.send_event_no_sampling(
28
26
  eventCategory,
29
27
  eventAction,
@@ -419,8 +419,6 @@ export default class GetLendingActions {
419
419
  lendingActions = this.restrictedAction();
420
420
  }
421
421
 
422
- // debugging console
423
- console.log(lendingActions.primaryTitle);
424
422
  return lendingActions;
425
423
  }
426
424
  }
@@ -60,8 +60,6 @@ export class LoanTokenPoller {
60
60
  }
61
61
 
62
62
  sendEvent(eventCategory, eventAction) {
63
- // eslint-disable-next-line no-console
64
- console?.log('Book action: ', { eventCategory, eventAction });
65
63
  window?.archive_analytics?.send_event_no_sampling(
66
64
  eventCategory,
67
65
  eventAction,
@@ -77,6 +75,8 @@ export class LoanTokenPoller {
77
75
  error: data => {
78
76
  this.disconnectedInterval(); // stop token fetch api
79
77
  this.errorCallback({ detail: { action, data } });
78
+ // send LendingServiceError to GA
79
+ this.sendEvent('LendingServiceLoanError', action);
80
80
  },
81
81
  success: () => {
82
82
  if (isInitial) this.successCallback();