@ndla/ui 13.2.2 → 14.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.
- package/es/Footer/FooterAuth.js +15 -22
- package/es/LearningPaths/LearningPathMenu.js +3 -4
- package/es/Masthead/MastheadAuthModal.js +2 -2
- package/es/ResourceGroup/ResourceItem.js +14 -17
- package/es/Search/ActiveFilters.js +6 -7
- package/es/Search/ContentTypeResult.js +6 -8
- package/es/SearchTypeResult/ActiveFilters.js +6 -10
- package/es/TopicIntroductionList/TopicIntroduction.js +2 -4
- package/es/TopicIntroductionList/TopicShortcutItem.js +1 -3
- package/es/User/AuthModal.js +15 -24
- package/es/User/UserInfo.js +70 -0
- package/es/User/apiTypes.js +0 -0
- package/es/User/index.js +2 -0
- package/es/User/parseUserObject.js +102 -0
- package/es/all.css +18 -0
- package/es/index.js +1 -0
- package/es/locale/messages-en.js +9 -0
- package/es/locale/messages-nb.js +9 -0
- package/es/locale/messages-nn.js +9 -0
- package/es/locale/messages-se.js +9 -0
- package/es/locale/messages-sma.js +9 -0
- package/lib/Footer/FooterAuth.d.ts +1 -1
- package/lib/Footer/FooterAuth.js +17 -17
- package/lib/LearningPaths/LearningPathMenu.js +3 -4
- package/lib/Masthead/MastheadAuthModal.d.ts +3 -3
- package/lib/Masthead/MastheadAuthModal.js +3 -3
- package/lib/ResourceGroup/ResourceItem.js +14 -17
- package/lib/Search/ActiveFilters.js +6 -7
- package/lib/Search/ContentTypeResult.js +6 -8
- package/lib/SearchTypeResult/ActiveFilters.js +6 -10
- package/lib/TopicIntroductionList/TopicIntroduction.js +2 -4
- package/lib/TopicIntroductionList/TopicShortcutItem.js +1 -3
- package/lib/User/AuthModal.d.ts +3 -3
- package/lib/User/AuthModal.js +16 -23
- package/lib/User/UserInfo.d.ts +13 -0
- package/lib/User/UserInfo.js +84 -0
- package/lib/User/apiTypes.d.ts +61 -0
- package/lib/User/apiTypes.js +1 -0
- package/lib/User/index.d.ts +4 -0
- package/lib/User/index.js +8 -0
- package/lib/User/parseUserObject.d.ts +32 -0
- package/lib/User/parseUserObject.js +105 -0
- package/lib/all.css +18 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -1
- package/lib/locale/messages-en.d.ts +9 -0
- package/lib/locale/messages-en.js +9 -0
- package/lib/locale/messages-nb.d.ts +9 -0
- package/lib/locale/messages-nb.js +9 -0
- package/lib/locale/messages-nn.d.ts +9 -0
- package/lib/locale/messages-nn.js +9 -0
- package/lib/locale/messages-se.d.ts +9 -0
- package/lib/locale/messages-se.js +9 -0
- package/lib/locale/messages-sma.d.ts +9 -0
- package/lib/locale/messages-sma.js +9 -0
- package/package.json +5 -5
- package/src/Footer/FooterAuth.tsx +7 -9
- package/src/LearningPaths/LearningPathMenu.tsx +1 -1
- package/src/Masthead/MastheadAuthModal.tsx +4 -5
- package/src/ResourceGroup/ResourceItem.tsx +3 -3
- package/src/Search/ActiveFilters.jsx +0 -1
- package/src/Search/ContentTypeResult.tsx +8 -9
- package/src/SearchTypeResult/ActiveFilters.tsx +1 -3
- package/src/TopicIntroductionList/TopicIntroduction.tsx +2 -2
- package/src/TopicIntroductionList/TopicShortcutItem.tsx +1 -5
- package/src/User/AuthModal.tsx +5 -26
- package/src/User/UserInfo.tsx +80 -0
- package/src/User/__tests__/parseUserObject-test.ts +315 -0
- package/src/User/apiTypes.ts +74 -0
- package/src/User/index.ts +4 -0
- package/src/User/parseUserObject.ts +83 -0
- package/src/all.scss +1 -0
- package/src/index.ts +2 -0
- package/src/locale/messages-en.ts +9 -0
- package/src/locale/messages-nb.ts +9 -0
- package/src/locale/messages-nn.ts +9 -0
- package/src/locale/messages-se.ts +9 -0
- package/src/locale/messages-sma.ts +9 -0
|
@@ -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
|
+
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 } from './apiTypes';
|
|
10
12
|
|
|
13
|
+
export { UserInfo };
|
|
14
|
+
export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType };
|
|
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
package/src/index.ts
CHANGED
|
@@ -108,7 +108,9 @@ export { SearchFieldForm } from './Search/SearchFieldForm';
|
|
|
108
108
|
|
|
109
109
|
export { default as MastheadSearchModal } from './Masthead/MastheadSearchModal';
|
|
110
110
|
export { default as MastheadAuthModal } from './Masthead/MastheadAuthModal';
|
|
111
|
+
export { UserInfo } from './User';
|
|
111
112
|
export { default as AuthModal } from './User';
|
|
113
|
+
export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType } from './User';
|
|
112
114
|
|
|
113
115
|
export { default as CreatedBy } from './CreatedBy';
|
|
114
116
|
|
|
@@ -945,6 +945,15 @@ const messages = {
|
|
|
945
945
|
resource: {
|
|
946
946
|
accessDenied: 'We are sorry, but this resource is only available to teachers who are logged in with Feide.',
|
|
947
947
|
},
|
|
948
|
+
primarySchool: 'Primary School',
|
|
949
|
+
name: 'Name',
|
|
950
|
+
mail: 'E-mail',
|
|
951
|
+
username: 'Username',
|
|
952
|
+
groupTypes: {
|
|
953
|
+
basic: 'Basic group',
|
|
954
|
+
teaching: 'Teaching group',
|
|
955
|
+
other: 'Other groups',
|
|
956
|
+
},
|
|
948
957
|
},
|
|
949
958
|
checkOutNewFeature: 'New feature',
|
|
950
959
|
slateBlockMenu: {
|
|
@@ -943,6 +943,15 @@ const messages = {
|
|
|
943
943
|
resource: {
|
|
944
944
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.',
|
|
945
945
|
},
|
|
946
|
+
primarySchool: 'Hovedskole',
|
|
947
|
+
name: 'Navn',
|
|
948
|
+
mail: 'E-post',
|
|
949
|
+
username: 'Brukernavn',
|
|
950
|
+
groupTypes: {
|
|
951
|
+
basic: 'Basisgruppe',
|
|
952
|
+
teaching: 'Undervisningsgruppe',
|
|
953
|
+
other: 'Andre grupper',
|
|
954
|
+
},
|
|
946
955
|
},
|
|
947
956
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
948
957
|
slateBlockMenu: {
|
|
@@ -944,6 +944,15 @@ const messages = {
|
|
|
944
944
|
resource: {
|
|
945
945
|
accessDenied: 'Vi beklagar, men denne ressursen er berre for lærarar innlogga med Feide.',
|
|
946
946
|
},
|
|
947
|
+
primarySchool: 'Hovudskule',
|
|
948
|
+
name: 'Namn',
|
|
949
|
+
mail: 'E-post',
|
|
950
|
+
username: 'Brukarnamn',
|
|
951
|
+
groupTypes: {
|
|
952
|
+
basic: 'Basisgruppe',
|
|
953
|
+
teaching: 'Undervisningsgruppe',
|
|
954
|
+
other: 'Andre grupper',
|
|
955
|
+
},
|
|
947
956
|
},
|
|
948
957
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
949
958
|
slateBlockMenu: {
|
|
@@ -943,6 +943,15 @@ const messages = {
|
|
|
943
943
|
resource: {
|
|
944
944
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.',
|
|
945
945
|
},
|
|
946
|
+
primarySchool: 'Hovudskule',
|
|
947
|
+
name: 'Namn',
|
|
948
|
+
mail: 'E-post',
|
|
949
|
+
username: 'Brukarnamn',
|
|
950
|
+
groupTypes: {
|
|
951
|
+
basic: 'Basisgruppe',
|
|
952
|
+
teaching: 'Undervisningsgruppe',
|
|
953
|
+
other: 'Andre grupper',
|
|
954
|
+
},
|
|
946
955
|
},
|
|
947
956
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
948
957
|
slateBlockMenu: {
|
|
@@ -943,6 +943,15 @@ const messages = {
|
|
|
943
943
|
resource: {
|
|
944
944
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.',
|
|
945
945
|
},
|
|
946
|
+
primarySchool: 'Hovudskule',
|
|
947
|
+
name: 'Namn',
|
|
948
|
+
mail: 'E-post',
|
|
949
|
+
username: 'Brukarnamn',
|
|
950
|
+
groupTypes: {
|
|
951
|
+
basic: 'Basisgruppe',
|
|
952
|
+
teaching: 'Undervisningsgruppe',
|
|
953
|
+
other: 'Andre grupper',
|
|
954
|
+
},
|
|
946
955
|
},
|
|
947
956
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
948
957
|
slateBlockMenu: {
|