@ndla/ui 13.2.1 → 15.0.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 (245) hide show
  1. package/es/Article/Article.js +22 -3
  2. package/es/Article/ArticleFavoritesButton.js +38 -0
  3. package/es/Article/index.js +2 -1
  4. package/es/Breadcrumb/ActionBreadcrumb.js +57 -0
  5. package/es/Breadcrumb/index.js +1 -0
  6. package/es/Footer/FooterAuth.js +15 -22
  7. package/es/InfoBlock/InfoBlock.js +55 -0
  8. package/es/InfoBlock/index.js +1 -0
  9. package/es/LearningPaths/LearningPathMenu.js +3 -4
  10. package/es/Masthead/MastheadAuthModal.js +2 -2
  11. package/es/MyNdla/Navigation/VerticalNavigation.js +51 -0
  12. package/es/MyNdla/Navigation/index.js +2 -0
  13. package/es/MyNdla/Resource/Folder.js +86 -0
  14. package/{lib/MyNdla/ResourceDash/ResourcesView.d.ts → es/MyNdla/Resource/index.js} +2 -3
  15. package/es/MyNdla/index.js +3 -4
  16. package/es/Notion/ConceptNotion.js +2 -1
  17. package/es/Notion/FigureNotion.js +13 -9
  18. package/es/Notion/NotionVisualElement.js +3 -2
  19. package/es/Resource/BlockResource.js +73 -0
  20. package/es/Resource/ListResource.js +66 -0
  21. package/es/Resource/index.js +10 -0
  22. package/es/Resource/resourceComponents.js +97 -0
  23. package/es/ResourceGroup/ResourceGroup.js +7 -5
  24. package/es/ResourceGroup/ResourceItem.js +28 -30
  25. package/es/ResourceGroup/ResourceList.js +18 -6
  26. package/es/Search/ActiveFilters.js +6 -7
  27. package/es/Search/ContentTypeResult.js +6 -8
  28. package/es/SearchTypeResult/ActiveFilters.js +6 -10
  29. package/es/SearchTypeResult/SearchViewType.js +5 -5
  30. package/es/SnackBar/SnackBar.js +117 -0
  31. package/es/SnackBar/index.js +9 -0
  32. package/es/TagSelector/SuggestionInput.js +240 -0
  33. package/es/TagSelector/Suggestions.js +93 -0
  34. package/es/TagSelector/TagSelector.js +137 -0
  35. package/es/TagSelector/index.js +9 -0
  36. package/es/TopicIntroductionList/TopicIntroduction.js +2 -4
  37. package/es/TopicIntroductionList/TopicShortcutItem.js +1 -3
  38. package/es/TreeStructure/FolderItem.js +130 -0
  39. package/es/TreeStructure/FolderItems.js +123 -0
  40. package/es/TreeStructure/FolderNameInput.js +112 -0
  41. package/es/TreeStructure/TreeStructure.js +254 -0
  42. package/es/TreeStructure/TreeStructure.types.js +0 -0
  43. package/es/TreeStructure/TreeStructureWrapper.js +13 -0
  44. package/es/TreeStructure/helperFunctions.js +92 -0
  45. package/es/TreeStructure/index.js +9 -0
  46. package/es/TreeStructure/keyboardNavigation/keyboardNavigation.js +182 -0
  47. package/es/TreeStructure/keyboardNavigation/keyboardNavigation.types.js +0 -0
  48. package/es/User/AuthModal.js +15 -24
  49. package/es/User/UserInfo.js +70 -0
  50. package/es/User/apiTypes.js +0 -0
  51. package/es/User/index.js +2 -0
  52. package/es/User/parseUserObject.js +102 -0
  53. package/es/all.css +90 -0
  54. package/es/index.js +9 -3
  55. package/es/locale/messages-en.js +75 -8
  56. package/es/locale/messages-nb.js +74 -7
  57. package/es/locale/messages-nn.js +74 -7
  58. package/es/locale/messages-se.js +74 -7
  59. package/es/locale/messages-sma.js +74 -7
  60. package/lib/Article/Article.d.ts +3 -1
  61. package/lib/Article/Article.js +43 -23
  62. package/lib/Article/ArticleFavoritesButton.d.ts +15 -0
  63. package/lib/Article/ArticleFavoritesButton.js +56 -0
  64. package/lib/Article/index.d.ts +2 -1
  65. package/lib/Article/index.js +8 -0
  66. package/lib/Breadcrumb/ActionBreadcrumb.d.ts +16 -0
  67. package/lib/Breadcrumb/ActionBreadcrumb.js +72 -0
  68. package/lib/Breadcrumb/index.d.ts +1 -0
  69. package/lib/Breadcrumb/index.js +8 -0
  70. package/lib/Footer/FooterAuth.d.ts +1 -1
  71. package/lib/Footer/FooterAuth.js +17 -17
  72. package/lib/InfoBlock/InfoBlock.d.ts +8 -0
  73. package/lib/InfoBlock/InfoBlock.js +58 -0
  74. package/lib/InfoBlock/index.d.ts +1 -0
  75. package/lib/InfoBlock/index.js +13 -0
  76. package/lib/LearningPaths/LearningPathMenu.js +3 -4
  77. package/lib/Masthead/MastheadAuthModal.d.ts +3 -3
  78. package/lib/Masthead/MastheadAuthModal.js +3 -3
  79. package/lib/MyNdla/Navigation/VerticalNavigation.d.ts +10 -0
  80. package/lib/MyNdla/Navigation/VerticalNavigation.js +61 -0
  81. package/lib/MyNdla/Navigation/index.d.ts +2 -0
  82. package/lib/MyNdla/Navigation/index.js +15 -0
  83. package/lib/MyNdla/Resource/Folder.d.ts +20 -0
  84. package/lib/MyNdla/Resource/Folder.js +100 -0
  85. package/lib/MyNdla/Resource/index.d.ts +9 -0
  86. package/lib/MyNdla/Resource/index.js +15 -0
  87. package/lib/MyNdla/index.d.ts +3 -4
  88. package/lib/MyNdla/index.js +9 -11
  89. package/lib/Notion/ConceptNotion.js +2 -1
  90. package/lib/Notion/FigureNotion.d.ts +1 -1
  91. package/lib/Notion/FigureNotion.js +12 -8
  92. package/lib/Notion/NotionVisualElement.js +3 -2
  93. package/lib/Resource/BlockResource.d.ts +20 -0
  94. package/lib/Resource/BlockResource.js +84 -0
  95. package/lib/Resource/ListResource.d.ts +20 -0
  96. package/lib/Resource/ListResource.js +78 -0
  97. package/lib/Resource/index.d.ts +11 -0
  98. package/lib/Resource/index.js +29 -0
  99. package/lib/Resource/resourceComponents.d.ts +24 -0
  100. package/lib/Resource/resourceComponents.js +106 -0
  101. package/lib/ResourceGroup/ResourceGroup.d.ts +2 -1
  102. package/lib/ResourceGroup/ResourceGroup.js +7 -5
  103. package/lib/ResourceGroup/ResourceItem.d.ts +5 -1
  104. package/lib/ResourceGroup/ResourceItem.js +29 -30
  105. package/lib/ResourceGroup/ResourceList.d.ts +3 -1
  106. package/lib/ResourceGroup/ResourceList.js +18 -6
  107. package/lib/Search/ActiveFilters.js +6 -7
  108. package/lib/Search/ContentTypeResult.js +6 -8
  109. package/lib/SearchTypeResult/ActiveFilters.js +6 -10
  110. package/lib/SearchTypeResult/SearchViewType.js +5 -5
  111. package/lib/SnackBar/SnackBar.d.ts +23 -0
  112. package/lib/SnackBar/SnackBar.js +127 -0
  113. package/lib/SnackBar/index.d.ts +10 -0
  114. package/lib/SnackBar/index.js +15 -0
  115. package/lib/TagSelector/SuggestionInput.d.ts +19 -0
  116. package/lib/TagSelector/SuggestionInput.js +255 -0
  117. package/lib/TagSelector/Suggestions.d.ts +12 -0
  118. package/lib/TagSelector/Suggestions.js +96 -0
  119. package/lib/TagSelector/TagSelector.d.ts +16 -0
  120. package/lib/TagSelector/TagSelector.js +150 -0
  121. package/lib/TagSelector/index.d.ts +10 -0
  122. package/lib/TagSelector/index.js +19 -0
  123. package/lib/TopicIntroductionList/TopicIntroduction.js +2 -4
  124. package/lib/TopicIntroductionList/TopicShortcutItem.js +1 -3
  125. package/lib/TreeStructure/FolderItem.d.ts +27 -0
  126. package/lib/TreeStructure/FolderItem.js +140 -0
  127. package/lib/TreeStructure/FolderItems.d.ts +11 -0
  128. package/lib/TreeStructure/FolderItems.js +130 -0
  129. package/lib/TreeStructure/FolderNameInput.d.ts +15 -0
  130. package/lib/TreeStructure/FolderNameInput.js +125 -0
  131. package/lib/TreeStructure/TreeStructure.d.ts +12 -0
  132. package/lib/TreeStructure/TreeStructure.js +273 -0
  133. package/lib/TreeStructure/TreeStructure.types.d.ts +63 -0
  134. package/lib/TreeStructure/TreeStructure.types.js +1 -0
  135. package/lib/TreeStructure/TreeStructureWrapper.d.ts +12 -0
  136. package/lib/TreeStructure/TreeStructureWrapper.js +24 -0
  137. package/lib/TreeStructure/helperFunctions.d.ts +5 -0
  138. package/lib/TreeStructure/helperFunctions.js +103 -0
  139. package/lib/TreeStructure/index.d.ts +10 -0
  140. package/lib/TreeStructure/index.js +15 -0
  141. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.d.ts +11 -0
  142. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.js +186 -0
  143. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.types.d.ts +26 -0
  144. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.types.js +1 -0
  145. package/lib/User/AuthModal.d.ts +3 -3
  146. package/lib/User/AuthModal.js +16 -23
  147. package/lib/User/UserInfo.d.ts +13 -0
  148. package/lib/User/UserInfo.js +84 -0
  149. package/lib/User/apiTypes.d.ts +61 -0
  150. package/lib/User/apiTypes.js +1 -0
  151. package/lib/User/index.d.ts +4 -0
  152. package/lib/User/index.js +8 -0
  153. package/lib/User/parseUserObject.d.ts +32 -0
  154. package/lib/User/parseUserObject.js +105 -0
  155. package/lib/all.css +90 -0
  156. package/lib/index.d.ts +14 -3
  157. package/lib/index.js +76 -10
  158. package/lib/locale/messages-en.d.ts +67 -0
  159. package/lib/locale/messages-en.js +75 -8
  160. package/lib/locale/messages-nb.d.ts +67 -0
  161. package/lib/locale/messages-nb.js +74 -7
  162. package/lib/locale/messages-nn.d.ts +67 -0
  163. package/lib/locale/messages-nn.js +74 -7
  164. package/lib/locale/messages-se.d.ts +67 -0
  165. package/lib/locale/messages-se.js +74 -7
  166. package/lib/locale/messages-sma.d.ts +67 -0
  167. package/lib/locale/messages-sma.js +74 -7
  168. package/lib/types.d.ts +1 -1
  169. package/package.json +11 -11
  170. package/src/Article/Article.tsx +31 -0
  171. package/src/Article/ArticleFavoritesButton.tsx +40 -0
  172. package/src/Article/index.ts +2 -0
  173. package/src/Breadcrumb/ActionBreadcrumb.tsx +68 -0
  174. package/src/Breadcrumb/index.ts +2 -0
  175. package/src/Footer/FooterAuth.tsx +7 -9
  176. package/src/InfoBlock/InfoBlock.tsx +61 -0
  177. package/src/InfoBlock/index.ts +1 -0
  178. package/src/LearningPaths/LearningPathMenu.tsx +1 -1
  179. package/src/Masthead/MastheadAuthModal.tsx +4 -5
  180. package/src/MyNdla/Navigation/VerticalNavigation.tsx +93 -0
  181. package/src/MyNdla/Navigation/index.ts +2 -0
  182. package/src/MyNdla/Resource/Folder.tsx +143 -0
  183. package/src/MyNdla/Resource/index.ts +10 -0
  184. package/src/MyNdla/index.ts +3 -5
  185. package/src/Notion/ConceptNotion.tsx +1 -0
  186. package/src/Notion/FigureNotion.tsx +12 -5
  187. package/src/Notion/NotionVisualElement.tsx +1 -1
  188. package/src/Resource/BlockResource.tsx +101 -0
  189. package/src/Resource/ListResource.tsx +111 -0
  190. package/src/Resource/index.ts +12 -0
  191. package/src/Resource/resourceComponents.tsx +143 -0
  192. package/src/ResourceGroup/ResourceGroup.tsx +3 -0
  193. package/src/ResourceGroup/ResourceItem.tsx +20 -3
  194. package/src/ResourceGroup/ResourceList.tsx +16 -3
  195. package/src/Search/ActiveFilters.jsx +0 -1
  196. package/src/Search/ContentTypeResult.tsx +8 -9
  197. package/src/SearchTypeResult/ActiveFilters.tsx +1 -3
  198. package/src/SearchTypeResult/SearchViewType.tsx +1 -1
  199. package/src/SnackBar/SnackBar.tsx +183 -0
  200. package/src/SnackBar/index.ts +13 -0
  201. package/src/TagSelector/SuggestionInput.tsx +230 -0
  202. package/src/TagSelector/Suggestions.tsx +125 -0
  203. package/src/TagSelector/TagSelector.tsx +111 -0
  204. package/src/TagSelector/index.ts +13 -0
  205. package/src/TopicIntroductionList/TopicIntroduction.tsx +2 -2
  206. package/src/TopicIntroductionList/TopicShortcutItem.tsx +1 -5
  207. package/src/TreeStructure/FolderItem.tsx +160 -0
  208. package/src/TreeStructure/FolderItems.tsx +109 -0
  209. package/src/TreeStructure/FolderNameInput.tsx +109 -0
  210. package/src/TreeStructure/TreeStructure.tsx +184 -0
  211. package/src/TreeStructure/TreeStructure.types.ts +69 -0
  212. package/src/TreeStructure/TreeStructureWrapper.tsx +34 -0
  213. package/src/TreeStructure/helperFunctions.ts +52 -0
  214. package/src/TreeStructure/index.ts +11 -0
  215. package/src/TreeStructure/keyboardNavigation/keyboardNavigation.ts +161 -0
  216. package/src/TreeStructure/keyboardNavigation/keyboardNavigation.types.ts +28 -0
  217. package/src/User/AuthModal.tsx +5 -26
  218. package/src/User/UserInfo.tsx +80 -0
  219. package/src/User/__tests__/parseUserObject-test.ts +315 -0
  220. package/src/User/apiTypes.ts +74 -0
  221. package/src/User/index.ts +4 -0
  222. package/src/User/parseUserObject.ts +83 -0
  223. package/src/all.scss +2 -0
  224. package/src/index.ts +15 -4
  225. package/src/locale/messages-en.ts +69 -7
  226. package/src/locale/messages-nb.ts +68 -6
  227. package/src/locale/messages-nn.ts +68 -6
  228. package/src/locale/messages-se.ts +68 -6
  229. package/src/locale/messages-sma.ts +68 -6
  230. package/src/types.ts +1 -1
  231. package/es/MyNdla/ResourceDash/Breadcrumbs.js +0 -22
  232. package/es/MyNdla/ResourceDash/ResourceElement.js +0 -27
  233. package/es/MyNdla/ResourceDash/ResourcesView.js +0 -43
  234. package/es/MyNdla/ResourceDash/index.js +0 -4
  235. package/lib/MyNdla/ResourceDash/Breadcrumbs.d.ts +0 -15
  236. package/lib/MyNdla/ResourceDash/Breadcrumbs.js +0 -35
  237. package/lib/MyNdla/ResourceDash/ResourceElement.d.ts +0 -18
  238. package/lib/MyNdla/ResourceDash/ResourceElement.js +0 -38
  239. package/lib/MyNdla/ResourceDash/ResourcesView.js +0 -57
  240. package/lib/MyNdla/ResourceDash/index.d.ts +0 -4
  241. package/lib/MyNdla/ResourceDash/index.js +0 -31
  242. package/src/MyNdla/ResourceDash/Breadcrumbs.tsx +0 -31
  243. package/src/MyNdla/ResourceDash/ResourceElement.tsx +0 -50
  244. package/src/MyNdla/ResourceDash/ResourcesView.tsx +0 -42
  245. package/src/MyNdla/ResourceDash/index.ts +0 -5
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { FeideUserApiType } from '../apiTypes';
10
+ import { parseUserObject } from '../parseUserObject';
11
+
12
+ const feideUserLaerer: FeideUserApiType = {
13
+ cn: ['David LærerVGS Jonsen'],
14
+ displayName: 'David LærerVGS Jonsen',
15
+ eduPersonAffiliation: ['member', 'employee', 'faculty'],
16
+ eduPersonPrimaryAffiliation: 'employee',
17
+ eduPersonPrincipalName: 'david_laerervgs@spusers.feide.no',
18
+ givenName: ['David LærerVGS'],
19
+ mail: ['david_laerervgs@feide.no'],
20
+ sn: ['Jonsen'],
21
+ uid: ['david_laerervgs'],
22
+ groups: [
23
+ {
24
+ id: 'fc:org:spusers.feide.no',
25
+ displayName: 'Rogn fylkeskommune',
26
+ type: 'fc:org',
27
+ public: false,
28
+ membership: {
29
+ basic: 'admin',
30
+ affiliation: ['member', 'employee', 'faculty'],
31
+ primaryAffiliation: 'employee',
32
+ displayName: 'Akademisk ansatt',
33
+ },
34
+ orgType: ['higher_education', 'upper_secondary_owner', 'primary_and_lower_secondary_owner'],
35
+ norEduOrgNIN: 'NO956326503',
36
+ eduOrgLegalName: 'Rogn fylkeskommune',
37
+ mail: 'support@feide.no',
38
+ },
39
+ {
40
+ id: 'fc:org:spusers.feide.no:unit:NO956326504',
41
+ parent: 'fc:org:spusers.feide.no',
42
+ displayName: 'Lind VGS',
43
+ type: 'fc:org',
44
+ public: false,
45
+ membership: {
46
+ basic: 'member',
47
+ primarySchool: true,
48
+ },
49
+ orgType: ['primary_and_lower_secondary'],
50
+ },
51
+ {
52
+ id: 'fc:org:spusers.feide.no:unit:NO856326501',
53
+ parent: 'fc:org:spusers.feide.no',
54
+ displayName: 'Lerk VGS',
55
+ type: 'fc:org',
56
+ public: false,
57
+ membership: {
58
+ basic: 'member',
59
+ primarySchool: false,
60
+ },
61
+ orgType: ['primary_and_lower_secondary'],
62
+ },
63
+ {
64
+ id: 'fc:gogroup:spusers.feide.no:b:NO856326501:1sta:2000-07-01:2100-06-30',
65
+ displayName: 'Klasse 1STA',
66
+ type: 'fc:gogroup',
67
+ notBefore: '2000-06-30T22:00:00Z',
68
+ notAfter: '2100-06-30T23:00:00Z',
69
+ go_type: 'b',
70
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
71
+ membership: {
72
+ basic: 'member',
73
+ affiliation: 'employee',
74
+ displayName: 'Ansatt',
75
+ },
76
+ go_type_displayName: 'basisgruppe',
77
+ },
78
+ {
79
+ id: 'fc:gogroup:spusers.feide.no:a:NO856326501:1sta-lab1:2000-07-01:2100-06-30',
80
+ displayName: 'Laboratoriegruppe 1',
81
+ type: 'fc:gogroup',
82
+ notBefore: '2000-06-30T22:00:00Z',
83
+ notAfter: '2100-06-30T23:00:00Z',
84
+ go_type: 'a',
85
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
86
+ membership: {
87
+ basic: 'member',
88
+ affiliation: 'employee',
89
+ displayName: 'Ansatt',
90
+ },
91
+ go_type_displayName: 'other groups',
92
+ },
93
+ {
94
+ id: 'fc:gogroup:spusers.feide.no:a:NO856326501:1sta-lab2:2000-07-01:2100-06-30',
95
+ displayName: 'Laboratoriegruppe 2',
96
+ type: 'fc:gogroup',
97
+ notBefore: '2000-06-30T22:00:00Z',
98
+ notAfter: '2100-06-30T23:00:00Z',
99
+ go_type: 'a',
100
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
101
+ membership: {
102
+ basic: 'member',
103
+ affiliation: 'employee',
104
+ displayName: 'Ansatt',
105
+ },
106
+ go_type_displayName: 'other groups',
107
+ },
108
+ {
109
+ id: 'fc:gogroup:spusers.feide.no:u:NO856326501:1mat11-1map1:2000-07-01:2100-06-30',
110
+ displayName: 'Matematikk 1P',
111
+ type: 'fc:gogroup',
112
+ notBefore: '2000-06-30T22:00:00Z',
113
+ notAfter: '2100-06-30T23:00:00Z',
114
+ go_type: 'u',
115
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
116
+ membership: {
117
+ basic: 'member',
118
+ affiliation: 'employee',
119
+ displayName: 'Ansatt',
120
+ },
121
+ go_type_displayName: 'undervisningsgruppe',
122
+ grep: {
123
+ displayName: 'Mathematics 1P',
124
+ code: 'MAT1011',
125
+ },
126
+ },
127
+ {
128
+ id: 'fc:gogroup:spusers.feide.no:u:NO856326501:1mat13-1mat1:2000-07-01:2100-06-30',
129
+ displayName: 'Matematikk 1T',
130
+ type: 'fc:gogroup',
131
+ notBefore: '2000-06-30T22:00:00Z',
132
+ notAfter: '2100-06-30T23:00:00Z',
133
+ go_type: 'u',
134
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
135
+ membership: {
136
+ basic: 'member',
137
+ affiliation: 'employee',
138
+ displayName: 'Ansatt',
139
+ },
140
+ go_type_displayName: 'undervisningsgruppe',
141
+ grep: {
142
+ displayName: 'Mathematics 1T',
143
+ code: 'MAT1013',
144
+ },
145
+ },
146
+ ],
147
+ primarySchool: {
148
+ id: 'fc:org:spusers.feide.no:unit:NO956326504',
149
+ parent: 'fc:org:spusers.feide.no',
150
+ displayName: 'Lind VGS',
151
+ type: 'fc:org',
152
+ public: false,
153
+ membership: {
154
+ basic: 'member',
155
+ primarySchool: true,
156
+ },
157
+ orgType: ['primary_and_lower_secondary'],
158
+ },
159
+ };
160
+
161
+ describe('parseUserObject', () => {
162
+ it('Correctly parses Feide user', () => {
163
+ const expected = {
164
+ uid: ['david_laerervgs'],
165
+ primaryAffiliation: 'employee',
166
+ displayName: 'David LærerVGS Jonsen',
167
+ mail: ['david_laerervgs@feide.no'],
168
+ organizations: [
169
+ {
170
+ id: 'fc:org:spusers.feide.no',
171
+ displayName: 'Rogn fylkeskommune',
172
+ type: 'fc:org',
173
+ public: false,
174
+ membership: {
175
+ basic: 'admin',
176
+ affiliation: ['member', 'employee', 'faculty'],
177
+ primaryAffiliation: 'employee',
178
+ displayName: 'Akademisk ansatt',
179
+ },
180
+ orgType: ['higher_education', 'upper_secondary_owner', 'primary_and_lower_secondary_owner'],
181
+ norEduOrgNIN: 'NO956326503',
182
+ eduOrgLegalName: 'Rogn fylkeskommune',
183
+ mail: 'support@feide.no',
184
+ children: {
185
+ basic: [],
186
+ teaching: [],
187
+ other: [],
188
+ },
189
+ },
190
+ {
191
+ id: 'fc:org:spusers.feide.no:unit:NO956326504',
192
+ parent: 'fc:org:spusers.feide.no',
193
+ displayName: 'Lind VGS',
194
+ type: 'fc:org',
195
+ public: false,
196
+ membership: {
197
+ basic: 'member',
198
+ primarySchool: true,
199
+ },
200
+ orgType: ['primary_and_lower_secondary'],
201
+ children: {
202
+ basic: [],
203
+ teaching: [],
204
+ other: [],
205
+ },
206
+ },
207
+ {
208
+ id: 'fc:org:spusers.feide.no:unit:NO856326501',
209
+ parent: 'fc:org:spusers.feide.no',
210
+ displayName: 'Lerk VGS',
211
+ type: 'fc:org',
212
+ public: false,
213
+ membership: {
214
+ basic: 'member',
215
+ primarySchool: false,
216
+ },
217
+ orgType: ['primary_and_lower_secondary'],
218
+ children: {
219
+ basic: [
220
+ {
221
+ id: 'fc:gogroup:spusers.feide.no:b:NO856326501:1sta:2000-07-01:2100-06-30',
222
+ displayName: 'Klasse 1STA',
223
+ type: 'fc:gogroup',
224
+ notBefore: '2000-06-30T22:00:00Z',
225
+ notAfter: '2100-06-30T23:00:00Z',
226
+ go_type: 'b',
227
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
228
+ membership: {
229
+ basic: 'member',
230
+ affiliation: 'employee',
231
+ displayName: 'Ansatt',
232
+ },
233
+ go_type_displayName: 'basisgruppe',
234
+ },
235
+ ],
236
+ teaching: [
237
+ {
238
+ id: 'fc:gogroup:spusers.feide.no:u:NO856326501:1mat11-1map1:2000-07-01:2100-06-30',
239
+ displayName: 'Matematikk 1P',
240
+ type: 'fc:gogroup',
241
+ notBefore: '2000-06-30T22:00:00Z',
242
+ notAfter: '2100-06-30T23:00:00Z',
243
+ go_type: 'u',
244
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
245
+ membership: {
246
+ basic: 'member',
247
+ affiliation: 'employee',
248
+ displayName: 'Ansatt',
249
+ },
250
+ go_type_displayName: 'undervisningsgruppe',
251
+ grep: {
252
+ displayName: 'Mathematics 1P',
253
+ code: 'MAT1011',
254
+ },
255
+ },
256
+ {
257
+ id: 'fc:gogroup:spusers.feide.no:u:NO856326501:1mat13-1mat1:2000-07-01:2100-06-30',
258
+ displayName: 'Matematikk 1T',
259
+ type: 'fc:gogroup',
260
+ notBefore: '2000-06-30T22:00:00Z',
261
+ notAfter: '2100-06-30T23:00:00Z',
262
+ go_type: 'u',
263
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
264
+ membership: {
265
+ basic: 'member',
266
+ affiliation: 'employee',
267
+ displayName: 'Ansatt',
268
+ },
269
+ go_type_displayName: 'undervisningsgruppe',
270
+ grep: {
271
+ displayName: 'Mathematics 1T',
272
+ code: 'MAT1013',
273
+ },
274
+ },
275
+ ],
276
+ other: [
277
+ {
278
+ id: 'fc:gogroup:spusers.feide.no:a:NO856326501:1sta-lab1:2000-07-01:2100-06-30',
279
+ displayName: 'Laboratoriegruppe 1',
280
+ type: 'fc:gogroup',
281
+ notBefore: '2000-06-30T22:00:00Z',
282
+ notAfter: '2100-06-30T23:00:00Z',
283
+ go_type: 'a',
284
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
285
+ membership: {
286
+ basic: 'member',
287
+ affiliation: 'employee',
288
+ displayName: 'Ansatt',
289
+ },
290
+ go_type_displayName: 'other groups',
291
+ },
292
+ {
293
+ id: 'fc:gogroup:spusers.feide.no:a:NO856326501:1sta-lab2:2000-07-01:2100-06-30',
294
+ displayName: 'Laboratoriegruppe 2',
295
+ type: 'fc:gogroup',
296
+ notBefore: '2000-06-30T22:00:00Z',
297
+ notAfter: '2100-06-30T23:00:00Z',
298
+ go_type: 'a',
299
+ parent: 'fc:org:spusers.feide.no:unit:NO856326501',
300
+ membership: {
301
+ basic: 'member',
302
+ affiliation: 'employee',
303
+ displayName: 'Ansatt',
304
+ },
305
+ go_type_displayName: 'other groups',
306
+ },
307
+ ],
308
+ },
309
+ },
310
+ ],
311
+ };
312
+ const actual = parseUserObject(feideUserLaerer);
313
+ expect(actual).toEqual(expected);
314
+ });
315
+ });
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ type OrgType =
10
+ | 'higher_education'
11
+ | 'primary_and_lower_secondary'
12
+ | 'primary_and_lower_secondary_owner'
13
+ | 'upper_secondary'
14
+ | 'upper_secondary_owner';
15
+
16
+ type AffiliationType = 'member' | 'student' | 'faculty' | 'staff' | 'affiliate' | 'employee';
17
+
18
+ export interface FeideMembershipType {
19
+ basic: 'member' | 'admin' | 'owner'; // Basic membership role of user.
20
+ affiliation?: AffiliationType[] | AffiliationType;
21
+ primarySchool?: boolean;
22
+ primaryAffiliation?: AffiliationType;
23
+ displayName?: string;
24
+ }
25
+
26
+ interface FeideBaseGroup {
27
+ id: string;
28
+ type: 'fc:org' | 'fc:gogroup';
29
+ displayName: string;
30
+ membership: FeideMembershipType;
31
+ }
32
+
33
+ export interface FeideOrg extends FeideBaseGroup {
34
+ type: 'fc:org';
35
+ orgType: OrgType[];
36
+ norEduOrgNIN?: string;
37
+ eduOrgLegalName?: string;
38
+ mail?: string;
39
+ parent?: string;
40
+ public: boolean;
41
+ }
42
+
43
+ export interface FeideGoGroup extends FeideBaseGroup {
44
+ type: 'fc:gogroup';
45
+ notBefore: string;
46
+ notAfter: string;
47
+ go_type: 'b' | 'u' | 'a';
48
+ parent: string;
49
+ go_type_displayName: string;
50
+ grep?: {
51
+ displayName: string;
52
+ code: string;
53
+ };
54
+ }
55
+
56
+ export type FeideGroup = FeideOrg | FeideGoGroup;
57
+
58
+ export interface FeideUser {
59
+ cn: string[];
60
+ displayName: string;
61
+ eduPersonAffiliation: AffiliationType[] | AffiliationType;
62
+ eduPersonPrimaryAffiliation: string;
63
+ eduPersonPrincipalName: string;
64
+ givenName: string[];
65
+ mail?: string[];
66
+ schacHomeOrganization?: string;
67
+ sn: string[];
68
+ uid: string[];
69
+ }
70
+
71
+ export interface FeideUserApiType extends FeideUser {
72
+ groups: FeideGroup[];
73
+ primarySchool?: FeideGroup;
74
+ }
package/src/User/index.ts CHANGED
@@ -7,5 +7,9 @@
7
7
  */
