@beinformed/ui 1.15.1 → 1.17.0

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/esm/hooks/useAuthentication.js +4 -1
  3. package/esm/hooks/useAuthentication.js.map +1 -1
  4. package/esm/models/application/ApplicationModel.js +13 -2
  5. package/esm/models/application/ApplicationModel.js.map +1 -1
  6. package/esm/models/attributes/AttributeContent.js +4 -7
  7. package/esm/models/attributes/AttributeContent.js.map +1 -1
  8. package/esm/models/href/Href.js +11 -1
  9. package/esm/models/href/Href.js.map +1 -1
  10. package/esm/redux/actions/SignIn.js +9 -0
  11. package/esm/redux/actions/SignIn.js.map +1 -1
  12. package/esm/redux/reducers/AuthReducer.js +5 -0
  13. package/esm/redux/reducers/AuthReducer.js.map +1 -1
  14. package/esm/utils/helpers/checkResource.js +39 -0
  15. package/esm/utils/helpers/checkResource.js.map +1 -0
  16. package/esm/utils/index.js +1 -1
  17. package/esm/utils/index.js.map +1 -1
  18. package/lib/hooks/useAuthentication.js +3 -0
  19. package/lib/hooks/useAuthentication.js.flow +7 -5
  20. package/lib/hooks/useAuthentication.js.map +1 -1
  21. package/lib/models/application/ApplicationModel.js +13 -2
  22. package/lib/models/application/ApplicationModel.js.flow +7 -0
  23. package/lib/models/application/ApplicationModel.js.map +1 -1
  24. package/lib/models/attributes/AttributeContent.js +4 -7
  25. package/lib/models/attributes/AttributeContent.js.flow +3 -6
  26. package/lib/models/attributes/AttributeContent.js.map +1 -1
  27. package/lib/models/href/Href.js +11 -1
  28. package/lib/models/href/Href.js.flow +12 -1
  29. package/lib/models/href/Href.js.map +1 -1
  30. package/lib/redux/actions/SignIn.js +14 -2
  31. package/lib/redux/actions/SignIn.js.flow +8 -0
  32. package/lib/redux/actions/SignIn.js.map +1 -1
  33. package/lib/redux/reducers/AuthReducer.js +5 -0
  34. package/lib/redux/reducers/AuthReducer.js.flow +3 -0
  35. package/lib/redux/reducers/AuthReducer.js.map +1 -1
  36. package/lib/redux/reducers/__tests__/AuthReducer.spec.js.flow +52 -13
  37. package/lib/redux/types.js.flow +5 -0
  38. package/lib/utils/helpers/__tests__/checkResource.spec.js.flow +60 -0
  39. package/lib/utils/helpers/checkResource.js +54 -0
  40. package/lib/utils/helpers/checkResource.js.flow +42 -0
  41. package/lib/utils/helpers/checkResource.js.map +1 -0
  42. package/lib/utils/index.js +4 -4
  43. package/lib/utils/index.js.flow +1 -1
  44. package/lib/utils/index.js.map +1 -1
  45. package/package.json +10 -10
  46. package/src/hooks/useAuthentication.js +7 -5
  47. package/src/models/application/ApplicationModel.js +7 -0
  48. package/src/models/attributes/AttributeContent.js +3 -6
  49. package/src/models/href/Href.js +12 -1
  50. package/src/redux/actions/SignIn.js +8 -0
  51. package/src/redux/reducers/AuthReducer.js +3 -0
  52. package/src/redux/reducers/__tests__/AuthReducer.spec.js +52 -13
  53. package/src/redux/types.js +5 -0
  54. package/src/utils/helpers/__tests__/checkResource.spec.js +60 -0
  55. package/src/utils/helpers/checkResource.js +42 -0
  56. package/src/utils/index.js +1 -1
  57. package/esm/utils/helpers/checkResourceExists.js +0 -23
  58. package/esm/utils/helpers/checkResourceExists.js.map +0 -1
  59. package/lib/utils/helpers/checkResourceExists.js +0 -34
  60. package/lib/utils/helpers/checkResourceExists.js.flow +0 -21
  61. package/lib/utils/helpers/checkResourceExists.js.map +0 -1
  62. package/src/utils/helpers/checkResourceExists.js +0 -21
@@ -92,6 +92,13 @@ export default class ApplicationModel extends ResourceModel {
92
92
  return this._userServices ? this._userServices : null;
93
93
  }
94
94
 
