@fluid-topics/ft-reader-feedback 1.0.57 → 1.0.58

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.
@@ -2,7 +2,7 @@ import { nothing } from "lit";
2
2
  import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
4
  import { FtTopicRatingSummary } from "@fluid-topics/ft-reader-context/build/store/model";
5
- import type { FtPublicationRatingSummary, FtUserProfile } from "@fluid-topics/public-api";
5
+ import type { FtPublicationRatingSummary, FtSession } from "@fluid-topics/public-api";
6
6
  import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
7
7
  import { FtTextArea } from "@fluid-topics/ft-text-area";
8
8
  import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
@@ -27,7 +27,7 @@ export declare class FtReaderFeedback extends FtReaderFeedback_base implements F
27
27
  ratingAllowed: boolean;
28
28
  i18nProperties: FeedbackI18nProperties;
29
29
  ratingSummary?: FtPublicationRatingSummary | FtTopicRatingSummary;
30
- user?: FtUserProfile;
30
+ session?: FtSession;
31
31
  feedbackInput: FtTextArea;
32
32
  from: string;
33
33
  feedbackMessage: string;
@@ -21,7 +21,7 @@ import { withI18n } from "@fluid-topics/ft-i18n";
21
21
  import { defaultDesignerMessages, designer } from "./utils/InDesignerFeedbackComponentMessages";
22
22
  import { FtTextField } from "@fluid-topics/ft-text-field";
23
23
  import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
24
- import { FtReaderFeatures } from "@fluid-topics/ft-reader-context/build/store/utils/FtReaderService";
24
+ import { FtReaderFeatures } from "@fluid-topics/ft-reader-context";
25
25
  class FtReaderFeedback extends withI18n(FtReaderComponent) {
26
26
  constructor() {
27
27
  super();
@@ -41,14 +41,14 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
41
41
  }
42
42
  get canAccessFeedback() {
43
43
  var _a;
44
- return this.user && userHasRole(this.user.roles, "FEEDBACK_USER") && ((_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.FEEDBACK));
44
+ return (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.FEEDBACK, { session: this.session });
45
45
  }
46
46
  get canAccessRating() {
47
- var _a;
48
- return this.userHasRatingRole && this.configuredRatingType !== "NO_RATING" && ((_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.RATING));
47
+ var _a, _b;
48
+ return (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.RATING, { session: this.session, ratingType: (_b = this.ratingSummary) === null || _b === void 0 ? void 0 : _b.type });
49
49
  }
50
50
  get userHasRatingRole() {
51
- return this.user && userHasRole(this.user.roles, "RATING_USER");
51
+ return this.session && userHasRole(this.session, "RATING_USER");
52
52
  }
53
53
  get configuredRatingType() {
54
54
  var _a, _b;
@@ -188,7 +188,7 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
188
188
  }
189
189
  }
190
190
  renderFeedbackSection() {
191
- var _a, _b;
191
+ var _a, _b, _c;
192
192
  if (this.canAccessFeedback) {
193
193
  const mailLink = this.feedbackMailLinkBuilder(this.feedbackMessage);
194
194
  let button = html `
@@ -212,13 +212,13 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
212
212
  <ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
213
213
  ${this.i18n(this.i18nProperties.feedbackSectionTitle)}
214
214
  </ft-typography>
215
- ${((_a = this.user) === null || _a === void 0 ? void 0 : _a.userId) == null && ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers) ? html `
215
+ ${((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) == null && ((_c = this.configuration) === null || _c === void 0 ? void 0 : _c.mailsSentByFluidTopicsForUnauthenticatedUsers) ? html `
216
216
  <ft-text-field outlined
217
- class="ft-reader-feedback--from-input"
218
- label=${feedback.messages.feedbackfromEmail()}
219
- @live-change=${(e) => this.from = e.detail.trim()}
220
- ?error=${this.from && !this.validFromEmail()}
221
- helper=${this.from && !this.validFromEmail() ? feedback.messages.feedbackfromEmailInvalid() : ""}
217
+ class="ft-reader-feedback--from-input"
218
+ label=${feedback.messages.feedbackfromEmail()}
219
+ @live-change=${(e) => this.from = e.detail.trim()}
220
+ ?error=${this.from && !this.validFromEmail()}
221
+ helper=${this.from && !this.validFromEmail() ? feedback.messages.feedbackfromEmailInvalid() : ""}
222
222
  />
223
223
  ` : nothing}
224
224
  <ft-text-area outlined
@@ -233,9 +233,9 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
233
233
  return this.placeholderInEditor(designer.messages.missingFeedbackRole());
234
234
  }
235
235
  validFromEmail() {
236
- var _a, _b;
236
+ var _a, _b, _c;
237
237
  const expression = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
238
- return !(((_a = this.user) === null || _a === void 0 ? void 0 : _a.userId) == null && ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers))
238
+ return !(((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) == null && ((_c = this.configuration) === null || _c === void 0 ? void 0 : _c.mailsSentByFluidTopicsForUnauthenticatedUsers))
239
239
  || expression.test(this.from);
240
240
  }
241
241
  sendFeedback() {
@@ -293,7 +293,7 @@ __decorate([
293
293
  ], FtReaderFeedback.prototype, "ratingSummary", void 0);
294
294
  __decorate([
295
295
  property({ attribute: false })
296
- ], FtReaderFeedback.prototype, "user", void 0);
296
+ ], FtReaderFeedback.prototype, "session", void 0);
297
297
  __decorate([
298
298
  query(".ft-reader-feedback--feedback-input")
299
299
  ], FtReaderFeedback.prototype, "feedbackInput", void 0);