8
8
 
9
9
  import AuthModal from './AuthModal';
10
+ import { UserInfo } from './UserInfo';
11
+ import type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser } from './apiTypes';
10
12
 
13
+ export { UserInfo };
14
+ export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser };
11
15
  export default AuthModal;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { groupBy } from 'lodash';
9
+ import { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType } from './apiTypes';
10
+
11
+ type GoGroupType = 'basic' | 'teaching' | 'other';
12
+
13
+ /**
14
+ * The keys come from:
15
+ * https://docs.feide.no/reference/apis/groups_api/groups_data_model/primary_and_secondary_education_groups.html?highlight=gogroup#specific-attributes-for-fc-gogroup
16
+ */
17
+ const goGroupTypeMap: Record<'a' | 'b' | 'u', GoGroupType> = {
18
+ a: 'other',
19
+ b: 'basic',
20
+ u: 'teaching',
21
+ };
22
+
23
+ /**
24
+ * @param groups GoGroups to be mapped to specific GoGroupType
25
+ * @returns GoGroups mapped to GoGroupType. basic, teaching and other..
26
+ */
27
+ const createGroupings = (groups: FeideGoGroup[]) => {
28
+ return groups.reduce<Record<GoGroupType, FeideGoGroup[]>>(
29
+ (acc, curr) => {
30
+ const type = goGroupTypeMap[curr.go_type];
31
+ if (!acc[type]) return acc;
32
+
33
+ acc[type] = acc[type].concat(curr);
34
+ return acc;
35
+ },
36
+ {
37
+ basic: [],
38
+ teaching: [],
39
+ other: [],
40
+ },
41
+ );
42
+ };
43
+
44
+ /**
45
+ * @param groups GoGroups to be mapped to root/child relations.
46
+ * @returns An object containing root groups mapped with children.
47
+ */
48
+ const parseOrgs = (groups: FeideGroup[]) => {
49
+ const [roots, children] = groups.reduce<[FeideOrg[], FeideGoGroup[]]>(
50
+ (acc, curr) => {
51
+ if (curr.type === 'fc:org') {
52
+ return [acc[0].concat(curr), acc[1]];
53
+ } else {
54
+ return [acc[0], acc[1].concat(curr)];
55
+ }
56
+ },
57
+ [[], []],
58
+ );
59
+
60
+ const childrenByParentId = groupBy(children, (c) => c.parent);
61
+ const rootsWithChildren = roots.map((root) => ({ ...root, children: childrenByParentId[root.id] ?? [] }));
62
+
63
+ return rootsWithChildren.map((root) => ({
64
+ ...root,
65
+ children: createGroupings(root.children),
66
+ }));
67
+ };
68
+
69
+ /**
70
+ * @param user A user object coming from the API
71
+ * @returns A user object parsed in a presentable way to be handled by i.e UserInfo component.
72
+ */
73
+ export const parseUserObject = (user: FeideUserApiType) => {
74
+ const orgs = parseOrgs(user.groups);
75
+
76
+ return {
77
+ uid: user.uid,
78
+ primaryAffiliation: user.eduPersonPrimaryAffiliation,
79
+ displayName: user.displayName,
80
+ mail: user.mail,
81
+ organizations: orgs,
82
+ };
83
+ };
package/src/all.scss CHANGED
@@ -5,3 +5,5 @@
5
5
  @import '~@ndla/core/scss/utilities';
