@spokane-folio/security-incident 1.0.28

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 (188) hide show
  1. package/.eslintrc +32 -0
  2. package/.github/workflows/CODEOWNERS +8 -0
  3. package/.github/workflows/pr-validation.yml +44 -0
  4. package/.github/workflows/release.yml +64 -0
  5. package/.prettierrc +6 -0
  6. package/.stripesclirc +4 -0
  7. package/CHANGELOG.md +8 -0
  8. package/CONTRIBUTING.md +4 -0
  9. package/LICENSE +201 -0
  10. package/README.md +16 -0
  11. package/administrator-documentation/roles-and-permissions.md +65 -0
  12. package/administrator-documentation/track-settings-admin-guide-sketch.md +192 -0
  13. package/administrator-documentation/using-the-application.md +192 -0
  14. package/icons/app.png +0 -0
  15. package/icons/app.svg +1 -0
  16. package/icons/playButton.png +0 -0
  17. package/icons/profilePicThumbnail.png +0 -0
  18. package/jest.config.js +10 -0
  19. package/module-descriptor.json +75 -0
  20. package/output/service-worker.js +0 -0
  21. package/package.json +146 -0
  22. package/src/components/incidents/ColumnChooser.js +37 -0
  23. package/src/components/incidents/CreateMedia.js +132 -0
  24. package/src/components/incidents/CreatePane.js +1215 -0
  25. package/src/components/incidents/CreatePane.test.js +138 -0
  26. package/src/components/incidents/CreateReport.js +102 -0
  27. package/src/components/incidents/DetailsPane.js +1267 -0
  28. package/src/components/incidents/DetailsPane.test.js +150 -0
  29. package/src/components/incidents/EditPane.js +2334 -0
  30. package/src/components/incidents/EditPane.test.js +187 -0
  31. package/src/components/incidents/GetDetails.js +55 -0
  32. package/src/components/incidents/GetListDQLinkIncident.js +81 -0
  33. package/src/components/incidents/GetListDynamicQuery.js +66 -0
  34. package/src/components/incidents/GetLocations.js +57 -0
  35. package/src/components/incidents/GetMedia.js +98 -0
  36. package/src/components/incidents/GetName.js +111 -0
  37. package/src/components/incidents/GetNameCreatedBy.js +94 -0
  38. package/src/components/incidents/GetOrgLocaleSettings.js +61 -0
  39. package/src/components/incidents/GetPatronGroups.js +52 -0
  40. package/src/components/incidents/GetSelf.js +65 -0
  41. package/src/components/incidents/GetSummary.js +110 -0
  42. package/src/components/incidents/IncidentTypeCard.js +53 -0
  43. package/src/components/incidents/IncidentTypeCard.test.js +133 -0
  44. package/src/components/incidents/IncidentsPaneset.js +810 -0
  45. package/src/components/incidents/IncidentsPaneset.test.js +128 -0
  46. package/src/components/incidents/LinkedIncident.js +86 -0
  47. package/src/components/incidents/ModalAddMedia.js +262 -0
  48. package/src/components/incidents/ModalAddMedia.test.js +97 -0
  49. package/src/components/incidents/ModalAttentionDecOfService.js +111 -0
  50. package/src/components/incidents/ModalCustomWitness.js +469 -0
  51. package/src/components/incidents/ModalCustomWitness.test.js +147 -0
  52. package/src/components/incidents/ModalCustomerDetails.js +480 -0
  53. package/src/components/incidents/ModalCustomerDetails.test.js +116 -0
  54. package/src/components/incidents/ModalDescribeCustomer.js +361 -0
  55. package/src/components/incidents/ModalDescribeCustomer.test.js +156 -0
  56. package/src/components/incidents/ModalDirtyFormWarn.js +62 -0
  57. package/src/components/incidents/ModalLinkIncident.js +1213 -0
  58. package/src/components/incidents/ModalLinkIncidentStyle.css +32 -0
  59. package/src/components/incidents/ModalSelectIncidentTypes.js +178 -0
  60. package/src/components/incidents/ModalSelectIncidentTypes.test.js +273 -0
  61. package/src/components/incidents/ModalSelectKnownCustomer.js +395 -0
  62. package/src/components/incidents/ModalSelectWitness.js +406 -0
  63. package/src/components/incidents/ModalSelectWitness.test.js +308 -0
  64. package/src/components/incidents/ModalStyle.css +44 -0
  65. package/src/components/incidents/ModalTrespass.js +741 -0
  66. package/src/components/incidents/ModalViewCustomerDetails.js +241 -0
  67. package/src/components/incidents/ModalViewMedia.js +86 -0
  68. package/src/components/incidents/ModalViewTrespass.js +210 -0
  69. package/src/components/incidents/ResultsPane.js +437 -0
  70. package/src/components/incidents/ResultsPane.test.js +120 -0
  71. package/src/components/incidents/SearchCustomerOrWitness.js +108 -0
  72. package/src/components/incidents/Thumbnail.js +72 -0
  73. package/src/components/incidents/ThumbnailMarkRemoval.js +38 -0
  74. package/src/components/incidents/ThumbnailSkeleton.js +30 -0
  75. package/src/components/incidents/ThumbnailStyles.js +49 -0
  76. package/src/components/incidents/ThumbnailTempPreSave.js +71 -0
  77. package/src/components/incidents/UpdateReport.js +84 -0
  78. package/src/components/incidents/__snapshots__/CreatePane.test.js.snap +3 -0
  79. package/src/components/incidents/__snapshots__/DetailsPane.test.js.snap +3 -0
  80. package/src/components/incidents/__snapshots__/EditPane.test.js.snap +3 -0
  81. package/src/components/incidents/__snapshots__/IncidentTypeCard.test.js.snap +3 -0
  82. package/src/components/incidents/__snapshots__/IncidentsPaneset.test.js.snap +3 -0
  83. package/src/components/incidents/__snapshots__/ModalAddMedia.test.js.snap +3 -0
  84. package/src/components/incidents/__snapshots__/ModalCustomerDetails.test.js.snap +3 -0
  85. package/src/components/incidents/__snapshots__/ModalSelectWitness.test.js.snap +3 -0
  86. package/src/components/incidents/__snapshots__/ResultsPane.test.js.snap +3 -0
  87. package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.css +5 -0
  88. package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.js +51 -0
  89. package/src/components/incidents/helpers/ProfilePicture/isAValidURL.js +3 -0
  90. package/src/components/incidents/helpers/ProfilePicture/useProfilePicture.js +127 -0
  91. package/src/components/incidents/helpers/buildQueryString.js +28 -0
  92. package/src/components/incidents/helpers/cleanFormValues.js +53 -0
  93. package/src/components/incidents/helpers/computeEditedCustomers.js +124 -0
  94. package/src/components/incidents/helpers/convertDateIgnoringTZ.js +8 -0
  95. package/src/components/incidents/helpers/convertUTCISOToLocalePrettyTime.js +15 -0
  96. package/src/components/incidents/helpers/convertUTCISOToPrettyDate.js +19 -0
  97. package/src/components/incidents/helpers/decodeParamsToForm.js +20 -0
  98. package/src/components/incidents/helpers/deepNormalizeForComparison.js +39 -0
  99. package/src/components/incidents/helpers/extractFilterString.js +12 -0
  100. package/src/components/incidents/helpers/formatDateAndTimeToUTCISO.js +14 -0
  101. package/src/components/incidents/helpers/formatDateToUTCISO.js +14 -0
  102. package/src/components/incidents/helpers/formatTimeToUTCISO.js +28 -0
  103. package/src/components/incidents/helpers/getCurrentTime.js +20 -0
  104. package/src/components/incidents/helpers/getTodayDate.js +12 -0
  105. package/src/components/incidents/helpers/handlebarsHelpers.js +148 -0
  106. package/src/components/incidents/helpers/hasFormChangedAtCreate.js +50 -0
  107. package/src/components/incidents/helpers/hasTopLevelChangeAffectedDeclaration.js +90 -0
  108. package/src/components/incidents/helpers/hasTopLevelFormChanged.js +111 -0
  109. package/src/components/incidents/helpers/identifyCurrentTrespassDocs.js +109 -0
  110. package/src/components/incidents/helpers/isSameHtml.js +13 -0
  111. package/src/components/incidents/helpers/isValidDateFormat.js +14 -0
  112. package/src/components/incidents/helpers/isValidTimeInput.js +11 -0
  113. package/src/components/incidents/helpers/isValidUTCTimeFormat.js +14 -0
  114. package/src/components/incidents/helpers/parseMMDDYYYY.js +7 -0
  115. package/src/components/incidents/helpers/parseQueryString.js +16 -0
  116. package/src/components/incidents/helpers/sortTrespassDocuments.js +44 -0
  117. package/src/components/incidents/helpers/stripHTML.js +11 -0
  118. package/src/components/incidents/helpers/trespassDocUtils.js +197 -0
  119. package/src/components/incidents/helpers/validateTrespassDetails.js +37 -0
  120. package/src/components/incidents/usePersistedColModalLink.js +70 -0
  121. package/src/components/incidents/usePersistedColumns.js +70 -0
  122. package/src/components/incidents/usePersistedSort.js +23 -0
  123. package/src/components/incidents/usePersistedSortModalLink.js +23 -0
  124. package/src/contexts/IncidentContext.js +433 -0
  125. package/src/index.js +61 -0
  126. package/src/routes/Application.js +13 -0
  127. package/src/settings/GetIncidentCategories.js +56 -0
  128. package/src/settings/GetIncidentTypesDetails.js +88 -0
  129. package/src/settings/GetIncidentTypesIds.js +74 -0
  130. package/src/settings/GetLocationsInService.js +54 -0
  131. package/src/settings/GetSingleCustomLocationDetails.js +60 -0
  132. package/src/settings/GetSingleIncidentTypeDetails.js +60 -0
  133. package/src/settings/GetTrespassReasons.js +67 -0
  134. package/src/settings/GetTrespassTemplates.js +51 -0
  135. package/src/settings/IncidentCategoriesPane.js +285 -0
  136. package/src/settings/IncidentCategoriesPane.test.js +229 -0
  137. package/src/settings/IncidentTypeDetailsPane.js +215 -0
  138. package/src/settings/IncidentTypeDetailsPane.test.js +220 -0
  139. package/src/settings/IncidentTypeEditPane.js +211 -0
  140. package/src/settings/IncidentTypeEditPane.test.js +170 -0
  141. package/src/settings/IncidentTypesPaneset.js +167 -0
  142. package/src/settings/IncidentTypesPaneset.test.js +124 -0
  143. package/src/settings/LocationInServiceEditPane.js +320 -0
  144. package/src/settings/LocationsPaneset.js +415 -0
  145. package/src/settings/LocationsPaneset.test.js +106 -0
  146. package/src/settings/ModalDeleteCategory.js +47 -0
  147. package/src/settings/ModalDeleteIncidentType.js +49 -0
  148. package/src/settings/ModalDeleteLocationInService.js +49 -0
  149. package/src/settings/ModalDeleteTrespassReason.js +49 -0
  150. package/src/settings/ModalPreviewTrespassDoc.js +65 -0
  151. package/src/settings/ModalTrespassDocTokens.js +83 -0
  152. package/src/settings/NewIncidentTypePane.js +182 -0
  153. package/src/settings/PutIncidentType.js +60 -0
  154. package/src/settings/PutLocationsInService.js +52 -0
  155. package/src/settings/PutTrespassReasons.js +61 -0
  156. package/src/settings/PutTrespassTemplate.js +50 -0
  157. package/src/settings/TrespassDoc.css +17 -0
  158. package/src/settings/TrespassDocDetailsPane.js +215 -0
  159. package/src/settings/TrespassDocEditPane.js +538 -0
  160. package/src/settings/TrespassDocPaneset.js +581 -0
  161. package/src/settings/TrespassReasonDetailsPane.js +171 -0
  162. package/src/settings/TrespassReasonEditPane.js +221 -0
  163. package/src/settings/TrespassReasonsPaneset.js +282 -0
  164. package/src/settings/__snapshots__/IncidentCategoriesPane.test.js.snap +3 -0
  165. package/src/settings/__snapshots__/IncidentTypeDetailsPane.test.js.snap +3 -0
  166. package/src/settings/__snapshots__/IncidentTypeEditPane.test.js.snap +3 -0
  167. package/src/settings/__snapshots__/IncidentTypesPaneset.test.js.snap +3 -0
  168. package/src/settings/__snapshots__/LocationsPaneset.test.js.snap +3 -0
  169. package/src/settings/data/exampleJSON.json +92 -0
  170. package/src/settings/data/templateTokens.js +396 -0
  171. package/src/settings/helpers/alphabetize.js +18 -0
  172. package/src/settings/helpers/getCategoryTitleById.js +13 -0
  173. package/src/settings/helpers/makeId.js +15 -0
  174. package/src/settings/index.js +48 -0
  175. package/stripes.config.js +10 -0
  176. package/test/jest/__mock__/index.js +8 -0
  177. package/test/jest/__mock__/intl.mock.js +27 -0
  178. package/test/jest/__mock__/stripes.mock.js +26 -0
  179. package/test/jest/__mock__/stripesComponents.mock.js +151 -0
  180. package/test/jest/__mock__/stripesConfig.mock.js +1 -0
  181. package/test/jest/__mock__/stripesCore.mock.js +9 -0
  182. package/test/jest/__mock__/stripesIcon.mock.js +5 -0
  183. package/test/jest/__mock__/stripesSmartComponents.mock.js +7 -0
  184. package/test/jest/__mock__/stripesUtils.mock.js +3 -0
  185. package/test/jest/eslintrc.js +12 -0
  186. package/test/jest/setupFiles.js +5 -0
  187. package/translations/ui-security-incident/en_US.json +542 -0
  188. package/ui-module-acceptance-criteria.md +34 -0