95
+ /**
96
+ * Indicates if the user is logged in
97
+ */
98
+ get isLoggedIn(): boolean {
99
+ return this.userServices?.isLoggedIn ?? false;
100
+ }
101
+
95
102
  /**
96
103
  * Retrieve link to the user information,
97
104
  * only available when the user services are available
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","userLink","data","contributions","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,gB;;;;;;;;;;;;;;;;;;;;;;;;AAGnB;AACF;AACA;AACE,mBAAmB;AACjB,aAAO,aAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,UAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;AACA,UAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;AACrD,cAAM,IAAIC,kCAAJ,CACJ,kIADI,CAAN;AAGD;;AAED,aAAOL,WAAW,GAAG,CAACA,WAAD,CAAH,GAAmB,EAArC;AACD;AAED;AACF;;;;WACE,wBAAeM,MAAf,EAA8C;AAC5C,UAAMC,gBAAgB,GAAG,mBAAAD,MAAM,MAAN,CAAAA,MAAM,EAC7B,UAACE,KAAD;AAAA,eAAWA,KAAK,CAACC,IAAN,KAAe,cAA1B;AAAA,OAD6B,CAA/B;;AAIA,UAAIF,gBAAJ,EAAsB;AACpB,aAAKG,YAAL,GAAoBH,gBAApB;AACD;AACF;AAED;AACF;AACA;;;;SACE,eAAoB;AAClB,aAAO,KAAKI,eAAL,CAAqB,OAArB,EAA8B,EAA9B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA2B;AACzB,aAAO,KAAKV,KAAL,CAAWW,eAAX,CAA2B,KAA3B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA8B;AAC5B,aAAOC,mBAAUC,MAAV,CAAiB,cAAjB,EAAiC,eAAjC,EAAkD,eAAlD,CAAP;AACD;AAED;AACF;AACA;;;;;AAKE;AACF;AACA;AACE,mBAAuC;AACrC,aAAO,KAAKC,aAAL,GAAqB,KAAKA,aAA1B,GAA0C,IAAjD;AACD;AAED;AACF;AACA;AACA;;SAdE,aAAiBP,KAAjB,EAAyC;AACvC,WAAKO,aAAL,GAAqBP,KAAK,YAAYQ,0BAAjB,GAAqCR,KAArC,GAA6C,IAAlE;AACD;;;SAaD,eAA4B;AAC1B,UAAI,KAAKE,YAAL,IAAqB,IAArB,IAA6B,KAAKA,YAAL,CAAkBO,QAAlB,IAA8B,IAA/D,EAAqE;AACnE,eAAO,KAAKP,YAAL,CAAkBO,QAAlB,CAA2Bd,IAAlC;AACD;;AAED,aAAO,IAAP;AACD;;;WA7ED,2BAAyBe,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACC,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;AAID;;;EAjB2CC,uB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.js"}
1
+ {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userLink","data","contributions","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,gB;;;;;;;;;;;;;;;;;;;;;;;;AAGnB;AACF;AACA;AACE,mBAAmB;AACjB,aAAO,aAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,UAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;AACA,UAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;AACrD,cAAM,IAAIC,kCAAJ,CACJ,kIADI,CAAN;AAGD;;AAED,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,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;AAID;;;EAjB2CC,uB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.js"}
@@ -119,8 +119,7 @@ var AttributeContent = /*#__PURE__*/function () {
119
119
  var _this$_content$elemen;
120
120
 
121
121
  return (_this$_content$elemen = this._content.elements) === null || _this$_content$elemen === void 0 ? void 0 : (0, _map.default)(_this$_content$elemen).call(_this$_content$elemen, function (element) {
122
- if ("propertyElement" in element) {
123
- // $FlowIssue[prop-missing]
122
+ if (element.propertyElement) {
124
123
  var _element$propertyElem = element.propertyElement,
125
124
  label = _element$propertyElem.label,
126
125
  layouthint = _element$propertyElem.layouthint,
@@ -134,9 +133,8 @@ var AttributeContent = /*#__PURE__*/function () {
134
133
  };
135
134
  }
136
135
 
137
- if ("textFragmentElement" in element) {
138
- var _element$textFragment = // $FlowIssue[prop-missing]
139
- element.textFragmentElement,
136
+ if (element.textFragmentElement) {
137
+ var _element$textFragment = element.textFragmentElement,
140
138
  _label = _element$textFragment.label,
141
139
  _layouthint = _element$textFragment.layouthint,
142
140
  textfragments = _element$textFragment.textfragments;
@@ -153,8 +151,7 @@ var AttributeContent = /*#__PURE__*/function () {
153
151
  };
154
152
  }
155
153
 
156
- if ("contentElement" in element) {
157
- // $FlowIssue[prop-missing]
154
+ if (element.contentElement) {
158
155
  var _element$contentEleme = element.contentElement,
159
156
  _label2 = _element$contentEleme.label,
160
157
  _layouthint2 = _element$contentEleme.layouthint,
@@ -61,8 +61,7 @@ class AttributeContent {
61
61
  get elements(): ContentAll {
62
62
  if (this._content?.elements) {
63
63
  return this._content.elements?.map((element) => {
64
- if ("propertyElement" in element) {
65
- // $FlowIssue[prop-missing]
64
+ if (element.propertyElement) {
66
65
  const { label, layouthint, properties } = element.propertyElement;
67
66
 
68
67
  return {
@@ -74,9 +73,8 @@ class AttributeContent {
74
73
  };
75
74
  }
76
75
 
77
- if ("textFragmentElement" in element) {
76
+ if (element.textFragmentElement) {
78
77
  const { label, layouthint, textfragments } =
79
- // $FlowIssue[prop-missing]
80
78
  element.textFragmentElement;
81
79
  return {
82
80
  textFragmentElement: {
@@ -90,8 +88,7 @@ class AttributeContent {
90
88
  };
91
89
  }
92
90
 
93
- if ("contentElement" in element) {
94
- // $FlowIssue[prop-missing]
91
+ if (element.contentElement) {
95
92
  const { label, layouthint, sections } = element.contentElement;
96
93
  return {
97
94
  contentElement: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAaMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,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GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue[prop-missing]\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue[prop-missing]\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue[prop-missing]\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAaMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG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AAP;AAID;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMK,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
@@ -403,11 +403,21 @@ var Href = /*#__PURE__*/function () {
403
403
  return this.querystring.length > 0 ? [this.path, this.querystring].join("?") : this.path;
404
404
  }
405
405
  /**
406
- * Getting the URL including the base path
406
+ * Getting the URL including the base path, querystring is prefixed
407
407
  */
408
408
 
409
409
  }, {
410
410
  key: "absolutehref",
411
+ get: function get() {
412
+ var querystring = this.getQuerystring(false);
413
+ return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
414
+ }
415
+ /**
416
+ * Getting the URL including the base path, the querystring is prefixed
417
+ */
418
+
419
+ }, {
420
+ key: "absolutehrefPrefixedQuerystring",
411
421
  get: function get() {
412
422
  var querystring = this.getQuerystring(true);
413
423
  return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
@@ -366,9 +366,20 @@ class Href {
366
366
  }
367
367
 
368
368
  /**
369
- * Getting the URL including the base path
369
+ * Getting the URL including the base path, querystring is prefixed
370
370
  */
371
371
  get absolutehref(): string {
372
+ const querystring = this.getQuerystring(false);
373
+
374
+ return querystring.length > 0
375
+ ? [this.absolutepath, querystring].join("?")
376
+ : this.absolutepath;
377
+ }
378
+
379
+ /**
380
+ * Getting the URL including the base path, the querystring is prefixed
381
+ */
382
+ get absolutehrefPrefixedQuerystring(): string {
372
383
  const querystring = this.getQuerystring(true);
373
384
 
374
385
  return querystring.length > 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/href/Href.js"],"names":["Href","href","resourcetype","path","parameters","hash","state","method","HTTP_METHODS","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","Parameter","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","BASE","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","IllegalArgumentException","CONTENT_PATH","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAgBA;AACA;AACA;IACMA,I;AAQJ;AACF;AACA;AACE,gBAAYC,IAAZ,EAA8BC,YAA9B,EAAqD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACnD,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,KAAL,GAAa,IAAb;AACA,SAAKC,MAAL,GAAcC,wBAAaC,GAA3B;AACA,SAAKP,YAAL,GAAoBA,YAAY,IAAI,EAApC;;AAEA,QAAID,IAAI,YAAYD,IAApB,EAA0B;AACxB,WAAKU,WAAL,CAAiBT,IAAjB;AACD,KAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AACnC,WAAKU,aAAL,CAAmBV,IAAnB;AACD,KAFM,MAEA,IAAI,sBAAOA,IAAP,MAAgB,QAApB,EAA8B;AACnC,WAAKW,uBAAL,CAA6BX,IAA7B;AACD;AACF;AAED;AACF;AACA;;;;;WACE,qBA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E,I","sourcesContent":["// @flow\nimport { BASE, CONTENT_PATH, HTTP_METHODS } from \"../../constants/Constants\";\n\nimport Parameter from \"../parameter/Parameter\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { LocationShape } from \"react-router\";\n\ntype HrefObject = {\n _path: string,\n _hash: string,\n _parameters: Array<Parameter>,\n _resourcetype: string,\n _method: $Keys<typeof HTTP_METHODS>,\n _state: ?{ [key: string]: any },\n pathname: ?string,\n};\n\nexport type HrefInput = Href | HrefObject | LocationShape | string;\n\n/**\n * Defines a Href with the parameters\n */\nclass Href {\n _path: string;\n _hash: string;\n _parameters: Array<Parameter>;\n _resourcetype: string;\n _method: $Keys<typeof HTTP_METHODS>;\n _state: ?{ +[key: string]: any };\n\n /**\n * Create a Href\n */\n constructor(href?: HrefInput, resourcetype?: string) {\n this.path = \"\";\n this.parameters = [];\n this.hash = \"\";\n this.state = null;\n this.method = HTTP_METHODS.GET;\n this.resourcetype = resourcetype || \"\";\n\n if (href instanceof Href) {\n this.setFromHref(href);\n } else if (typeof href === \"string\") {\n this.setFromString(href);\n } else if (typeof href === \"object\") {\n this.setFromLocationOrObject(href);\n }\n }\n\n /**\n * Set parameters from Href model input\n */\n setFromHref(href: Href) {\n this.path = href.path;\n this.parameters = href.parameters;\n this.hash = href.hash;\n this.state = href.state;\n }\n\n /**\n */\n setFromLocationOrObject(href: LocationShape | HrefObject) {\n if (typeof href[\"pathname\"] === \"string\") {\n this.path = href.pathname;\n } else if (typeof href._path === \"string\") {\n this.path = href._path;\n }\n\n if (href.search) {\n this.addParametersFromString(href.search);\n } else if (Array.isArray(href._parameters)) {\n // $FlowExpectedError[incompatible-call]\n href._parameters.map((param: Parameter) =>\n this.addParameter(param._name, param._value, param._prefix)\n );\n }\n\n if (href.hash) {\n this.hash = Href.getHashFromString(href.hash);\n } else if (typeof href._hash === \"string\") {\n this.hash = href._hash;\n }\n\n if (href.state) {\n this.state = href.state || null;\n } else if (typeof href._state === \"object\") {\n this.state = href._state;\n }\n }\n\n /**\n * Set parameters from string input\n */\n setFromString(href: string) {\n this.path = Href.getPathFromString(href);\n this.addParametersFromString(href);\n this.hash = Href.getHashFromString(href);\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this._path.includes(\"/change-password\");\n }\n\n /**\n * check if the path is referencing a camel route\n */\n static isCamelRoute(path: string): boolean {\n return (\n path.startsWith(\"/restServices\") && !path.startsWith(\"/restServices/ui\")\n );\n }\n\n /**\n */\n static checkAbsoluteUrl(href: string): boolean {\n const checkAbsolute = new RegExp(\"^(?:[a-z]+:)?//\", \"i\");\n return checkAbsolute.test(href);\n }\n\n // Check if url is relative (not checking for absolute urls with same domain)\n /**\n */\n get isExternal(): boolean {\n return Href.checkAbsoluteUrl(this.path);\n }\n\n /**\n * Retrieve the relative path part of a href string, e.g. https://www.beinformed.com/BeInformed/tab/view?q=url => /tab/view\n */\n static getPathFromString(href: string): string {\n const decodedHref = decodeURI(href);\n\n const hrefNoHash = decodedHref.includes(\"#\")\n ? decodedHref.substr(0, decodedHref.indexOf(\"#\"))\n : decodedHref;\n\n return hrefNoHash.includes(\"?\") ? hrefNoHash.split(\"?\")[0] : hrefNoHash;\n }\n\n /**\n * Retrieve hash of href string\n */\n static getHashFromString(href: string = \"\"): string {\n return href.includes(\"#\") ? href.substr(href.indexOf(\"#\") + 1) : \"\";\n }\n\n /**\n * Add a parameter for each parameter found in the querystring of an URL string, e.g. https://www.beinformed.com?q=url => q=url\n */\n addParametersFromString(href: string): Href {\n if (href.includes(\"?\")) {\n href\n .split(\"?\")[1]\n .split(\"&\")\n .forEach((param) => {\n const paramFromString = Parameter.fromString(param);\n if (paramFromString) {\n this.setParameter(\n paramFromString.name,\n paramFromString.value,\n paramFromString.prefix\n );\n }\n });\n }\n\n return this;\n }\n\n /**\n * Add a querystring parameter to the parameter collection of this Href, skips parameters that have a value of null\n */\n addParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value !== null) {\n this.removeParameter(name, prefix);\n this._parameters.push(new Parameter(prefix, name, value));\n }\n\n return this;\n }\n\n /**\n * Adds or overwrites a parameter when it exists and value is not null.\n * Removes the parameter when the value is null\n */\n setParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value === null) {\n this.removeParameter(name, prefix);\n } else {\n this.addParameter(name, value, prefix);\n }\n\n return this;\n }\n\n /**\n * Retrieve a parameter by it's name and (optionally) prefix\n */\n getParameter(name: string, prefix: ?string): ?Parameter {\n return this._parameters.find(\n (param) => param.prefix === prefix && param.name === name\n );\n }\n\n /**\n */\n hasParameter(name: string, prefix: ?string): boolean {\n return this.getParameter(name, prefix) !== undefined;\n }\n\n /**\n * Get request method\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n * Set request method\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method || HTTP_METHODS.GET;\n }\n\n /**\n * Retrieve all paremters\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n * Replace parameters of Href\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n * Remove a parameter from the parameter collection\n */\n removeParameter(name: string, prefix: ?string): Href {\n this._parameters = this._parameters.filter(\n (param) => param.prefix !== prefix || param.name !== name\n );\n\n return this;\n }\n\n /**\n * Get the parameters as a querystring, e.g. param1=value1&param2=value2, optionally with prefix\n */\n getQuerystring(withPrefix: boolean = false): string {\n return this.parameters\n .filter((param) => param.value != null)\n .map((param) => param.toQuerystring(withPrefix))\n .join(\"&\");\n }\n\n /**\n * Retrieve a querystring that only contains parameter that can be send to the modular ui, parameters are filtered by prefix\n */\n getQuerystringForModularUI(prefix: string = \"\"): string {\n return this.parameters\n .filter(\n (param) =>\n param.isModUIParameter &&\n (!prefix || !param.prefix || param.prefix === prefix) &&\n param.value != null\n )\n .map((param) => param.toQuerystring(false))\n .join(\"&\");\n }\n\n /**\n * Retrieve all parameters from the parameter collection in a querystring style name1=value1&name2=value2, without the prefix\n */\n get querystring(): string {\n return this.getQuerystring(false);\n }\n\n /**\n * Set the path of the Href, the part before the querystring question mark\n */\n set path(path: string) {\n this._path = path;\n }\n\n /**\n * Retrieve the path\n */\n get path(): string {\n return this._path || \"\";\n }\n\n /**\n * Set hash\n */\n set hash(hash: string) {\n this._hash = hash;\n }\n\n /**\n * Retrieve hash\n */\n get hash(): string {\n return this._hash;\n }\n\n /**\n */\n set state(state: ?{ +[key: string]: any }) {\n this._state = state;\n }\n\n /**\n */\n get state(): ?{ +[key: string]: any } {\n return this._state;\n }\n\n /**\n */\n setState(state: { [key: string]: any }): Href {\n this.state = state;\n\n return this;\n }\n\n /**\n * Set resourctype\n */\n set resourcetype(resourcetype: string) {\n this._resourcetype = resourcetype;\n }\n\n /**\n * Retrieve resourceType\n */\n get resourcetype(): string {\n return this._resourcetype;\n }\n\n /**\n * Retrieve the path combined with the BASE of the application, e.g. /BeInformed\n */\n get absolutepath(): string {\n if (this.isExternal) {\n return this.path;\n }\n\n return BASE + this.path;\n }\n\n /**\n * Retrieves the combination of the path and the querystring\n */\n get href(): string {\n return this.querystring.length > 0\n ? [this.path, this.querystring].join(\"?\")\n : this.path;\n }\n\n /**\n * Getting the URL including the base path\n */\n get absolutehref(): string {\n const querystring = this.getQuerystring(true);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Checks if the URL starts within the given href\n */\n startsWith(href: Href | string): boolean {\n const thisPath = `${this.path}/`;\n const otherPath = href instanceof Href ? `${href.path}/` : href;\n\n return thisPath.startsWith(otherPath);\n }\n\n /**\n * Checks if the given Href equals this Href\n */\n equals(href: Href | string): boolean {\n if (href instanceof Href) {\n return this.path === href.path;\n }\n\n return this.path === href;\n }\n\n /**\n */\n equalsWithParameters(href: Href): boolean {\n if (!this.equals(href)) {\n return false;\n }\n\n if (href instanceof Href) {\n if (this.parameters.length !== href.parameters.length) {\n return false;\n }\n\n if (this.parameters.length === 0 && href.parameters.length === 0) {\n return true;\n }\n\n const thisParams = this.parameters.map((param) => param.toString());\n\n return href.parameters.every((param) =>\n thisParams.includes(param.toString())\n );\n }\n\n throw new IllegalArgumentException(`${href} is not an instance of Href`);\n }\n\n /**\n * Indicates if the link is a content link\n */\n get isContent(): boolean {\n return this.absolutepath.startsWith(CONTENT_PATH);\n }\n\n /**\n * Returns a complete url from the Href\n */\n toString(): string {\n return this.href;\n }\n\n /**\n */\n toLocation(): LocationShape {\n return {\n pathname: this.path,\n search: this.querystring.length > 0 ? `?${this.querystring}` : \"\",\n hash: this.hash.length > 0 ? `#${this.hash}` : \"\",\n state: this.state,\n };\n }\n}\n\nexport default Href;\n"],"file":"Href.js"}
1
+ {"version":3,"sources":["../../../src/models/href/Href.js"],"names":["Href","href","resourcetype","path","parameters","hash","state","method","HTTP_METHODS","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","Parameter","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","BASE","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","IllegalArgumentException","CONTENT_PATH","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAgBA;AACA;AACA;IACMA,I;AAQJ;AACF;AACA;AACE,gBAAYC,IAAZ,EAA8BC,YAA9B,EAAqD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACnD,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,KAAL,GAAa,IAAb;AACA,SAAKC,MAAL,GAAcC,wBAAaC,GAA3B;AACA,SAAKP,YAAL,GAAoBA,YAAY,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X,CAAAA,WAAW,EAAU,GAAV,CAAX,GACfA,WAAW,CAACG,MAAZ,CAAmB,CAAnB,EAAsBH,WAAW,CAACI,OAAZ,CAAoB,GAApB,CAAtB,CADe,GAEfJ,WAFJ;AAIA,aAAO,uBAAAE,UAAU,MAAV,CAAAA,UAAU,EAAU,GAAV,CAAV,GAA2BA,UAAU,CAACtC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAA3B,GAAsDsC,UAA7D;AACD;AAED;AACF;AACA;;;;WACE,6BAAoD;AAAA,UAA3BnE,IAA2B,uEAAZ,EAAY;AAClD,aAAO,uBAAAA,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GAAqBA,IAAI,CAACoE,MAAL,CAAYpE,IAAI,CAACqE,OAAL,CAAa,GAAb,IAAoB,CAAhC,CAArB,GAA0D,EAAjE;AACD;;;;;eA0TYtE,I","sourcesContent":["// @flow\nimport { BASE, CONTENT_PATH, HTTP_METHODS } from \"../../constants/Constants\";\n\nimport Parameter from \"../parameter/Parameter\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { LocationShape } from \"react-router\";\n\ntype HrefObject = {\n _path: string,\n _hash: string,\n _parameters: Array<Parameter>,\n _resourcetype: string,\n _method: $Keys<typeof HTTP_METHODS>,\n _state: ?{ [key: string]: any },\n pathname: ?string,\n};\n\nexport type HrefInput = Href | HrefObject | LocationShape | string;\n\n/**\n * Defines a Href with the parameters\n */\nclass Href {\n _path: string;\n _hash: string;\n _parameters: Array<Parameter>;\n _resourcetype: string;\n _method: $Keys<typeof HTTP_METHODS>;\n _state: ?{ +[key: string]: any };\n\n /**\n * Create a Href\n */\n constructor(href?: HrefInput, resourcetype?: string) {\n this.path = \"\";\n this.parameters = [];\n this.hash = \"\";\n this.state = null;\n this.method = HTTP_METHODS.GET;\n this.resourcetype = resourcetype || \"\";\n\n if (href instanceof Href) {\n this.setFromHref(href);\n } else if (typeof href === \"string\") {\n this.setFromString(href);\n } else if (typeof href === \"object\") {\n this.setFromLocationOrObject(href);\n }\n }\n\n /**\n * Set parameters from Href model input\n */\n setFromHref(href: Href) {\n this.path = href.path;\n this.parameters = href.parameters;\n this.hash = href.hash;\n this.state = href.state;\n }\n\n /**\n */\n setFromLocationOrObject(href: LocationShape | HrefObject) {\n if (typeof href[\"pathname\"] === \"string\") {\n this.path = href.pathname;\n } else if (typeof href._path === \"string\") {\n this.path = href._path;\n }\n\n if (href.search) {\n this.addParametersFromString(href.search);\n } else if (Array.isArray(href._parameters)) {\n // $FlowExpectedError[incompatible-call]\n href._parameters.map((param: Parameter) =>\n this.addParameter(param._name, param._value, param._prefix)\n );\n }\n\n if (href.hash) {\n this.hash = Href.getHashFromString(href.hash);\n } else if (typeof href._hash === \"string\") {\n this.hash = href._hash;\n }\n\n if (href.state) {\n this.state = href.state || null;\n } else if (typeof href._state === \"object\") {\n this.state = href._state;\n }\n }\n\n /**\n * Set parameters from string input\n */\n setFromString(href: string) {\n this.path = Href.getPathFromString(href);\n this.addParametersFromString(href);\n this.hash = Href.getHashFromString(href);\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this._path.includes(\"/change-password\");\n }\n\n /**\n * check if the path is referencing a camel route\n */\n static isCamelRoute(path: string): boolean {\n return (\n path.startsWith(\"/restServices\") && !path.startsWith(\"/restServices/ui\")\n );\n }\n\n /**\n */\n static checkAbsoluteUrl(href: string): boolean {\n const checkAbsolute = new RegExp(\"^(?:[a-z]+:)?//\", \"i\");\n return checkAbsolute.test(href);\n }\n\n // Check if url is relative (not checking for absolute urls with same domain)\n /**\n */\n get isExternal(): boolean {\n return Href.checkAbsoluteUrl(this.path);\n }\n\n /**\n * Retrieve the relative path part of a href string, e.g. https://www.beinformed.com/BeInformed/tab/view?q=url => /tab/view\n */\n static getPathFromString(href: string): string {\n const decodedHref = decodeURI(href);\n\n const hrefNoHash = decodedHref.includes(\"#\")\n ? decodedHref.substr(0, decodedHref.indexOf(\"#\"))\n : decodedHref;\n\n return hrefNoHash.includes(\"?\") ? hrefNoHash.split(\"?\")[0] : hrefNoHash;\n }\n\n /**\n * Retrieve hash of href string\n */\n static getHashFromString(href: string = \"\"): string {\n return href.includes(\"#\") ? href.substr(href.indexOf(\"#\") + 1) : \"\";\n }\n\n /**\n * Add a parameter for each parameter found in the querystring of an URL string, e.g. https://www.beinformed.com?q=url => q=url\n */\n addParametersFromString(href: string): Href {\n if (href.includes(\"?\")) {\n href\n .split(\"?\")[1]\n .split(\"&\")\n .forEach((param) => {\n const paramFromString = Parameter.fromString(param);\n if (paramFromString) {\n this.setParameter(\n paramFromString.name,\n paramFromString.value,\n paramFromString.prefix\n );\n }\n });\n }\n\n return this;\n }\n\n /**\n * Add a querystring parameter to the parameter collection of this Href, skips parameters that have a value of null\n */\n addParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value !== null) {\n this.removeParameter(name, prefix);\n this._parameters.push(new Parameter(prefix, name, value));\n }\n\n return this;\n }\n\n /**\n * Adds or overwrites a parameter when it exists and value is not null.\n * Removes the parameter when the value is null\n */\n setParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value === null) {\n this.removeParameter(name, prefix);\n } else {\n this.addParameter(name, value, prefix);\n }\n\n return this;\n }\n\n /**\n * Retrieve a parameter by it's name and (optionally) prefix\n */\n getParameter(name: string, prefix: ?string): ?Parameter {\n return this._parameters.find(\n (param) => param.prefix === prefix && param.name === name\n );\n }\n\n /**\n */\n hasParameter(name: string, prefix: ?string): boolean {\n return this.getParameter(name, prefix) !== undefined;\n }\n\n /**\n * Get request method\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n * Set request method\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method || HTTP_METHODS.GET;\n }\n\n /**\n * Retrieve all paremters\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n * Replace parameters of Href\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n * Remove a parameter from the parameter collection\n */\n removeParameter(name: string, prefix: ?string): Href {\n this._parameters = this._parameters.filter(\n (param) => param.prefix !== prefix || param.name !== name\n );\n\n return this;\n }\n\n /**\n * Get the parameters as a querystring, e.g. param1=value1&param2=value2, optionally with prefix\n */\n getQuerystring(withPrefix: boolean = false): string {\n return this.parameters\n .filter((param) => param.value != null)\n .map((param) => param.toQuerystring(withPrefix))\n .join(\"&\");\n }\n\n /**\n * Retrieve a querystring that only contains parameter that can be send to the modular ui, parameters are filtered by prefix\n */\n getQuerystringForModularUI(prefix: string = \"\"): string {\n return this.parameters\n .filter(\n (param) =>\n param.isModUIParameter &&\n (!prefix || !param.prefix || param.prefix === prefix) &&\n param.value != null\n )\n .map((param) => param.toQuerystring(false))\n .join(\"&\");\n }\n\n /**\n * Retrieve all parameters from the parameter collection in a querystring style name1=value1&name2=value2, without the prefix\n */\n get querystring(): string {\n return this.getQuerystring(false);\n }\n\n /**\n * Set the path of the Href, the part before the querystring question mark\n */\n set path(path: string) {\n this._path = path;\n }\n\n /**\n * Retrieve the path\n */\n get path(): string {\n return this._path || \"\";\n }\n\n /**\n * Set hash\n */\n set hash(hash: string) {\n this._hash = hash;\n }\n\n /**\n * Retrieve hash\n */\n get hash(): string {\n return this._hash;\n }\n\n /**\n */\n set state(state: ?{ +[key: string]: any }) {\n this._state = state;\n }\n\n /**\n */\n get state(): ?{ +[key: string]: any } {\n return this._state;\n }\n\n /**\n */\n setState(state: { [key: string]: any }): Href {\n this.state = state;\n\n return this;\n }\n\n /**\n * Set resourctype\n */\n set resourcetype(resourcetype: string) {\n this._resourcetype = resourcetype;\n }\n\n /**\n * Retrieve resourceType\n */\n get resourcetype(): string {\n return this._resourcetype;\n }\n\n /**\n * Retrieve the path combined with the BASE of the application, e.g. /BeInformed\n */\n get absolutepath(): string {\n if (this.isExternal) {\n return this.path;\n }\n\n return BASE + this.path;\n }\n\n /**\n * Retrieves the combination of the path and the querystring\n */\n get href(): string {\n return this.querystring.length > 0\n ? [this.path, this.querystring].join(\"?\")\n : this.path;\n }\n\n /**\n * Getting the URL including the base path, querystring is prefixed\n */\n get absolutehref(): string {\n const querystring = this.getQuerystring(false);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Getting the URL including the base path, the querystring is prefixed\n */\n get absolutehrefPrefixedQuerystring(): string {\n const querystring = this.getQuerystring(true);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Checks if the URL starts within the given href\n */\n startsWith(href: Href | string): boolean {\n const thisPath = `${this.path}/`;\n const otherPath = href instanceof Href ? `${href.path}/` : href;\n\n return thisPath.startsWith(otherPath);\n }\n\n /**\n * Checks if the given Href equals this Href\n */\n equals(href: Href | string): boolean {\n if (href instanceof Href) {\n return this.path === href.path;\n }\n\n return this.path === href;\n }\n\n /**\n */\n equalsWithParameters(href: Href): boolean {\n if (!this.equals(href)) {\n return false;\n }\n\n if (href instanceof Href) {\n if (this.parameters.length !== href.parameters.length) {\n return false;\n }\n\n if (this.parameters.length === 0 && href.parameters.length === 0) {\n return true;\n }\n\n const thisParams = this.parameters.map((param) => param.toString());\n\n return href.parameters.every((param) =>\n thisParams.includes(param.toString())\n );\n }\n\n throw new IllegalArgumentException(`${href} is not an instance of Href`);\n }\n\n /**\n * Indicates if the link is a content link\n */\n get isContent(): boolean {\n return this.absolutepath.startsWith(CONTENT_PATH);\n }\n\n /**\n * Returns a complete url from the Href\n */\n toString(): string {\n return this.href;\n }\n\n /**\n */\n toLocation(): LocationShape {\n return {\n pathname: this.path,\n search: this.querystring.length > 0 ? `?${this.querystring}` : \"\",\n hash: this.hash.length > 0 ? `#${this.hash}` : \"\",\n state: this.state,\n };\n }\n}\n\nexport default Href;\n"],"file":"Href.js"}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.loginSuccess = exports.loginFailed = exports.login = exports.changePassword = void 0;
8
+ exports.resetAuthErrors = exports.loginSuccess = exports.loginFailed = exports.login = exports.changePassword = void 0;
9
9
 
10
10
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
11
11
 
@@ -31,12 +31,24 @@ var loginFailed = function loginFailed(errorMessage) {
31
31
  };
32
32
  };
33
33
  /**
34
- * Send login success action
34
+ * Resets any authentication errors
35
35
  */
36
36
 
37
37
 
38
38
  exports.loginFailed = loginFailed;
39
39
 
40
+ var resetAuthErrors = function resetAuthErrors() {
41
+ return {
42
+ type: "AUTHENTICATION_RESET_ERRORS"
43
+ };
44
+ };
45
+ /**
46
+ * Send login success action
47
+ */
48
+
49
+
50
+ exports.resetAuthErrors = resetAuthErrors;
51
+
40
52
  var loginSuccess = function loginSuccess() {
41
53
  return {
42
54
  type: "AUTHENTICATION_SUCCESS"
@@ -10,6 +10,7 @@ import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
10
10
 
11
11
  import type {
12
12
  LoginFailedAction,
13
+ ResetAuthErrorsAction,
13
14
  LoginSuccessAction,
14
15
  ThunkAction,
15
16
  } from "../types";
@@ -22,6 +23,13 @@ export const loginFailed = (errorMessage: string): LoginFailedAction => ({
22
23
  payload: errorMessage,
23
24
  });
24
25
 
26
+ /**
27
+ * Resets any authentication errors
28
+ */
29
+ export const resetAuthErrors = (): ResetAuthErrorsAction => ({
30
+ type: "AUTHENTICATION_RESET_ERRORS",
31
+ });
32
+
25
33
  /**
26
34
  * Send login success action
27
35
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/SignIn.js"],"names":["loginFailed","errorMessage","type","payload","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","CHANGEPASSWORD_PATH","login","username","password","Authenticate","then","Cache","addItem","catch","error","id","dispatchedReloadApplication","resolve"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAQA;AACA;AAC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MAAd,EAAsB,IAAtB;;AACAhB,MAAAA,QAAQ,CAACF,YAAY,EAAb,CAAR;AAEA,aAAOE,QAAQ,CAAC,wCAAD,CAAf;AACD,KARI,EASJiB,KATI,CASE,UAACC,KAAD,EAAW;AAChB,UAAIA,KAAK,CAACC,EAAN,KAAa,8BAAjB,EAAiD;AAC/C,YAAMC,2BAA2B,GAAGpB,QAAQ,CAAC,qCAAD,CAA5C;AAEA,eAAO,iBAAQqB,OAAR,CAAgBD,2BAAhB,EAA6CN,IAA7C,CAAkD,YAAM;AAC7DC,yBAAMC,OAAN,CAAc,MAAd,EAAsB,IAAtB;;AACA,iBAAOhB,QAAQ,CAACD,cAAc,EAAf,CAAf;AACD,SAHM,CAAP;AAID;;AAEDC,MAAAA,QAAQ,CAACN,WAAW,CAACwB,KAAK,CAACC,EAAP,CAAZ,CAAR;AACA,aAAOnB,QAAQ,CAAC,wCAAD,CAAf;AACD,KArBI,CAAP;AAsBD,GA1BD;AAAA,CADK","sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/actions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n LoginFailedAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (errorMessage: string): LoginFailedAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n })\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(loginSuccess());\n\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n return dispatch(changePassword());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"file":"SignIn.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/SignIn.js"],"names":["loginFailed","errorMessage","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","CHANGEPASSWORD_PATH","login","username","password","Authenticate","then","Cache","addItem","catch","error","id","dispatchedReloadApplication","resolve"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AASA;AACA;AACA;AACO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,YAAD;AAAA,SAA8C;AACvEC,IAAAA,IAAI,EAAE,sBADiE;AAEvEC,IAAAA,OAAO,EAAEF;AAF8D,GAA9C;AAAA,CAApB;AAKP;AACA;AACA;;;;;AACO,IAAMG,eAAe,GAAG,SAAlBA,eAAkB;AAAA,SAA8B;AAC3DF,IAAAA,IAAI,EAAE;AADqD,GAA9B;AAAA,CAAxB;AAIP;AACA;AACA;;;;;AACO,IAAMG,YAAY,GAAG,SAAfA,YAAe;AAAA,SAA2B;AACrDH,IAAAA,IAAI,EAAE;AAD+C,GAA3B;AAAA,CAArB;AAIP;AACA;AACA;;;;;AACO,IAAMI,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAAmB,UAACC,QAAD,E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MAAd,EAAsB,IAAtB;;AACA,iBAAOhB,QAAQ,CAACD,cAAc,EAAf,CAAf;AACD,SAHM,CAAP;AAID;;AAEDC,MAAAA,QAAQ,CAACP,WAAW,CAACyB,KAAK,CAACC,EAAP,CAAZ,CAAR;AACA,aAAOnB,QAAQ,CAAC,wCAAD,CAAf;AACD,KArBI,CAAP;AAsBD,GA1BD;AAAA,CADK","sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/actions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n LoginFailedAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (errorMessage: string): LoginFailedAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n })\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(loginSuccess());\n\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n return dispatch(changePassword());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"file":"SignIn.js"}
@@ -57,6 +57,11 @@ var AuthReducer = function AuthReducer() {
57
57
  error: action.payload
58
58
  });
59
59
 
60
+ case "AUTHENTICATION_RESET_ERRORS":
61
+ return _objectSpread(_objectSpread({}, state), {}, {
62
+ error: null
63
+ });
64
+
60
65
  case "AUTHENTICATION_LOGOUT":
61
66
  {
62
67
  // clear cache because of cached contributions
@@ -34,6 +34,9 @@ const AuthReducer: Reducer<AuthState, ReduxAction> = (
34
34
  case "AUTHENTICATION_ERROR":
35
35
  return { ...state, mustChangePassword: false, error: action.payload };
36
36
 
37
+ case "AUTHENTICATION_RESET_ERRORS":
38
+ return { ...state, error: null };
39
+
37
40
  case "AUTHENTICATION_LOGOUT": {
38
41
  // clear cache because of cached contributions
39
42
  if (state.isAuthenticated) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/reducers/AuthReducer.js"],"names":["initialState","isAuthenticated","mustChangePassword","error","AuthReducer","state","action","type","payload","Cache","clear"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;;;;;AAKA;AACA,IAAMA,YAAuB,GAAG;AAC9BC,EAAAA,eAAe,EAAE,KADa;AAE9BC,EAAAA,kBAAkB,EAAE,KAFU;AAG9BC,EAAAA,KAAK,EAAE;AAHuB,CAAhC;AAMA;AACA;AACA;;AACA,IAAMC,WAA4C,GAAG,SAA/CA,WAA+C,GAGhD;AAAA,MAFHC,KAEG,uEAFKL,YAEL;AAAA,MADHM,MACG;;AACH,MAAI,CAACA,MAAL,EAAa;AACX,WAAOD,KAAP;AACD;;AAED,UAAQC,MAAM,CAACC,IAAf;AACE,SAAK,wBAAL;AACE,6CACKF,KADL;AAEEJ,QAAAA,eAAe,EAAE,IAFnB;AAGEE,QAAAA,KAAK,EAAE,IAHT;AAIED,QAAAA,kBAAkB,EAAE;AAJtB;;AAOF,SAAK,sBAAL;AACE,6CAAYG,KAAZ;AAAmBH,QAAAA,kBAAkB,EAAE,KAAvC;AAA8CC,QAAAA,KAAK,EAAEG,MAAM,CAACE;AAA5D;;AAEF,SAAK,uBAAL;AAA8B;AAC5B;AACA,YAAIH,KAAK,CAACJ,eAAV,EAA2B;AACzBQ,yBAAMC,KAAN;AACD;;AAED,+CACKL,KADL;AAEEH,UAAAA,kBAAkB,EAAE,KAFtB;AAGED,UAAAA,eAAe,EAAE,KAHnB;AAIEE,UAAAA,KAAK,EAAE;AAJT;AAMD;;AAED,SAAK,iBAAL;AACE,6CACKE,KADL;AAEEJ,QAAAA,eAAe,EAAE,IAFnB;AAGEC,QAAAA,kBAAkB,EAAE,IAHtB;AAIEC,QAAAA,KAAK,EAAE;AAJT;;AAOF;AACE,aAAOE,KAAP;AAnCJ;AAqCD,CA7CD;;eA+CeD,W","sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { Reducer } from \"redux\";\nimport type { AuthState, ReduxAction } from \"../types\";\n\n// REDUCER\nconst initialState: AuthState = {\n isAuthenticated: false,\n mustChangePassword: false,\n error: null,\n};\n\n/**\n * Auth reducer\n */\nconst AuthReducer: Reducer<AuthState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"AUTHENTICATION_SUCCESS\":\n return {\n ...state,\n isAuthenticated: true,\n error: null,\n mustChangePassword: false,\n };\n\n case \"AUTHENTICATION_ERROR\":\n return { ...state, mustChangePassword: false, error: action.payload };\n\n case \"AUTHENTICATION_LOGOUT\": {\n // clear cache because of cached contributions\n if (state.isAuthenticated) {\n Cache.clear();\n }\n\n return {\n ...state,\n mustChangePassword: false,\n isAuthenticated: false,\n error: null,\n };\n }\n\n case \"CHANGE_PASSWORD\":\n return {\n ...state,\n isAuthenticated: true,\n mustChangePassword: true,\n error: null,\n };\n\n default:\n return state;\n }\n};\n\nexport default AuthReducer;\n"],"file":"AuthReducer.js"}
1
+ {"version":3,"sources":["../../../src/redux/reducers/AuthReducer.js"],"names":["initialState","isAuthenticated","mustChangePassword","error","AuthReducer","state","action","type","payload","Cache","clear"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;;;;;AAKA;AACA,IAAMA,YAAuB,GAAG;AAC9BC,EAAAA,eAAe,EAAE,KADa;AAE9BC,EAAAA,kBAAkB,EAAE,KAFU;AAG9BC,EAAAA,KAAK,EAAE;AAHuB,CAAhC;AAMA;AACA;AACA;;AACA,IAAMC,WAA4C,GAAG,SAA/CA,WAA+C,GAGhD;AAAA,MAFHC,KAEG,uEAFKL,YAEL;AAAA,MADHM,MACG;;AACH,MAAI,CAACA,MAAL,EAAa;AACX,WAAOD,KAAP;AACD;;AAED,UAAQC,MAAM,CAACC,IAAf;AACE,SAAK,wBAAL;AACE,6CACKF,KADL;AAEEJ,QAAAA,eAAe,EAAE,IAFnB;AAGEE,QAAAA,KAAK,EAAE,IAHT;AAIED,QAAAA,kBAAkB,EAAE;AAJtB;;AAOF,SAAK,sBAAL;AACE,6CAAYG,KAAZ;AAAmBH,QAAAA,kBAAkB,EAAE,KAAvC;AAA8CC,QAAAA,KAAK,EAAEG,MAAM,CAACE;AAA5D;;AAEF,SAAK,6BAAL;AACE,6CAAYH,KAAZ;AAAmBF,QAAAA,KAAK,EAAE;AAA1B;;AAEF,SAAK,uBAAL;AAA8B;AAC5B;AACA,YAAIE,KAAK,CAACJ,eAAV,EAA2B;AACzBQ,yBAAMC,KAAN;AACD;;AAED,+CACKL,KADL;AAEEH,UAAAA,kBAAkB,EAAE,KAFtB;AAGED,UAAAA,eAAe,EAAE,KAHnB;AAIEE,UAAAA,KAAK,EAAE;AAJT;AAMD;;AAED,SAAK,iBAAL;AACE,6CACKE,KADL;AAEEJ,QAAAA,eAAe,EAAE,IAFnB;AAGEC,QAAAA,kBAAkB,EAAE,IAHtB;AAIEC,QAAAA,KAAK,EAAE;AAJT;;AAOF;AACE,aAAOE,KAAP;AAtCJ;AAwCD,CAhDD;;eAkDeD,W","sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { Reducer } from \"redux\";\nimport type { AuthState, ReduxAction } from \"../types\";\n\n// REDUCER\nconst initialState: AuthState = {\n isAuthenticated: false,\n mustChangePassword: false,\n error: null,\n};\n\n/**\n * Auth reducer\n */\nconst AuthReducer: Reducer<AuthState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"AUTHENTICATION_SUCCESS\":\n return {\n ...state,\n isAuthenticated: true,\n error: null,\n mustChangePassword: false,\n };\n\n case \"AUTHENTICATION_ERROR\":\n return { ...state, mustChangePassword: false, error: action.payload };\n\n case \"AUTHENTICATION_RESET_ERRORS\":\n return { ...state, error: null };\n\n case \"AUTHENTICATION_LOGOUT\": {\n // clear cache because of cached contributions\n if (state.isAuthenticated) {\n Cache.clear();\n }\n\n return {\n ...state,\n mustChangePassword: false,\n isAuthenticated: false,\n error: null,\n };\n }\n\n case \"CHANGE_PASSWORD\":\n return {\n ...state,\n isAuthenticated: true,\n mustChangePassword: true,\n error: null,\n };\n\n default:\n return state;\n }\n};\n\nexport default AuthReducer;\n"],"file":"AuthReducer.js"}
@@ -17,9 +17,12 @@ describe("authentication reducer", () => {
17
17
 
18
18
  it("should handle AUTHENTICATION_SUCCESS", () => {
19
19
  expect(
20
- AuthReducer([], {
21
- type: "AUTHENTICATION_SUCCESS",
22
- })
20
+ AuthReducer(
21
+ {},
22
+ {
23
+ type: "AUTHENTICATION_SUCCESS",
24
+ }
25
+ )
23
26
  ).toStrictEqual({
24
27
  isAuthenticated: true,
25
28
  mustChangePassword: false,
@@ -29,10 +32,13 @@ describe("authentication reducer", () => {
29
32
 
30
33
  it("should handle AUTHENTICATION_ERROR", () => {
31
34
  expect(
32
- AuthReducer([], {
33
- type: "AUTHENTICATION_ERROR",
34
- payload: "error",
35
- })
35
+ AuthReducer(
36
+ {},
37
+ {
38
+ type: "AUTHENTICATION_ERROR",
39
+ payload: "error",
40
+ }
41
+ )
36
42
  ).toStrictEqual({
37
43
  mustChangePassword: false,
38
44
  error: "error",
@@ -41,9 +47,35 @@ describe("authentication reducer", () => {
41
47
 
42
48
  it("should handle AUTHENTICATION_LOGOUT", () => {
43
49
  expect(
44
- AuthReducer([], {
45
- type: "AUTHENTICATION_LOGOUT",
46
- })
50
+ AuthReducer(
51
+ {
52
+ isAuthenticated: true,
53
+ mustChangePassword: false,
54
+ error: null,
55
+ },
56
+ {
57
+ type: "AUTHENTICATION_LOGOUT",
58
+ }
59
+ )
60
+ ).toStrictEqual({
61
+ isAuthenticated: false,
62
+ mustChangePassword: false,
63
+ error: null,
64
+ });
65
+ });
66
+
67
+ it("should handle AUTHENTICATION_RESET_ERRORS", () => {
68
+ expect(
69
+ AuthReducer(
70
+ {
71
+ isAuthenticated: false,
72
+ mustChangePassword: false,
73
+ error: "In error",
74
+ },
75
+ {
76
+ type: "AUTHENTICATION_RESET_ERRORS",
77
+ }
78
+ )
47
79
  ).toStrictEqual({
48
80
  isAuthenticated: false,
49
81
  mustChangePassword: false,
@@ -53,9 +85,16 @@ describe("authentication reducer", () => {
53
85
 
54
86
  it("should handle CHANGE_PASSWORD", () => {
55
87
  expect(
56
- AuthReducer([], {
57
- type: "CHANGE_PASSWORD",
58
- })
88
+ AuthReducer(
89
+ {
90
+ isAuthenticated: true,
91
+ mustChangePassword: false,
92
+ error: null,
93
+ },
94
+ {
95
+ type: "CHANGE_PASSWORD",
96
+ }
97
+ )
59
98
  ).toStrictEqual({
60
99
  isAuthenticated: true,
61
100
  mustChangePassword: true,
@@ -104,6 +104,10 @@ export type LoginFailedAction = {
104
104
  payload: string,
105
105
  };
106
106
 
107
+ export type ResetAuthErrorsAction = {
108
+ type: "AUTHENTICATION_RESET_ERRORS",
109
+ };
110
+
107
111
  export type LoginSuccessAction = {
108
112
  type: "AUTHENTICATION_SUCCESS",
109
113
  };
@@ -143,6 +147,7 @@ export type ReduxAction =
143
147
  | ResetProgressAction
144
148
  | UpdateProgressAction
145
149
  | LoginFailedAction
150
+ | ResetAuthErrorsAction
146
151
  | LoginSuccessAction
147
152
  | ChangePasswordAction
148
153
  | LogoutSuccessAction
@@ -0,0 +1,60 @@
1
+ import {
2
+ resourceExists,
3
+ resourceRedirectsToSecureLogin,
4
+ } from "../checkResource";
5
+
6
+ import Href from "../../../models/href/Href";
7
+
8
+ const mockXMLHttpRequest = () => {
9
+ const mock = {
10
+ open: jest.fn(),
11
+ addEventListener: jest.fn(),
12
+ setRequestHeader: jest.fn(),
13
+ send: jest.fn(),
14
+ getResponseHeader: jest.fn(),
15
+
16
+ upload: {
17
+ addEventListener: jest.fn(),
18
+ },
19
+ };
20
+
21
+ jest.spyOn(global, "XMLHttpRequest").mockImplementation(() => mock);
22
+
23
+ return mock;
24
+ };
25
+
26
+ describe("checkResource", () => {
27
+ it("indicates a resource exists if it has a status code other then 404", () => {
28
+ const mock = mockXMLHttpRequest();
29
+ mock.status = 200;
30
+
31
+ const exists = resourceExists("/");
32
+ expect(exists).toBe(true);
33
+
34
+ const hrefExists = resourceExists(new Href("/caseview"));
35
+ expect(hrefExists).toBe(true);
36
+ });
37
+
38
+ it("indicates a resource does not exists if it has a status code of 404", () => {
39
+ const mock = mockXMLHttpRequest();
40
+ mock.status = 404;
41
+
42
+ const exists = resourceExists("/");
43
+ expect(exists).toBe(false);
44
+
45
+ const hrefExists = resourceExists(new Href("/caseview"));
46
+ expect(hrefExists).toBe(false);
47
+ });
48
+
49
+ it("indicates resource request redirects to secureLogin", () => {
50
+ const mock = mockXMLHttpRequest();
51
+ mock.responseURL = "/BeInformed/secureLogin";
52
+ mock.status = 400;
53
+
54
+ const toLogin = resourceRedirectsToSecureLogin("/");
55
+ expect(toLogin).toBe(true);
56
+
57
+ const hrefToLogin = resourceExists(new Href("/caseview"));
58
+ expect(hrefToLogin).toBe(true);
59
+ });
60
+ });