6
6
  @import '~@ndla/audio-search/scss/audio-search';
7
7
  @import '~@ndla/video-search/scss/video-search';
8
+ @import '~@ndla/button/src/all.scss';
9
+ @import '~@ndla/tooltip/src/all.css';
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ export {
22
22
  ArticleHeaderWrapper,
23
23
  ArticleSideBar,
24
24
  default as Article,
25
+ ArticleFavoritesButton,
25
26
  } from './Article';
26
27
 
27
28
  export { default as Table } from './Table';
@@ -108,7 +109,9 @@ export { SearchFieldForm } from './Search/SearchFieldForm';
108
109
 
109
110
  export { default as MastheadSearchModal } from './Masthead/MastheadSearchModal';
110
111
  export { default as MastheadAuthModal } from './Masthead/MastheadAuthModal';
112
+ export { UserInfo } from './User';
111
113
  export { default as AuthModal } from './User';
114
+ export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser } from './User';
112
115
 
113
116
  export { default as CreatedBy } from './CreatedBy';
114
117
 
@@ -151,7 +154,7 @@ export type { TopicProps } from './Topic';
151
154
  export { default as Aside } from './Aside';
152
155
  export { default as AuthorInfo } from './AuthorInfo';
153
156
 
154
- export { default as Breadcrumb, HeaderBreadcrumb, HomeBreadcrumb } from './Breadcrumb';
157
+ export { default as Breadcrumb, HeaderBreadcrumb, HomeBreadcrumb, ActionBreadcrumb } from './Breadcrumb';
155
158
  export type { SimpleBreadcrumbItem, IndexedBreadcrumbItem } from './Breadcrumb';