@@ -0,0 +1,215 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import DOMPurify from 'dompurify';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { useParams, useHistory } from 'react-router-dom';
5
+ import {
6
+ AccordionSet,
7
+ Accordion,
8
+ Button,
9
+ Col,
10
+ Headline,
11
+ Label,
12
+ Pane,
13
+ PaneMenu,
14
+ Row,
15
+ } from '@folio/stripes/components';
16
+ import GetTrespassTemplates from './GetTrespassTemplates';
17
+ import { useIncidents } from '../contexts/IncidentContext';
18
+ import ModalPreviewTrespassDoc from './ModalPreviewTrespassDoc';
19
+ import DOMPurify from 'dompurify';
20
+ import { tokenValues } from './data/templateTokens';
21
+
22
+ const TrespassDocDetailsPane = ({handleShowEdit, ...props}, ) => {
23
+ const { id } = useParams();
24
+ const history = useHistory();
25
+ const {
26
+ trespassTemplates
27
+ } = useIncidents();
28
+
29
+ const [viewTemplateData, setViewTemplateData] = useState({
30
+ name: '',
31
+ active: Boolean,
32
+ isDefault: Boolean,
33
+ description: '',
34
+ templateValue: ''
35
+ });
36
+ const [previewContent, setPreviewContent] = useState('');
37
+ const [showPreviewModal, setShowPreviewModal] = useState(false);
38
+
39
+ const processContentForView = (template) => {
40
+ let processedContent = template;
41
+ Object.keys(tokenValues).forEach((token) => {
42
+ const value = tokenValues[token];
43
+ // replace special chars as escaped
44
+ const regex = new RegExp(token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
45
+ // replace regex with matched value
46
+ processedContent = processedContent.replace(regex, value);
47
+ })
48
+ return processedContent;
49
+ };
50
+
51
+ useEffect(() => {
52
+ if (trespassTemplates && trespassTemplates.length > 0) {
53
+ const foundTemplate = trespassTemplates.find((template) => template.id === id);
54
+ if (foundTemplate) {
55
+ const readyPreviewContent = processContentForView(foundTemplate.templateValue);
56
+ setPreviewContent(readyPreviewContent);
57
+ setViewTemplateData({
58
+ name: foundTemplate.name || '',
59
+ active: foundTemplate.active || false,
60
+ isDefault: foundTemplate.isDefault || false,
61
+ description: foundTemplate.description || '', // not required
62
+ templateValue: foundTemplate.templateValue || ''
63
+ });
64
+
65
+ } else {
66
+ console.log(`template with id ${id} not found`);
67
+ setViewTemplateData({
68
+ name: '',
69
+ active: '',
70
+ description: '',
71
+ templateValue: ''
72
+ });
73
+ setPreviewContent('');
74
+ };
75
+ };
76
+ }, [trespassTemplates, id]);
77
+
78
+ const handlePreviewClick = () => {
79
+ setShowPreviewModal(true);
80
+ };
81
+
82
+ const closePreviewModal = () => {
83
+ setShowPreviewModal(false);
84
+ };
85
+
86
+ const handleCloseDismiss = () => {
87
+ history.push(`/settings/incidents/trespass-template`);
88
+ };
89
+
90
+ const lastMenu = (
91
+ <PaneMenu>
92
+ <Button
93
+ style={{ marginTop: '10px' }}
94
+ buttonStyle="primary"
95
+ onClick={() => handleShowEdit(id)}
96
+ >
97
+ <FormattedMessage id="edit-button" />
98
+ </Button>
99
+ </PaneMenu>
100
+ );
101
+
102
+ return (
103
+ <Pane
104
+ dismissible
105
+ onClose={handleCloseDismiss}
106
+ defaultWidth="100%"
107
+ paneTitle={viewTemplateData.name}
108
+ {...props}
109
+ lastMenu={lastMenu}>
110
+
111
+ <GetTrespassTemplates />
112
+
113
+ {showPreviewModal && previewContent &&
114
+ <ModalPreviewTrespassDoc
115
+ previewContent={previewContent}
116
+ closePreviewModal={closePreviewModal}
117
+ />}
118
+
119
+ <AccordionSet>
120
+ <Accordion label='Details'>
121
+ <Row>
122
+ <Col xs={6}>
123
+ <Label>
124
+ <FormattedMessage id="settings.trespass-document-name-label"/>
125
+ </Label>
126
+ <Headline
127
+ tag='p'
128
+ size='medium'
129
+ margin='medium'
130
+ >
131
+ {viewTemplateData.name || ''}
132
+ </Headline>
133
+ </Col>
134
+ </Row>
135
+
136
+ <Row>
137
+ <Col xs={6}>
138
+ <Label>
139
+ <FormattedMessage id="settings.trespass-document-active-label"/>
140
+ </Label>
141
+ <Headline
142
+ tag='p'
143
+ size='medium'
144
+ margin='medium'
145
+ >
146
+ {viewTemplateData.active ? 'Yes' : 'No'}
147
+ </Headline>
148
+ </Col>
149
+ </Row>
150
+
151
+ <Row>
152
+ <Col xs={6}>
153
+ <Label>
154
+ <FormattedMessage id="settings.trespass-document-default-label"/>
155
+ </Label>
156
+ <Headline
157
+ tag='p'
158
+ size='medium'
159
+ margin='medium'
160
+ >
161
+ {viewTemplateData.isDefault ? (<FormattedMessage
162
+ id="settings.trespass-document-isDefault-yes"/>) : (<FormattedMessage
163
+ id="settings.trespass-document-isDefault-no"/>)}
164
+ </Headline>
165
+ </Col>
166
+ </Row>
167
+
168
+
169
+ <Row>
170
+ <Col xs={6}>
171
+ <Label>
172
+ <FormattedMessage id="settings.trespass-document-description-label"/>
173
+ </Label>
174
+ <Headline
175
+ tag='p'
176
+ size='medium'
177
+ margin='medium'
178
+ >
179
+ {viewTemplateData.description ?
180
+ viewTemplateData.description
181
+ : (<FormattedMessage
182
+ id="settings.trespass-document-default-no-description"/>)
183
+ }
184
+ </Headline>
185
+ </Col>
186
+ </Row>
187
+ </Accordion>
188
+
189
+ <Accordion label='Document'>
190
+ <Row style={{ marginTop: '20px'}}>
191
+ <Col xs={6}>
192
+ <Button
193
+ onClick={handlePreviewClick}
194
+ >
195
+ <FormattedMessage
196
+ id="settings.trespass-document-preview-button"
197
+ />
198
+ </Button>
199
+ </Col>
200
+ </Row>
201
+
202
+ <div
203
+ style={{ whiteSpace: 'pre-wrap' }}
204
+ dangerouslySetInnerHTML={{
205
+ __html: DOMPurify.sanitize(previewContent)
206
+ }}
207
+ >
208
+ </div>
209
+ </Accordion>
210
+ </AccordionSet>
211
+ </Pane>
212
+ );
213
+ };
214
+
215
+ export default TrespassDocDetailsPane;