@internetarchive/elements 1.1.3-webdev-9240.0 → 1.1.3
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/README.md +1 -1
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.d.ts +16 -1
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.d.ts.map +1 -1
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js +136 -8
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js.map +1 -1
- package/package.json +1 -9
- package/dist/src/elements/ia-reviews/assets/delete-icon.svg +0 -8
- package/dist/src/elements/ia-reviews/assets/star-basic.svg +0 -6
- package/dist/src/elements/ia-reviews/assets/star-selected.svg +0 -8
- package/dist/src/elements/ia-reviews/assets/star-unselected.svg +0 -8
- package/dist/src/elements/ia-reviews/ia-review-form.d.ts +0 -103
- package/dist/src/elements/ia-reviews/ia-review-form.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/ia-review-form.js +0 -685
- package/dist/src/elements/ia-reviews/ia-review-form.js.map +0 -1
- package/dist/src/elements/ia-reviews/ia-review.d.ts +0 -51
- package/dist/src/elements/ia-reviews/ia-review.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/ia-review.js +0 -344
- package/dist/src/elements/ia-reviews/ia-review.js.map +0 -1
- package/dist/src/elements/ia-reviews/ia-reviews.d.ts +0 -68
- package/dist/src/elements/ia-reviews/ia-reviews.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/ia-reviews.js +0 -354
- package/dist/src/elements/ia-reviews/ia-reviews.js.map +0 -1
- package/dist/src/elements/ia-reviews/mocks/mock-fetch-handler.d.ts +0 -23
- package/dist/src/elements/ia-reviews/mocks/mock-fetch-handler.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/mocks/mock-fetch-handler.js +0 -37
- package/dist/src/elements/ia-reviews/mocks/mock-fetch-handler.js.map +0 -1
- package/dist/src/elements/ia-reviews/mocks/mock-review-service.d.ts +0 -12
- package/dist/src/elements/ia-reviews/mocks/mock-review-service.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/mocks/mock-review-service.js +0 -19
- package/dist/src/elements/ia-reviews/mocks/mock-review-service.js.map +0 -1
- package/dist/src/elements/ia-reviews/models.d.ts +0 -38
- package/dist/src/elements/ia-reviews/models.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/models.js +0 -2
- package/dist/src/elements/ia-reviews/models.js.map +0 -1
- package/dist/src/elements/ia-reviews/review-service.d.ts +0 -53
- package/dist/src/elements/ia-reviews/review-service.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/review-service.js +0 -97
- package/dist/src/elements/ia-reviews/review-service.js.map +0 -1
- package/dist/src/elements/ia-reviews/utils/collapse-space.d.ts +0 -13
- package/dist/src/elements/ia-reviews/utils/collapse-space.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/utils/collapse-space.js +0 -19
- package/dist/src/elements/ia-reviews/utils/collapse-space.js.map +0 -1
- package/dist/src/elements/ia-reviews/utils/friendly-truncate.d.ts +0 -14
- package/dist/src/elements/ia-reviews/utils/friendly-truncate.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/utils/friendly-truncate.js +0 -65
- package/dist/src/elements/ia-reviews/utils/friendly-truncate.js.map +0 -1
- package/dist/src/elements/ia-reviews/utils/link-urls-in-text.d.ts +0 -9
- package/dist/src/elements/ia-reviews/utils/link-urls-in-text.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/utils/link-urls-in-text.js +0 -40
- package/dist/src/elements/ia-reviews/utils/link-urls-in-text.js.map +0 -1
- package/dist/src/elements/ia-reviews/utils/sanitize-review-body.d.ts +0 -9
- package/dist/src/elements/ia-reviews/utils/sanitize-review-body.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/utils/sanitize-review-body.js +0 -29
- package/dist/src/elements/ia-reviews/utils/sanitize-review-body.js.map +0 -1
- package/dist/src/elements/ia-reviews/utils/truncate-screenname.d.ts +0 -13
- package/dist/src/elements/ia-reviews/utils/truncate-screenname.d.ts.map +0 -1
- package/dist/src/elements/ia-reviews/utils/truncate-screenname.js +0 -19
- package/dist/src/elements/ia-reviews/utils/truncate-screenname.js.map +0 -1
- package/dist/src/elements/index.d.ts +0 -43
- package/dist/src/elements/index.d.ts.map +0 -1
- package/dist/src/elements/index.js +0 -43
- package/dist/src/elements/index.js.map +0 -1
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { css, html, LitElement, nothing, } from 'lit';
|
|
3
|
-
import { property, state } from 'lit/decorators.js';
|
|
4
|
-
import { customElement } from '../../util/custom-element.js';
|
|
5
|
-
import { localized, msg, str } from '@lit/localize';
|
|
6
|
-
import '../../elements/ia-button/ia-button.js';
|
|
7
|
-
import { ReviewService } from './review-service.js';
|
|
8
|
-
import './ia-review.js';
|
|
9
|
-
import './ia-review-form.js';
|
|
10
|
-
/**
|
|
11
|
-
* Renders the full IA reviews piece
|
|
12
|
-
*/
|
|
13
|
-
let IAReviews = class IAReviews extends LitElement {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
/* The list of reviews to be rendered */
|
|
17
|
-
this.reviews = [];
|
|
18
|
-
/* Whether reviews are disabled for the item */
|
|
19
|
-
this.reviewsDisabled = false;
|
|
20
|
-
/* Whether reviews are frozen for the item */
|
|
21
|
-
this.reviewsFrozen = false;
|
|
22
|
-
/* Whether the person viewing the reviews section has the power to delete reviews */
|
|
23
|
-
this.canDelete = false;
|
|
24
|
-
/* Whether we should bypass the show/hide and more/less toggles */
|
|
25
|
-
this.displayReviewsByDefault = false;
|
|
26
|
-
/* Base for URLs. Also used for the reviewer profile links. */
|
|
27
|
-
this.baseHost = 'https://archive.org';
|
|
28
|
-
/* Optionally avoid using recaptcha for the form */
|
|
29
|
-
this.bypassRecaptcha = false;
|
|
30
|
-
/* Whether the add/edit button has been clicked */
|
|
31
|
-
this.reviewAddEditRequested = false;
|
|
32
|
-
/* Whether to display the review form or the editable review */
|
|
33
|
-
this.displayReviewForm = false;
|
|
34
|
-
/* Whether to display the existing reviews */
|
|
35
|
-
this.displayReviews = false;
|
|
36
|
-
/* The sorted and filtered reviews to render */
|
|
37
|
-
this.filteredReviews = [];
|
|
38
|
-
/* The number of reviews */
|
|
39
|
-
this.reviewsCount = 0;
|
|
40
|
-
/* Whether recaptcha has been activated (by clicking the add/edit button) */
|
|
41
|
-
this.recaptchaActivated = false;
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
if (this.reviewsDisabled)
|
|
45
|
-
return this.reviewsDisabledTemplate;
|
|
46
|
-
if (this.reviewsCount === 0 && !this.displayReviewForm)
|
|
47
|
-
return this.noReviewsMsgTemplate;
|
|
48
|
-
if (!this.displayReviews)
|
|
49
|
-
return this.displayReviewsMsgTemplate;
|
|
50
|
-
return html `
|
|
51
|
-
<div class="reviews-list">
|
|
52
|
-
${this.reviewsFrozen
|
|
53
|
-
? html `<div class="message">
|
|
54
|
-
${msg('Reviews can no longer be added to this item.')}
|
|
55
|
-
</div>`
|
|
56
|
-
: nothing}
|
|
57
|
-
${this.editableCurrentReviewTemplate}
|
|
58
|
-
${this.filteredReviews.map((review) => review.reviewer_itemname !== this.submitterItemname
|
|
59
|
-
? this.renderReview(review)
|
|
60
|
-
: nothing)}
|
|
61
|
-
</div>
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
willUpdate(changed) {
|
|
65
|
-
if (!this.activeReviewService ||
|
|
66
|
-
changed.has('reviewService') ||
|
|
67
|
-
changed.has('baseHost')) {
|
|
68
|
-
// the fallback keeps rendering and the form working for a consumer that supplies no
|
|
69
|
-
// service; it carries no CSRF token, so a submission through it fails
|
|
70
|
-
this.activeReviewService =
|
|
71
|
-
this.reviewService ?? new ReviewService({ baseHost: this.baseHost });
|
|
72
|
-
}
|
|
73
|
-
if (changed.has('reviews') || changed.has('submitterItemname')) {
|
|
74
|
-
this.reviewsCount = this.reviews.length;
|
|
75
|
-
this.sortFilterReviews();
|
|
76
|
-
}
|
|
77
|
-
if (changed.has('displayReviewForm') && this.displayReviewForm === true) {
|
|
78
|
-
if (!this.bypassRecaptcha && !this.recaptchaActivated)
|
|
79
|
-
this.recaptchaActivated = true;
|
|
80
|
-
this.displayReviews = true;
|
|
81
|
-
}
|
|
82
|
-
if (changed.has('displayReviewsByDefault') &&
|
|
83
|
-
this.displayReviewsByDefault) {
|
|
84
|
-
this.displayReviews = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/* Message to display if reviews are disabled */
|
|
88
|
-
get reviewsDisabledTemplate() {
|
|
89
|
-
return html `<div class="message">
|
|
90
|
-
${msg('Reviews have been disabled for this item.')}
|
|
91
|
-
</div>`;
|
|
92
|
-
}
|
|
93
|
-
/* Message to display instead of the reviews list if there are no reviews yet */
|
|
94
|
-
get noReviewsMsgTemplate() {
|
|
95
|
-
if (this.reviewsFrozen)
|
|
96
|
-
return html `
|
|
97
|
-
<div class="message">
|
|
98
|
-
${msg('Reviews cannot be added to this item.')}
|
|
99
|
-
</div>
|
|
100
|
-
`;
|
|
101
|
-
return html `
|
|
102
|
-
<div class="message">
|
|
103
|
-
${msg('There are no reviews yet.')}
|
|
104
|
-
${msg(html `
|
|
105
|
-
Be the first one to
|
|
106
|
-
<ia-button
|
|
107
|
-
mode="link"
|
|
108
|
-
class="no-reviews-btn"
|
|
109
|
-
@click=${this.addEditReview}
|
|
110
|
-
>
|
|
111
|
-
write a review</ia-button
|
|
112
|
-
>.
|
|
113
|
-
`)}
|
|
114
|
-
</div>
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
/* Message to display instead of the reviews list if reviews are hidden */
|
|
118
|
-
get displayReviewsMsgTemplate() {
|
|
119
|
-
const hasOneReview = this.reviewsCount === 1;
|
|
120
|
-
return html `
|
|
121
|
-
<div class="message">
|
|
122
|
-
${hasOneReview
|
|
123
|
-
? msg('There is 1 review for this item.')
|
|
124
|
-
: msg(str `There are ${this.reviewsCount} reviews for this item.`)}
|
|
125
|
-
<ia-button
|
|
126
|
-
mode="link"
|
|
127
|
-
class="display-reviews-btn"
|
|
128
|
-
@click=${() => (this.displayReviews = true)}
|
|
129
|
-
>
|
|
130
|
-
${hasOneReview
|
|
131
|
-
? msg('Display review')
|
|
132
|
-
: msg('Display reviews')}</ia-button
|
|
133
|
-
>.
|
|
134
|
-
</div>
|
|
135
|
-
`;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Renders the review form, passing along all necessary properties; this will also render
|
|
139
|
-
* the patron's own review if applicable and/or following submission.
|
|
140
|
-
*/
|
|
141
|
-
get editableCurrentReviewTemplate() {
|
|
142
|
-
if (!this.displayReviewForm && !this.currentReview)
|
|
143
|
-
return nothing;
|
|
144
|
-
return html `<div class="own-review-container">
|
|
145
|
-
${!this.displayReviewForm
|
|
146
|
-
? this.renderReview(this.currentReview)
|
|
147
|
-
: html `<ia-review-form
|
|
148
|
-
.identifier=${this.identifier}
|
|
149
|
-
.oldReview=${this.currentReview}
|
|
150
|
-
.submitterItemname=${this.submitterItemname}
|
|
151
|
-
.submitterScreenname=${this.submitterScreenname}
|
|
152
|
-
.maxSubjectLength=${this.maxSubjectLength}
|
|
153
|
-
.maxBodyLength=${this.maxBodyLength}
|
|
154
|
-
.unrecoverableError=${this.reviewSubmissionError}
|
|
155
|
-
.reviewService=${this.activeReviewService}
|
|
156
|
-
.recaptchaManager=${this.recaptchaActivated
|
|
157
|
-
? this.recaptchaManager
|
|
158
|
-
: undefined}
|
|
159
|
-
?bypassRecaptcha=${this.bypassRecaptcha}
|
|
160
|
-
@reviewUpdated=${this.handleReviewUpdate}
|
|
161
|
-
@reviewEditCanceled=${this.handleEditCanceled}
|
|
162
|
-
></ia-review-form>`}
|
|
163
|
-
</div>`;
|
|
164
|
-
}
|
|
165
|
-
/** Sorts the reviews and splits the patron's own review out of the reviews array */
|
|
166
|
-
sortFilterReviews() {
|
|
167
|
-
let patronsOwnReview;
|
|
168
|
-
const filteredReviews = [];
|
|
169
|
-
this.reviews.forEach((review) => {
|
|
170
|
-
if (!patronsOwnReview &&
|
|
171
|
-
review.reviewer_itemname === this.submitterItemname) {
|
|
172
|
-
patronsOwnReview = review;
|
|
173
|
-
}
|
|
174
|
-
else
|
|
175
|
-
filteredReviews.push(review);
|
|
176
|
-
});
|
|
177
|
-
this.currentReview = patronsOwnReview;
|
|
178
|
-
this.filteredReviews = this.sortReviews(filteredReviews);
|
|
179
|
-
}
|
|
180
|
-
/** Sorts reviews by create date for render */
|
|
181
|
-
sortReviews(reviews) {
|
|
182
|
-
const sortedReviews = [...reviews].sort((a, b) => a.createdate && b.createdate
|
|
183
|
-
? new Date(b.createdate).getTime() - new Date(a.createdate).getTime()
|
|
184
|
-
: 0);
|
|
185
|
-
return sortedReviews;
|
|
186
|
-
}
|
|
187
|
-
/* Renders the given review, using the ia-review component */
|
|
188
|
-
renderReview(review) {
|
|
189
|
-
if (!review)
|
|
190
|
-
return nothing;
|
|
191
|
-
return html `<ia-review
|
|
192
|
-
.review=${review}
|
|
193
|
-
.identifier=${this.identifier}
|
|
194
|
-
.baseHost=${this.baseHost}
|
|
195
|
-
.reviewService=${this.activeReviewService}
|
|
196
|
-
?canDelete=${this.canDelete}
|
|
197
|
-
?bypassTruncation=${this.displayReviewsByDefault}
|
|
198
|
-
></ia-review>`;
|
|
199
|
-
}
|
|
200
|
-
/** Prepare the review form for adding or editing */
|
|
201
|
-
addEditReview() {
|
|
202
|
-
if (!this.bypassRecaptcha)
|
|
203
|
-
this.recaptchaActivated = true;
|
|
204
|
-
this.displayReviewForm = true;
|
|
205
|
-
}
|
|
206
|
-
/** Handles successful review submission */
|
|
207
|
-
handleReviewUpdate(e) {
|
|
208
|
-
if (!this.currentReview && e.detail) {
|
|
209
|
-
this.dispatchEvent(new CustomEvent('newReviewAdded'));
|
|
210
|
-
this.reviewsCount += 1;
|
|
211
|
-
}
|
|
212
|
-
this.currentReview = e.detail;
|
|
213
|
-
this.displayReviewForm = false;
|
|
214
|
-
}
|
|
215
|
-
/** Closes the review form if requested */
|
|
216
|
-
handleEditCanceled() {
|
|
217
|
-
this.displayReviewForm = false;
|
|
218
|
-
// Display no-reviews message again if no new review was added
|
|
219
|
-
if (this.reviewsCount === 0) {
|
|
220
|
-
this.displayReviews = false;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
static get styles() {
|
|
224
|
-
return [
|
|
225
|
-
css `
|
|
226
|
-
:host {
|
|
227
|
-
font-family: var(
|
|
228
|
-
--ia-font-stack,
|
|
229
|
-
'Helvetica Neue',
|
|
230
|
-
Helvetica,
|
|
231
|
-
Arial,
|
|
232
|
-
sans-serif
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
color: var(--ia-text-color, #2c2c2c);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.reviews-list {
|
|
239
|
-
display: flex;
|
|
240
|
-
flex-direction: column;
|
|
241
|
-
gap: 2rem;
|
|
242
|
-
width: 100%;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.own-review-container {
|
|
246
|
-
--error-color: var(--container-error-color, #ea0202);
|
|
247
|
-
--link-color: var(--container-link-color, #4f65f5);
|
|
248
|
-
--container-error-color: #ea0202;
|
|
249
|
-
--container-link-color: #4f65f5;
|
|
250
|
-
--container-bg-color: #fbfbfd;
|
|
251
|
-
--container-border-color: #999999;
|
|
252
|
-
|
|
253
|
-
border: 2px solid var(--container-border-color, #999999);
|
|
254
|
-
border-radius: 5px;
|
|
255
|
-
background-color: var(--container-bg-color, #fbfbfd);
|
|
256
|
-
padding: 10px;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.message {
|
|
260
|
-
font-weight: 200;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.message ia-button {
|
|
264
|
-
display: inline;
|
|
265
|
-
vertical-align: baseline;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/* The button inside ia-button is a flex box, which would break these
|
|
269
|
-
out of the sentence they sit in. */
|
|
270
|
-
.message ia-button::part(button) {
|
|
271
|
-
display: inline;
|
|
272
|
-
min-height: 0;
|
|
273
|
-
padding: 0;
|
|
274
|
-
font-weight: 600;
|
|
275
|
-
}
|
|
276
|
-
`,
|
|
277
|
-
];
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
__decorate([
|
|
281
|
-
property({ type: String })
|
|
282
|
-
], IAReviews.prototype, "identifier", void 0);
|
|
283
|
-
__decorate([
|
|
284
|
-
property({ type: Array })
|
|
285
|
-
], IAReviews.prototype, "reviews", void 0);
|
|
286
|
-
__decorate([
|
|
287
|
-
property({ type: Boolean })
|
|
288
|
-
], IAReviews.prototype, "reviewsDisabled", void 0);
|
|
289
|
-
__decorate([
|
|
290
|
-
property({ type: Boolean })
|
|
291
|
-
], IAReviews.prototype, "reviewsFrozen", void 0);
|
|
292
|
-
__decorate([
|
|
293
|
-
property({ type: Boolean })
|
|
294
|
-
], IAReviews.prototype, "canDelete", void 0);
|
|
295
|
-
__decorate([
|
|
296
|
-
property({ type: Boolean })
|
|
297
|
-
], IAReviews.prototype, "displayReviewsByDefault", void 0);
|
|
298
|
-
__decorate([
|
|
299
|
-
property({ type: Number })
|
|
300
|
-
], IAReviews.prototype, "maxSubjectLength", void 0);
|
|
301
|
-
__decorate([
|
|
302
|
-
property({ type: Number })
|
|
303
|
-
], IAReviews.prototype, "maxBodyLength", void 0);
|
|
304
|
-
__decorate([
|
|
305
|
-
property({ type: String })
|
|
306
|
-
], IAReviews.prototype, "baseHost", void 0);
|
|
307
|
-
__decorate([
|
|
308
|
-
property({ type: String })
|
|
309
|
-
], IAReviews.prototype, "submitterScreenname", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
property({ type: String })
|
|
312
|
-
], IAReviews.prototype, "submitterItemname", void 0);
|
|
313
|
-
__decorate([
|
|
314
|
-
property({ type: Object })
|
|
315
|
-
], IAReviews.prototype, "recaptchaManager", void 0);
|
|
316
|
-
__decorate([
|
|
317
|
-
property({ type: Boolean })
|
|
318
|
-
], IAReviews.prototype, "bypassRecaptcha", void 0);
|
|
319
|
-
__decorate([
|
|
320
|
-
property({ type: String })
|
|
321
|
-
], IAReviews.prototype, "reviewSubmissionError", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
property({ type: Boolean })
|
|
324
|
-
], IAReviews.prototype, "reviewAddEditRequested", void 0);
|
|
325
|
-
__decorate([
|
|
326
|
-
property({ type: Object })
|
|
327
|
-
], IAReviews.prototype, "reviewService", void 0);
|
|
328
|
-
__decorate([
|
|
329
|
-
state()
|
|
330
|
-
], IAReviews.prototype, "activeReviewService", void 0);
|
|
331
|
-
__decorate([
|
|
332
|
-
state()
|
|
333
|
-
], IAReviews.prototype, "displayReviewForm", void 0);
|
|
334
|
-
__decorate([
|
|
335
|
-
state()
|
|
336
|
-
], IAReviews.prototype, "displayReviews", void 0);
|
|
337
|
-
__decorate([
|
|
338
|
-
state()
|
|
339
|
-
], IAReviews.prototype, "filteredReviews", void 0);
|
|
340
|
-
__decorate([
|
|
341
|
-
state()
|
|
342
|
-
], IAReviews.prototype, "currentReview", void 0);
|
|
343
|
-
__decorate([
|
|
344
|
-
state()
|
|
345
|
-
], IAReviews.prototype, "reviewsCount", void 0);
|
|
346
|
-
__decorate([
|
|
347
|
-
state()
|
|
348
|
-
], IAReviews.prototype, "recaptchaActivated", void 0);
|
|
349
|
-
IAReviews = __decorate([
|
|
350
|
-
customElement('ia-reviews'),
|
|
351
|
-
localized()
|
|
352
|
-
], IAReviews);
|
|
353
|
-
export { IAReviews };
|
|
354
|
-
//# sourceMappingURL=ia-reviews.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ia-reviews.js","sourceRoot":"","sources":["../../../../src/elements/ia-reviews/ia-reviews.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EAEH,IAAI,EAEJ,UAAU,EACV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,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M,EAAE,CAAC;gDAAwC;AAI3D;IADP,KAAK,EAAE;sDAC6C;AAIrD;IADC,KAAK,EAAE;oDAC2B;AAI3B;IADP,KAAK,EAAE;iDACgC;AAIhC;IADP,KAAK,EAAE;kDAC+B;AAI/B;IADP,KAAK,EAAE;gDACuB;AAIvB;IADP,KAAK,EAAE;+CACyB;AAIzB;IADP,KAAK,EAAE;qDACoC;AAnFjC,SAAS;IAFrB,aAAa,CAAC,YAAY,CAAC;IAC3B,SAAS,EAAE;GACC,SAAS,CA8VrB","sourcesContent":["import {\n css,\n CSSResultGroup,\n html,\n HTMLTemplateResult,\n LitElement,\n nothing,\n PropertyValues,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { customElement } from '@src/util/custom-element';\nimport { localized, msg, str } from '@lit/localize';\n\nimport type { Review } from '@internetarchive/metadata-service';\nimport type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';\n\nimport '@src/elements/ia-button/ia-button';\n\nimport type { ReviewServiceInterface } from './models';\nimport { ReviewService } from './review-service';\nimport './ia-review';\nimport './ia-review-form';\n\n/**\n * Renders the full IA reviews piece\n */\n@customElement('ia-reviews')\n@localized()\nexport class IAReviews extends LitElement {\n /** GLOBAL/REVIEW-RENDERING PROPERTIES */\n /* The identifier for the item being reviewed */\n @property({ type: String }) identifier?: string;\n\n /* The list of reviews to be rendered */\n @property({ type: Array }) reviews: Review[] = [];\n\n /* Whether reviews are disabled for the item */\n @property({ type: Boolean }) reviewsDisabled = false;\n\n /* Whether reviews are frozen for the item */\n @property({ type: Boolean }) reviewsFrozen = false;\n\n /* Whether the person viewing the reviews section has the power to delete reviews */\n @property({ type: Boolean }) canDelete = false;\n\n /* Whether we should bypass the show/hide and more/less toggles */\n @property({ type: Boolean }) displayReviewsByDefault = false;\n\n /* Maximum allowable length for subject */\n @property({ type: Number }) maxSubjectLength?: number;\n\n /* Maximum allowable length for body */\n @property({ type: Number }) maxBodyLength?: number;\n\n /* Base for URLs. Also used for the reviewer profile links. */\n @property({ type: String }) baseHost = 'https://archive.org';\n\n /** REVIEW FORM PROPERTIES */\n\n /** Form submitter's screenname, if applicable. Defaults to \"Anonymous\". */\n @property({ type: String }) submitterScreenname?: string;\n\n /** Form submitter's itemname, if applicable */\n @property({ type: String }) submitterItemname?: string;\n\n /* Service for activating the recaptcha challenge */\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n /* Optionally avoid using recaptcha for the form */\n @property({ type: Boolean }) bypassRecaptcha: boolean = false;\n\n /* An optional error message to be displayed instead of the review form */\n @property({ type: String }) reviewSubmissionError?: string;\n\n /* Whether the add/edit button has been clicked */\n @property({ type: Boolean }) reviewAddEditRequested: boolean = false;\n\n /**\n * Handles the review write and delete requests.\n *\n * Writing and deleting need one, since the service is what carries the CSRF token. Left unset,\n * reviews still render and the form still opens, but a submission reports a generic failure.\n */\n @property({ type: Object }) reviewService?: ReviewServiceInterface;\n\n /* The service the components actually call, whether injected or built here */\n @state()\n private activeReviewService?: ReviewServiceInterface;\n\n /* Whether to display the review form or the editable review */\n @state()\n displayReviewForm: boolean = false;\n\n /* Whether to display the existing reviews */\n @state()\n private displayReviews: boolean = false;\n\n /* The sorted and filtered reviews to render */\n @state()\n private filteredReviews: Review[] = [];\n\n /* The current version of the review */\n @state()\n private currentReview?: Review;\n\n /* The number of reviews */\n @state()\n private reviewsCount: number = 0;\n\n /* Whether recaptcha has been activated (by clicking the add/edit button) */\n @state()\n private recaptchaActivated: boolean = false;\n\n render() {\n if (this.reviewsDisabled) return this.reviewsDisabledTemplate;\n if (this.reviewsCount === 0 && !this.displayReviewForm)\n return this.noReviewsMsgTemplate;\n if (!this.displayReviews) return this.displayReviewsMsgTemplate;\n\n return html`\n <div class=\"reviews-list\">\n ${this.reviewsFrozen\n ? html`<div class=\"message\">\n ${msg('Reviews can no longer be added to this item.')}\n </div>`\n : nothing}\n ${this.editableCurrentReviewTemplate}\n ${this.filteredReviews.map((review) =>\n review.reviewer_itemname !== this.submitterItemname\n ? this.renderReview(review)\n : nothing,\n )}\n </div>\n `;\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (\n !this.activeReviewService ||\n changed.has('reviewService') ||\n changed.has('baseHost')\n ) {\n // the fallback keeps rendering and the form working for a consumer that supplies no\n // service; it carries no CSRF token, so a submission through it fails\n this.activeReviewService =\n this.reviewService ?? new ReviewService({ baseHost: this.baseHost });\n }\n\n if (changed.has('reviews') || changed.has('submitterItemname')) {\n this.reviewsCount = this.reviews.length;\n this.sortFilterReviews();\n }\n\n if (changed.has('displayReviewForm') && this.displayReviewForm === true) {\n if (!this.bypassRecaptcha && !this.recaptchaActivated)\n this.recaptchaActivated = true;\n this.displayReviews = true;\n }\n\n if (\n changed.has('displayReviewsByDefault') &&\n this.displayReviewsByDefault\n ) {\n this.displayReviews = true;\n }\n }\n\n /* Message to display if reviews are disabled */\n private get reviewsDisabledTemplate(): HTMLTemplateResult {\n return html`<div class=\"message\">\n ${msg('Reviews have been disabled for this item.')}\n </div>`;\n }\n\n /* Message to display instead of the reviews list if there are no reviews yet */\n private get noReviewsMsgTemplate(): HTMLTemplateResult {\n if (this.reviewsFrozen)\n return html`\n <div class=\"message\">\n ${msg('Reviews cannot be added to this item.')}\n </div>\n `;\n\n return html`\n <div class=\"message\">\n ${msg('There are no reviews yet.')}\n ${msg(html`\n Be the first one to\n <ia-button\n mode=\"link\"\n class=\"no-reviews-btn\"\n @click=${this.addEditReview}\n >\n write a review</ia-button\n >.\n `)}\n </div>\n `;\n }\n\n /* Message to display instead of the reviews list if reviews are hidden */\n private get displayReviewsMsgTemplate(): HTMLTemplateResult {\n const hasOneReview = this.reviewsCount === 1;\n\n return html`\n <div class=\"message\">\n ${hasOneReview\n ? msg('There is 1 review for this item.')\n : msg(str`There are ${this.reviewsCount} reviews for this item.`)}\n <ia-button\n mode=\"link\"\n class=\"display-reviews-btn\"\n @click=${() => (this.displayReviews = true)}\n >\n ${hasOneReview\n ? msg('Display review')\n : msg('Display reviews')}</ia-button\n >.\n </div>\n `;\n }\n\n /**\n * Renders the review form, passing along all necessary properties; this will also render\n * the patron's own review if applicable and/or following submission.\n */\n private get editableCurrentReviewTemplate():\n | HTMLTemplateResult\n | typeof nothing {\n if (!this.displayReviewForm && !this.currentReview) return nothing;\n\n return html`<div class=\"own-review-container\">\n ${!this.displayReviewForm\n ? this.renderReview(this.currentReview)\n : html`<ia-review-form\n .identifier=${this.identifier}\n .oldReview=${this.currentReview}\n .submitterItemname=${this.submitterItemname}\n .submitterScreenname=${this.submitterScreenname}\n .maxSubjectLength=${this.maxSubjectLength}\n .maxBodyLength=${this.maxBodyLength}\n .unrecoverableError=${this.reviewSubmissionError}\n .reviewService=${this.activeReviewService}\n .recaptchaManager=${this.recaptchaActivated\n ? this.recaptchaManager\n : undefined}\n ?bypassRecaptcha=${this.bypassRecaptcha}\n @reviewUpdated=${this.handleReviewUpdate}\n @reviewEditCanceled=${this.handleEditCanceled}\n ></ia-review-form>`}\n </div>`;\n }\n\n /** Sorts the reviews and splits the patron's own review out of the reviews array */\n private sortFilterReviews(): void {\n let patronsOwnReview: Review | undefined;\n const filteredReviews: Review[] = [];\n\n this.reviews.forEach((review) => {\n if (\n !patronsOwnReview &&\n review.reviewer_itemname === this.submitterItemname\n ) {\n patronsOwnReview = review;\n } else filteredReviews.push(review);\n });\n\n this.currentReview = patronsOwnReview;\n this.filteredReviews = this.sortReviews(filteredReviews);\n }\n\n /** Sorts reviews by create date for render */\n private sortReviews(reviews: Review[]): Review[] {\n const sortedReviews = [...reviews].sort((a, b) =>\n a.createdate && b.createdate\n ? new Date(b.createdate).getTime() - new Date(a.createdate).getTime()\n : 0,\n );\n\n return sortedReviews;\n }\n\n /* Renders the given review, using the ia-review component */\n private renderReview(review?: Review): HTMLTemplateResult | typeof nothing {\n if (!review) return nothing;\n\n return html`<ia-review\n .review=${review}\n .identifier=${this.identifier}\n .baseHost=${this.baseHost}\n .reviewService=${this.activeReviewService}\n ?canDelete=${this.canDelete}\n ?bypassTruncation=${this.displayReviewsByDefault}\n ></ia-review>`;\n }\n\n /** Prepare the review form for adding or editing */\n private addEditReview(): void {\n if (!this.bypassRecaptcha) this.recaptchaActivated = true;\n this.displayReviewForm = true;\n }\n\n /** Handles successful review submission */\n private handleReviewUpdate(e: CustomEvent<Review>): void {\n if (!this.currentReview && e.detail) {\n this.dispatchEvent(new CustomEvent<void>('newReviewAdded'));\n this.reviewsCount += 1;\n }\n this.currentReview = e.detail;\n this.displayReviewForm = false;\n }\n\n /** Closes the review form if requested */\n private handleEditCanceled(): void {\n this.displayReviewForm = false;\n\n // Display no-reviews message again if no new review was added\n if (this.reviewsCount === 0) {\n this.displayReviews = false;\n }\n }\n\n static get styles(): CSSResultGroup {\n return [\n css`\n :host {\n font-family: var(\n --ia-font-stack,\n 'Helvetica Neue',\n Helvetica,\n Arial,\n sans-serif\n );\n\n color: var(--ia-text-color, #2c2c2c);\n }\n\n .reviews-list {\n display: flex;\n flex-direction: column;\n gap: 2rem;\n width: 100%;\n }\n\n .own-review-container {\n --error-color: var(--container-error-color, #ea0202);\n --link-color: var(--container-link-color, #4f65f5);\n --container-error-color: #ea0202;\n --container-link-color: #4f65f5;\n --container-bg-color: #fbfbfd;\n --container-border-color: #999999;\n\n border: 2px solid var(--container-border-color, #999999);\n border-radius: 5px;\n background-color: var(--container-bg-color, #fbfbfd);\n padding: 10px;\n }\n\n .message {\n font-weight: 200;\n }\n\n .message ia-button {\n display: inline;\n vertical-align: baseline;\n }\n\n /* The button inside ia-button is a flex box, which would break these\n out of the sentence they sit in. */\n .message ia-button::part(button) {\n display: inline;\n min-height: 0;\n padding: 0;\n font-weight: 600;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { FetchHandlerInterface, FetchOptions } from '@internetarchive/fetch-handler';
|
|
2
|
-
/** A fetch() call the service made */
|
|
3
|
-
export type RecordedFetch = {
|
|
4
|
-
url: string;
|
|
5
|
-
options?: FetchOptions;
|
|
6
|
-
};
|
|
7
|
-
export declare class MockFetchHandler implements FetchHandlerInterface {
|
|
8
|
-
/** Every fetch() the service made, in order */
|
|
9
|
-
fetches: RecordedFetch[];
|
|
10
|
-
/** What fetch() should hand back. Defaults to a 200 carrying `{ success: true }`. */
|
|
11
|
-
response: () => Response;
|
|
12
|
-
fetchApiResponse<T>(): Promise<T>;
|
|
13
|
-
fetchApiPathResponse<T>(): Promise<T>;
|
|
14
|
-
fetchIAApiResponse<T>(): Promise<T>;
|
|
15
|
-
fetch(input: RequestInfo, options?: FetchOptions): Promise<Response>;
|
|
16
|
-
/** The most recent fetch the service made */
|
|
17
|
-
get lastFetch(): RecordedFetch | undefined;
|
|
18
|
-
/** The RequestInit the service handed to the handler */
|
|
19
|
-
get lastRequestInit(): RequestInit;
|
|
20
|
-
/** Body of the last fetch, decoded as url-encoded form params */
|
|
21
|
-
bodyOnLastFetch(): URLSearchParams;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=mock-fetch-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-fetch-handler.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-reviews/mocks/mock-fetch-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,gCAAgC,CAAC;AAExC,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,qBAAa,gBAAiB,YAAW,qBAAqB;IAC5D,+CAA+C;IAC/C,OAAO,EAAE,aAAa,EAAE,CAAM;IAE9B,qFAAqF;IACrF,QAAQ,EAAE,MAAM,QAAQ,CAInB;IAEC,gBAAgB,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAIjC,oBAAoB,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAIrC,kBAAkB,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAInC,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAK1E,6CAA6C;IAC7C,IAAI,SAAS,IAAI,aAAa,GAAG,SAAS,CAEzC;IAED,wDAAwD;IACxD,IAAI,eAAe,IAAI,WAAW,CAEjC;IAED,iEAAiE;IACjE,eAAe,IAAI,eAAe;CAGnC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class MockFetchHandler {
|
|
2
|
-
constructor() {
|
|
3
|
-
/** Every fetch() the service made, in order */
|
|
4
|
-
this.fetches = [];
|
|
5
|
-
/** What fetch() should hand back. Defaults to a 200 carrying `{ success: true }`. */
|
|
6
|
-
this.response = () => new Response(JSON.stringify({ success: true }), {
|
|
7
|
-
status: 200,
|
|
8
|
-
headers: { 'Content-Type': 'application/json' },
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
async fetchApiResponse() {
|
|
12
|
-
return { success: true };
|
|
13
|
-
}
|
|
14
|
-
async fetchApiPathResponse() {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
async fetchIAApiResponse() {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
async fetch(input, options) {
|
|
21
|
-
this.fetches.push({ url: input, options });
|
|
22
|
-
return this.response();
|
|
23
|
-
}
|
|
24
|
-
/** The most recent fetch the service made */
|
|
25
|
-
get lastFetch() {
|
|
26
|
-
return this.fetches[this.fetches.length - 1];
|
|
27
|
-
}
|
|
28
|
-
/** The RequestInit the service handed to the handler */
|
|
29
|
-
get lastRequestInit() {
|
|
30
|
-
return this.lastFetch?.options?.requestInit ?? {};
|
|
31
|
-
}
|
|
32
|
-
/** Body of the last fetch, decoded as url-encoded form params */
|
|
33
|
-
bodyOnLastFetch() {
|
|
34
|
-
return new URLSearchParams(String(this.lastRequestInit.body ?? ''));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=mock-fetch-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-fetch-handler.js","sourceRoot":"","sources":["../../../../../src/elements/ia-reviews/mocks/mock-fetch-handler.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,gBAAgB;IAA7B;QACE,+CAA+C;QAC/C,YAAO,GAAoB,EAAE,CAAC;QAE9B,qFAAqF;QACrF,aAAQ,GAAmB,GAAG,EAAE,CAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;YAC9C,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAC;IAiCP,CAAC;IA/BC,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAO,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,EAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAkB,EAAE,OAAsB;QACpD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAe,EAAE,OAAO,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED,6CAA6C;IAC7C,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,wDAAwD;IACxD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,IAAI,EAAE,CAAC;IACpD,CAAC;IAED,iEAAiE;IACjE,eAAe;QACb,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["import type {\n FetchHandlerInterface,\n FetchOptions,\n} from '@internetarchive/fetch-handler';\n\n/** A fetch() call the service made */\nexport type RecordedFetch = {\n url: string;\n options?: FetchOptions;\n};\n\nexport class MockFetchHandler implements FetchHandlerInterface {\n /** Every fetch() the service made, in order */\n fetches: RecordedFetch[] = [];\n\n /** What fetch() should hand back. Defaults to a 200 carrying `{ success: true }`. */\n response: () => Response = () =>\n new Response(JSON.stringify({ success: true }), {\n status: 200,\n headers: { 'Content-Type': 'application/json' },\n });\n\n async fetchApiResponse<T>(): Promise<T> {\n return { success: true } as T;\n }\n\n async fetchApiPathResponse<T>(): Promise<T> {\n return {} as T;\n }\n\n async fetchIAApiResponse<T>(): Promise<T> {\n return {} as T;\n }\n\n async fetch(input: RequestInfo, options?: FetchOptions): Promise<Response> {\n this.fetches.push({ url: input as string, options });\n return this.response();\n }\n\n /** The most recent fetch the service made */\n get lastFetch(): RecordedFetch | undefined {\n return this.fetches[this.fetches.length - 1];\n }\n\n /** The RequestInit the service handed to the handler */\n get lastRequestInit(): RequestInit {\n return this.lastFetch?.options?.requestInit ?? {};\n }\n\n /** Body of the last fetch, decoded as url-encoded form params */\n bodyOnLastFetch(): URLSearchParams {\n return new URLSearchParams(String(this.lastRequestInit.body ?? ''));\n }\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ReviewDeletion, ReviewServiceInterface, ReviewServiceResult, ReviewSubmission } from '../models.js';
|
|
2
|
-
export declare class MockReviewService implements ReviewServiceInterface {
|
|
3
|
-
/** Submissions the form handed over, in order */
|
|
4
|
-
submissions: ReviewSubmission[];
|
|
5
|
-
/** Deletions the review handed over, in order */
|
|
6
|
-
deletions: ReviewDeletion[];
|
|
7
|
-
/** What both operations report back */
|
|
8
|
-
result: ReviewServiceResult;
|
|
9
|
-
submitReview(submission: ReviewSubmission): Promise<ReviewServiceResult>;
|
|
10
|
-
deleteReview(deletion: ReviewDeletion): Promise<ReviewServiceResult>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=mock-review-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-review-service.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-reviews/mocks/mock-review-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,qBAAa,iBAAkB,YAAW,sBAAsB;IAC9D,iDAAiD;IACjD,WAAW,EAAE,gBAAgB,EAAE,CAAM;IAErC,iDAAiD;IACjD,SAAS,EAAE,cAAc,EAAE,CAAM;IAEjC,uCAAuC;IACvC,MAAM,EAAE,mBAAmB,CAAqB;IAE1C,YAAY,CAChB,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IAKzB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAI3E"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export class MockReviewService {
|
|
2
|
-
constructor() {
|
|
3
|
-
/** Submissions the form handed over, in order */
|
|
4
|
-
this.submissions = [];
|
|
5
|
-
/** Deletions the review handed over, in order */
|
|
6
|
-
this.deletions = [];
|
|
7
|
-
/** What both operations report back */
|
|
8
|
-
this.result = { success: true };
|
|
9
|
-
}
|
|
10
|
-
async submitReview(submission) {
|
|
11
|
-
this.submissions.push(submission);
|
|
12
|
-
return this.result;
|
|
13
|
-
}
|
|
14
|
-
async deleteReview(deletion) {
|
|
15
|
-
this.deletions.push(deletion);
|
|
16
|
-
return this.result;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=mock-review-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-review-service.js","sourceRoot":"","sources":["../../../../../src/elements/ia-reviews/mocks/mock-review-service.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,iBAAiB;IAA9B;QACE,iDAAiD;QACjD,gBAAW,GAAuB,EAAE,CAAC;QAErC,iDAAiD;QACjD,cAAS,GAAqB,EAAE,CAAC;QAEjC,uCAAuC;QACvC,WAAM,GAAwB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAalD,CAAC;IAXC,KAAK,CAAC,YAAY,CAChB,UAA4B;QAE5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAwB;QACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type {\n ReviewDeletion,\n ReviewServiceInterface,\n ReviewServiceResult,\n ReviewSubmission,\n} from '../models';\n\nexport class MockReviewService implements ReviewServiceInterface {\n /** Submissions the form handed over, in order */\n submissions: ReviewSubmission[] = [];\n\n /** Deletions the review handed over, in order */\n deletions: ReviewDeletion[] = [];\n\n /** What both operations report back */\n result: ReviewServiceResult = { success: true };\n\n async submitReview(\n submission: ReviewSubmission,\n ): Promise<ReviewServiceResult> {\n this.submissions.push(submission);\n return this.result;\n }\n\n async deleteReview(deletion: ReviewDeletion): Promise<ReviewServiceResult> {\n this.deletions.push(deletion);\n return this.result;\n }\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/** A review the patron is submitting, before it's mapped onto wire field names */
|
|
2
|
-
export type ReviewSubmission = {
|
|
3
|
-
/** The IA item being reviewed */
|
|
4
|
-
identifier: string;
|
|
5
|
-
/** Review subject */
|
|
6
|
-
title: string;
|
|
7
|
-
/** Review body */
|
|
8
|
-
body: string;
|
|
9
|
-
/** Star rating, '0' for no rating */
|
|
10
|
-
stars?: string;
|
|
11
|
-
/** ReCaptcha response, when the form ran a challenge */
|
|
12
|
-
recaptchaToken?: string;
|
|
13
|
-
};
|
|
14
|
-
/** The review to remove, identified by its reviewer */
|
|
15
|
-
export type ReviewDeletion = {
|
|
16
|
-
/** The IA item the review belongs to */
|
|
17
|
-
identifier: string;
|
|
18
|
-
/** Reviewer screenname */
|
|
19
|
-
reviewer: string;
|
|
20
|
-
/** Reviewer itemname, used when the reviewer's account is gone */
|
|
21
|
-
reviewerItemname?: string;
|
|
22
|
-
};
|
|
23
|
-
/** The outcome of a review write or delete */
|
|
24
|
-
export type ReviewServiceResult = {
|
|
25
|
-
success: boolean;
|
|
26
|
-
/** A message to show the patron, present when success is false */
|
|
27
|
-
error?: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Handles the network side of reviews, so the components only render state.
|
|
31
|
-
*/
|
|
32
|
-
export interface ReviewServiceInterface {
|
|
33
|
-
/** Add or update the patron's own review of an item */
|
|
34
|
-
submitReview(submission: ReviewSubmission): Promise<ReviewServiceResult>;
|
|
35
|
-
/** Remove a review, which the backend allows only for review moderators */
|
|
36
|
-
deleteReview(deletion: ReviewDeletion): Promise<ReviewServiceResult>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=models.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-reviews/models.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IAEnB,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;IAEd,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IAEb,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG;IAC3B,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IAEnB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IAEjB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IAEjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,YAAY,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEzE,2EAA2E;IAC3E,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACtE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/elements/ia-reviews/models.ts"],"names":[],"mappings":"","sourcesContent":["/** A review the patron is submitting, before it's mapped onto wire field names */\nexport type ReviewSubmission = {\n /** The IA item being reviewed */\n identifier: string;\n\n /** Review subject */\n title: string;\n\n /** Review body */\n body: string;\n\n /** Star rating, '0' for no rating */\n stars?: string;\n\n /** ReCaptcha response, when the form ran a challenge */\n recaptchaToken?: string;\n};\n\n/** The review to remove, identified by its reviewer */\nexport type ReviewDeletion = {\n /** The IA item the review belongs to */\n identifier: string;\n\n /** Reviewer screenname */\n reviewer: string;\n\n /** Reviewer itemname, used when the reviewer's account is gone */\n reviewerItemname?: string;\n};\n\n/** The outcome of a review write or delete */\nexport type ReviewServiceResult = {\n success: boolean;\n\n /** A message to show the patron, present when success is false */\n error?: string;\n};\n\n/**\n * Handles the network side of reviews, so the components only render state.\n */\nexport interface ReviewServiceInterface {\n /** Add or update the patron's own review of an item */\n submitReview(submission: ReviewSubmission): Promise<ReviewServiceResult>;\n\n /** Remove a review, which the backend allows only for review moderators */\n deleteReview(deletion: ReviewDeletion): Promise<ReviewServiceResult>;\n}\n"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { FetchHandlerInterface } from '@internetarchive/fetch-handler';
|
|
2
|
-
import type { ReviewDeletion, ReviewServiceInterface, ReviewServiceResult, ReviewSubmission } from './models.js';
|
|
3
|
-
export type ReviewServiceOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Handles retries and the CSRF token.
|
|
6
|
-
*
|
|
7
|
-
* Writing and deleting need a handler built with a `getCsrfToken` source, since that is what
|
|
8
|
-
* supplies the `X-CSRF-Token` header these endpoints require. The token resolves per request,
|
|
9
|
-
* so it doesn't have to be known when the service is constructed.
|
|
10
|
-
*/
|
|
11
|
-
fetchHandler?: FetchHandlerInterface;
|
|
12
|
-
/** Origin for the endpoints. Empty string keeps requests same-origin. */
|
|
13
|
-
baseHost?: string;
|
|
14
|
-
/** Path a review submission POSTs to */
|
|
15
|
-
submitPath?: string;
|
|
16
|
-
/** Path a review deletion goes to */
|
|
17
|
-
deletePath?: string;
|
|
18
|
-
/** Verb the delete endpoint expects */
|
|
19
|
-
deleteMethod?: 'POST' | 'DELETE';
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Talks to the archive.org review endpoints.
|
|
23
|
-
*
|
|
24
|
-
* The CSRF token is left to the fetch handler: both operations opt into its automatic
|
|
25
|
-
* `X-CSRF-Token` header, which resolves the token per request.
|
|
26
|
-
*/
|
|
27
|
-
export declare class ReviewService implements ReviewServiceInterface {
|
|
28
|
-
private fetchHandler;
|
|
29
|
-
private baseHost;
|
|
30
|
-
private submitPath;
|
|
31
|
-
private deletePath;
|
|
32
|
-
private deleteMethod;
|
|
33
|
-
constructor(options?: ReviewServiceOptions);
|
|
34
|
-
/** @inheritdoc */
|
|
35
|
-
submitReview(submission: ReviewSubmission): Promise<ReviewServiceResult>;
|
|
36
|
-
/** @inheritdoc */
|
|
37
|
-
deleteReview(deletion: ReviewDeletion): Promise<ReviewServiceResult>;
|
|
38
|
-
/**
|
|
39
|
-
* Sends a credentialed request and reads the `{ success, error }` result out of it.
|
|
40
|
-
*/
|
|
41
|
-
private request;
|
|
42
|
-
/**
|
|
43
|
-
* Reads a result out of a response.
|
|
44
|
-
*
|
|
45
|
-
* The status decides the outcome, so a rejected request can't read as a success. fetch
|
|
46
|
-
* resolves on a 4xx or 5xx, so that check can't be left to the catch. A JSON body supplies
|
|
47
|
-
* the patron-facing message; the legacy delete endpoint answers with an HTML page instead,
|
|
48
|
-
* and there the status is all there is to go on.
|
|
49
|
-
*/
|
|
50
|
-
private parseResult;
|
|
51
|
-
private get genericError();
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=review-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"review-service.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-reviews/review-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAErC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CAClC,CAAC;AAMF;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,sBAAsB;IAC1D,OAAO,CAAC,YAAY,CAAwB;IAE5C,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,YAAY,CAAoB;gBAE5B,OAAO,CAAC,EAAE,oBAAoB;IAQ1C,kBAAkB;IACZ,YAAY,CAChB,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IAoB/B,kBAAkB;IACZ,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAe1E;;OAEG;YACW,OAAO;IAqBrB;;;;;;;OAOG;YACW,WAAW;IAiBzB,OAAO,KAAK,YAAY,GAEvB;CACF"}
|