156
159
 
157
160
  export type { BreadcrumbItemProps } from './Breadcrumblist/Breadcrumblist';
@@ -219,7 +222,15 @@ export { default as CopyParagraphButton } from './CopyParagraphButton';
219
222
 
220
223
  export { default as ContentPlaceholder } from './ContentPlaceholder';
221
224
  export { Notion, ConceptNotion } from './Notion';
222
-
223
225
  export { BannerCard } from './BannerCard';
224
-
225
- export { ResourcesView, ResourceElement, Breadcrumbs } from './MyNdla';
226
+ export { VerticalNavigation, Folder } from './MyNdla';
227
+ export { ListResource, BlockResource } from './Resource';
228
+ export type { ListResourceProps } from './Resource';
229
+ export type { TagType } from './TagSelector';
230
+ export { TagSelector } from './TagSelector';
231
+
232
+ export type { SnackBarItem } from './SnackBar';
233
+ export { SnackBar } from './SnackBar';
234
+ export { InfoBlock } from './InfoBlock';
235
+ export { TreeStructure } from './TreeStructure';
236
+ export type { FolderStructureProps, TreeStructureProps } from './TreeStructure';
@@ -14,6 +14,19 @@ export const { contentTypes, subjectCategories, subjectTypes } = constants;
14
14
  const titleTemplate = ' - NDLA';
15
15
 
16
16
  const messages = {
17
+ treeStructure: {
18
+ createFolder: 'Create folder',
19
+ newFolder: {
20
+ placeholder: 'Add foldername',
21
+ defaultName: 'New folder',
22
+ },
23
+ },
24
+ tagSelector: {
25
+ placeholder: 'Add to tag',
26
+ removeTag: 'Remove tag {{name}}',
27
+ hideAllTags: 'Hide all tags',
28
+ showAllTags: 'Show all tags',
29
+ },
17
30
  htmlTitles: {
18
31
  titleTemplate,
19
32
  welcomePage: `Frontpage${titleTemplate}`,
@@ -757,15 +770,15 @@ const messages = {
757
770
  },
758
771
  blogPosts: {
759
772
  blog1: {
760
- text: 'Nye fag NDLA',
761
- externalLink: 'https://blogg.ndla.no/2021/12/nye-fag-pa-ndla/',
773
+ text: 'Forslag til årsplaner fra NDLA',
774
+ externalLink: 'https://blogg.ndla.no/2021/08/forslag-til-arsplaner-hos-ndla/',
762
775
  linkText: 'Fagblogg',
763
776
  license: 'CC-BY-SA-4.0',
764
777
  licenseAuthor: 'Vibeke Klungland',
765
778
  },
766
779
  blog2: {
767
- text: 'Aktiviser elevane med digitale verktøy',
768
- externalLink: 'https://blogg.ndla.no/2021/09/aktiviser-elevane-med-digitale-verktoy/',
780
+ text: 'Huskeliste for kontaktlærere',
781
+ externalLink: 'https://blogg.ndla.no/2019/08/huskeliste-for-kontaktlaerere/',
769
782
  linkText: 'Fagblogg',
770
783
  license: 'CC-BY-SA-4.0',
771
784
  licenseAuthor: 'Tom Knudsen',
@@ -945,6 +958,15 @@ const messages = {
945
958
  resource: {
946
959
  accessDenied: 'We are sorry, but this resource is only available to teachers who are logged in with Feide.',
947
960
  },
961
+ primarySchool: 'Primary School',
962
+ name: 'Name',
963
+ mail: 'E-mail',
964
+ username: 'Username',
965
+ groupTypes: {
966
+ basic: 'Basic group',
967
+ teaching: 'Teaching group',
968
+ other: 'Other groups',
969
+ },
948
970
  },
949
971
  checkOutNewFeature: 'New feature',
950
972
  slateBlockMenu: {
@@ -956,15 +978,55 @@ const messages = {
956
978
  close: 'Close fact box',
957
979
  },
958
980
  myNdla: {
959
- resources: 'resources',
960
- folders: 'folders',
961
- folder: 'folder',
981
+ resources: '{{count}} Resource',
982
+ resources_plural: '{{count}} Resources',
983
+ folders: '{{count}} Folder',
984
+ folders_plural: '{{count}} Folders',
985
+ folder: 'Folder',
962
986
  myFolders: 'My folders',
963
987
  myTags: 'My tags',
964
988
  newFolder: 'New folder',
989
+ newFolderUnder: 'Create new folder under {{folderName}}',
965
990
  myAccount: 'My account',
966
991
  favourites: 'Favourites',
967
992
  help: 'Help',
993
+ more: 'More options',
994
+ listView: 'List view',
995
+ detailView: 'Detailed listview',
996
+ shortView: 'Short view',
997
+ myPage: {
998
+ myPage: 'My page',
999
+ logout: 'Log out of My NDLA',
1000
+ deleteAccount: 'Delete My NDLA',
1001
+ welcome:
1002
+ 'Welcome to my NDLA! You can now save your favourite resources from NDLA and organise them in folders with tags',
1003
+ read: { our: 'Read our', ours: 'Read our' },
1004
+ privacy: 'privacy statement',
1005
+ questions: { question: 'Any questions?', ask: 'Ask us in the chat' },
1006
+ wishToDelete: 'Do you wish to delete your account?',
1007
+ terms: 'terms of use',
1008
+ feide: 'We have retrieved this information from Feide',
1009
+ newFavourite: 'Recently favourited',
1010
+ resource: {
1011
+ addToMyNdla: 'Add to My NDLA',
1012
+ addedToMyNdla: 'Added to My NDLA',
1013
+ },
1014
+ storageInfo: {
1015
+ title: 'How to save your favourite resources from NDLA',
1016
+ text: 'When you wish to save a resource, you can do so by clicking the heart on the top right corner of the page. You will then get an option to store the resource in a folder',
1017
+ },
1018
+ folderInfo: {
1019
+ title: 'How to organise your favourite resources in folders',
1020
+ text: 'You can get to the folder overview by clicking on my folders on the menu to the left. Here you can create new folders and subfolder. You can also create a new folder in the dialogue window that is activated when you click on the heart in a resource',
1021
+ },
1022
+ tagInfo: {
1023
+ title: 'How to tag your favourite resources',
1024
+ text: 'When you save a resource, you will have the option to tag it with a keyword. This tag can be used to find the resource across folders. By selecting my tags on the menu to the left, you will see all the tags your have used. You can also see which resources are tagget with which keyword.',
1025
+ },
1026
+ },
1027
+ },
1028
+ snackbar: {
1029
+ close: 'Close notification',
968
1030
  },
969
1031
  labels: {
970
1032
  category: 'Category',