@ndla/ui 46.0.1 → 46.1.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/Article/Article.js +12 -4
- package/es/Embed/AudioEmbed.js +3 -1
- package/es/RadioButtonGroup/RadioButtonGroup.js +99 -80
- package/es/index.js +0 -1
- package/lib/Article/Article.d.ts +6 -3
- package/lib/Article/Article.js +12 -4
- package/lib/Embed/AudioEmbed.d.ts +2 -1
- package/lib/Embed/AudioEmbed.js +3 -1
- package/lib/Figure/Figure.d.ts +1 -0
- package/lib/RadioButtonGroup/RadioButtonGroup.d.ts +16 -8
- package/lib/RadioButtonGroup/RadioButtonGroup.js +108 -84
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -7
- package/package.json +3 -2
- package/src/Article/Article.tsx +21 -7
- package/src/Embed/AudioEmbed.tsx +3 -2
- package/src/Figure/Figure.tsx +1 -0
- package/src/RadioButtonGroup/RadioButtonGroup.stories.tsx +126 -0
- package/src/RadioButtonGroup/RadioButtonGroup.tsx +137 -104
- package/src/index.ts +0 -10
- package/es/User/UserInfo.js +0 -114
- package/es/User/apiTypes.js +0 -1
- package/es/User/index.js +0 -10
- package/es/User/parseUserObject.js +0 -101
- package/lib/User/UserInfo.d.ts +0 -12
- package/lib/User/UserInfo.js +0 -119
- package/lib/User/apiTypes.d.ts +0 -70
- package/lib/User/apiTypes.js +0 -5
- package/lib/User/index.d.ts +0 -11
- package/lib/User/index.js +0 -12
- package/lib/User/parseUserObject.d.ts +0 -33
- package/lib/User/parseUserObject.js +0 -107
- package/src/User/UserInfo.tsx +0 -101
- package/src/User/__tests__/parseUserObject-test.ts +0 -316
- package/src/User/apiTypes.ts +0 -84
- package/src/User/index.ts +0 -21
- package/src/User/parseUserObject.ts +0 -89
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (c) 2022-present, NDLA.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import groupBy from 'lodash/groupBy';
|
|
21
|
-
/**
|
|
22
|
-
* The keys come from:
|
|
23
|
-
* https://docs.feide.no/reference/apis/groups_api/groups_data_model/primary_and_secondary_education_groups.html?highlight=gogroup#specific-attributes-for-fc-gogroup
|
|
24
|
-
*/
|
|
25
|
-
var goGroupTypeMap = {
|
|
26
|
-
a: 'other',
|
|
27
|
-
b: 'basic',
|
|
28
|
-
u: 'teaching'
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param groups GoGroups to be mapped to specific GoGroupType
|
|
33
|
-
* @returns GoGroups mapped to GoGroupType. basic, teaching and other..
|
|
34
|
-
*/
|
|
35
|
-
var createGroupings = function createGroupings(groups) {
|
|
36
|
-
return groups.reduce(function (acc, curr) {
|
|
37
|
-
var type = goGroupTypeMap[curr.go_type];
|
|
38
|
-
if (!acc[type]) return acc;
|
|
39
|
-
acc[type] = acc[type].concat(curr);
|
|
40
|
-
return acc;
|
|
41
|
-
}, {
|
|
42
|
-
basic: [],
|
|
43
|
-
teaching: [],
|
|
44
|
-
other: []
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param groups GoGroups to be mapped to root/child relations.
|
|
50
|
-
* @returns An object containing root groups mapped with children.
|
|
51
|
-
*/
|
|
52
|
-
var parseOrgs = function parseOrgs(groups) {
|
|
53
|
-
var _groups$reduce = groups.reduce(function (acc, curr) {
|
|
54
|
-
if (curr.type === 'fc:org') {
|
|
55
|
-
return [acc[0].concat(curr), acc[1], acc[2]];
|
|
56
|
-
} else if (curr.type === 'fc:gogroup') {
|
|
57
|
-
return [acc[0], acc[1].concat(curr), acc[2]];
|
|
58
|
-
} else {
|
|
59
|
-
return [acc[0], acc[1], acc[2].concat(curr)];
|
|
60
|
-
}
|
|
61
|
-
}, [[], [], []]),
|
|
62
|
-
_groups$reduce2 = _slicedToArray(_groups$reduce, 3),
|
|
63
|
-
roots = _groups$reduce2[0],
|
|
64
|
-
children = _groups$reduce2[1],
|
|
65
|
-
grep = _groups$reduce2[2];
|
|
66
|
-
var childrenByParentId = groupBy(children, function (c) {
|
|
67
|
-
return c.parent;
|
|
68
|
-
});
|
|
69
|
-
var rootsWithChildren = roots.map(function (root) {
|
|
70
|
-
var _childrenByParentId$r;
|
|
71
|
-
return _objectSpread(_objectSpread({}, root), {}, {
|
|
72
|
-
children: (_childrenByParentId$r = childrenByParentId[root.id]) !== null && _childrenByParentId$r !== void 0 ? _childrenByParentId$r : []
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
grepCodes: grep,
|
|
77
|
-
roots: rootsWithChildren.map(function (root) {
|
|
78
|
-
return _objectSpread(_objectSpread({}, root), {}, {
|
|
79
|
-
children: createGroupings(root.children)
|
|
80
|
-
});
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @param user A user object coming from the API
|
|
87
|
-
* @returns A user object parsed in a presentable way to be handled by i.e UserInfo component.
|
|
88
|
-
*/
|
|
89
|
-
export var parseUserObject = function parseUserObject(user) {
|
|
90
|
-
var _parseOrgs = parseOrgs(user.groups),
|
|
91
|
-
roots = _parseOrgs.roots,
|
|
92
|
-
grepCodes = _parseOrgs.grepCodes;
|
|
93
|
-
return {
|
|
94
|
-
uid: user.uid,
|
|
95
|
-
eduPersonAffiliation: user.eduPersonAffiliation,
|
|
96
|
-
displayName: user.displayName,
|
|
97
|
-
mail: user.mail,
|
|
98
|
-
organizations: roots,
|
|
99
|
-
grepCodes: grepCodes
|
|
100
|
-
};
|
|
101
|
-
};
|
package/lib/User/UserInfo.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
import { FeideUserApiType } from './apiTypes';
|
|
8
|
-
interface Props {
|
|
9
|
-
user: FeideUserApiType;
|
|
10
|
-
}
|
|
11
|
-
export declare const UserInfo: ({ user }: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
package/lib/User/UserInfo.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UserInfo = void 0;
|
|
7
|
-
var _base = _interopRequireDefault(require("@emotion/styled/base"));
|
|
8
|
-
var _core = require("@ndla/core");
|
|
9
|
-
var _reactI18next = require("react-i18next");
|
|
10
|
-
var _parseUserObject = require("./parseUserObject");
|
|
11
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
18
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } /**
|
|
20
|
-
* Copyright (c) 2022-present, NDLA.
|
|
21
|
-
*
|
|
22
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
23
|
-
* LICENSE file in the root directory of this source tree.
|
|
24
|
-
*/
|
|
25
|
-
var InfoList = /*#__PURE__*/(0, _base.default)("ul", {
|
|
26
|
-
target: "egwtjgg1",
|
|
27
|
-
label: "InfoList"
|
|
28
|
-
})("padding:0 0 0 ", _core.spacing.normal, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlVzZXJJbmZvLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFhMEIiLCJmaWxlIjoiVXNlckluZm8udHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIDIwMjItcHJlc2VudCwgTkRMQS5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBHUEx2MyBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTElDRU5TRSBmaWxlIGluIHRoZSByb290IGRpcmVjdG9yeSBvZiB0aGlzIHNvdXJjZSB0cmVlLlxuICovXG5cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCB7IHNwYWNpbmcgfSBmcm9tICdAbmRsYS9jb3JlJztcbmltcG9ydCB7IHVzZVRyYW5zbGF0aW9uIH0gZnJvbSAncmVhY3QtaTE4bmV4dCc7XG5pbXBvcnQgeyBGZWlkZVVzZXJBcGlUeXBlIH0gZnJvbSAnLi9hcGlUeXB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N0PlxuICAgICAgICAgICAgICB7T2JqZWN0LmVudHJpZXMob3JnLmNoaWxkcmVuKS5tYXAoKFtncm91cFR5cGUsIHZhbF0pID0+IHtcbiAgICAgICAgICAgICAgICBpZiAodmFsLmxlbmd0aCA8IDEpIHJldHVybiBudWxsO1xuICAgICAgICAgICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICAgICAgICA8bGkga2V5PXtncm91cFR5cGV9PlxuICAgICAgICAgICAgICAgICAgICB7dChgdXNlci5ncm91cFR5cGVzLiR7Z3JvdXBUeXBlfWApfVxuICAgICAgICAgICAgICAgICAgICA8SW5mb0xpc3Q+XG4gICAgICAgICAgICAgICAgICAgICAge3ZhbC5tYXAoKGdyb3VwKSA9PiAoXG4gICAgICAgICAgICAgICAgICAgICAgICA8bGkga2V5PXtncm91cC5pZH0+e2Ake2dyb3VwLmRpc3BsYXlOYW1lfSR7Z3JvdXAuZ3JlcCA/IGAgKCR7Z3JvdXAuZ3JlcC5jb2RlfSlgIDogJyd9YH08L2xpPlxuICAgICAgICAgICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgICAgICAgICA8L0luZm9MaXN0PlxuICAgICAgICAgICAgICAgICAgPC9saT5cbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICB9KX1cbiAgICAgICAgICAgIDwvSW5mb0xpc3Q+XG4gICAgICAgICAgPC9saT5cbiAgICAgICAgKSl9XG4gICAgICA8L0luZm9MaXN0PlxuICAgICAge3BhcnNlZFVzZXIuZ3JlcENvZGVzLmxlbmd0aCA+IDAgJiYgKFxuICAgICAgICA8SW5mb0xpc3QgZGF0YS1oai1zdXBwcmVzcz5cbiAgICAgICAgICA8bGkga2V5PVwiZ3JlcENvZGVzXCI+XG4gICAgICAgICAgICB7dCgndXNlci5ncm91cFR5cGVzLmdyZXBDb2RlJyl9XG4gICAgICAgICAgICA8SW5mb0xpc3Q+XG4gICAgICAgICAgICAgIHtwYXJzZWRVc2VyLmdyZXBDb2Rlcy5tYXAoKGNvZGUpID0+IChcbiAgICAgICAgICAgICAgICA8bGkga2V5PXtjb2RlLmlkfT57YCR7Y29kZS5kaXNwbGF5TmFtZX0gKCR7Y29kZS5jb2RlfSlgfTwvbGk+XG4gICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgPC9JbmZvTGlzdD5cbiAgICAgICAgICA8L2xpPlxuICAgICAgICA8L0luZm9MaXN0PlxuICAgICAgKX1cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG4iXX0= */"));
|
|
29
|
-
var ShortInfoDiv = /*#__PURE__*/(0, _base.default)("div", {
|
|
30
|
-
target: "egwtjgg0",
|
|
31
|
-
label: "ShortInfoDiv"
|
|
32
|
-
})(process.env.NODE_ENV === "production" ? {
|
|
33
|
-
name: "xsvpxu",
|
|
34
|
-
styles: "margin:2rem auto"
|
|
35
|
-
} : {
|
|
36
|
-
name: "xsvpxu",
|
|
37
|
-
styles: "margin:2rem auto",
|
|
38
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlVzZXJJbmZvLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQitCIiwiZmlsZSI6IlVzZXJJbmZvLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ29weXJpZ2h0IChjKSAyMDIyLXByZXNlbnQsIE5ETEEuXG4gKlxuICogVGhpcyBzb3VyY2UgY29kZSBpcyBsaWNlbnNlZCB1bmRlciB0aGUgR1BMdjMgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqL1xuXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBzcGFjaW5nIH0gZnJvbSAnQG5kbGEvY29yZSc7XG5pbXBvcnQgeyB1c2VUc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9EaXY+XG4gICAgICAgIDxkaXYgZGF0YS1oai1zdXBwcmVzcz5cbiAgICAgICAgICB7dCgndXNlci51c2VybmFtZScpfTogPGI+e3VzZXIudWlkfTwvYj5cbiAgICAgICAgPC9kaXY+XG4gICAgICAgIDxkaXYgZGF0YS1oai1zdXBwcmVzcz5cbiAgICAgICAgICB7dCgndXNlci5uYW1lJyl9OiA8Yj57dXNlci5kaXNwbGF5TmFtZX08L2I+XG4gICAgICAgIDwvZGl2PlxuICAgICAgICA8ZGl2IGRhdGEtaGotc3VwcHJlc3M+XG4gICAgICAgICAge3QoJ3VzZXIubWFpbCcpfTogPGI+e3VzZXIubWFpbD8uam9pbignLCAnKX08L2I+XG4gICAgICAgIDwvZGl2PlxuICAgICAgICB7dXNlci5wcmVmZXJyZWRMYW5ndWFnZSAmJiAoXG4gICAgICAgICAgPGRpdiBkYXRhLWhqLXN1cHByZXNzPlxuICAgICAgICAgICAge3QoJ3VzZXIucHJlZmVycmVkTGFuZ3VhZ2UnKX06IDxiPnt0KGBsYW5ndWFnZXMuJHt1c2VyLnByZWZlcnJlZExhbmd1YWdlfWApfTwvYj5cbiAgICAgICAgICA8L2Rpdj5cbiAgICAgICAgKX1cbiAgICAgICAge3VzZXIubW9iaWxlICYmIChcbiAgICAgICAgICA8ZGl2IGRhdGEtaGotc3VwcHJlc3M+XG4gICAgICAgICAgICB7dCgndXNlci5tb2JpbGUnKX06IDxiPnt1c2VyLm1vYmlsZX08L2I+XG4gICAgICAgICAgPC9kaXY+XG4gICAgICAgICl9XG4gICAgICA8L1Nob3J0SW5mb0Rpdj5cblxuICAgICAgPEluZm9MaXN0IGRhdGEtaGotc3VwcHJlc3M+XG4gICAgICAgIHtwYXJzZWRVc2VyLm9yZ2FuaXphdGlvbnMubWFwKChvcmcpID0+IChcbiAgICAgICAgICA8bGkga2V5PXtvcmcuaWR9PlxuICAgICAgICAgICAge2Ake29yZy5kaXNwbGF5TmFtZX0ke29yZy5tZW1iZXJzaGlwLnByaW1hcnlTY2hvb2wgPyBgICgke3QoJ3VzZXIucHJpbWFyeVNjaG9vbCcpfSlgIDogJyd9YH1cbiAgICAgICAgICAgIDxJbmZvTGlzdD5cbiAgICAgICAgICAgICAge09iamVjdC5lbnRyaWVzKG9yZy5jaGlsZHJlbikubWFwKChbZ3JvdXBUeXBlLCB2YWxdKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKHZhbC5sZW5ndGggPCAxKSByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgICAgICAgPGxpIGtleT17Z3JvdXBUeXBlfT5cbiAgICAgICAgICAgICAgICAgICAge3QoYHVzZXIuZ3JvdXBUeXBlcy4ke2dyb3VwVHlwZX1gKX1cbiAgICAgICAgICAgICAgICAgICAgPEluZm9MaXN0PlxuICAgICAgICAgICAgICAgICAgICAgIHt2YWwubWFwKChncm91cCkgPT4gKFxuICAgICAgICAgICAgICAgICAgICAgICAgPGxpIGtleT17Z3JvdXAuaWR9PntgJHtncm91cC5kaXNwbGF5TmFtZX0ke2dyb3VwLmdyZXAgPyBgICgke2dyb3VwLmdyZXAuY29kZX0pYCA6ICcnfWB9PC9saT5cbiAgICAgICAgICAgICAgICAgICAgICApKX1cbiAgICAgICAgICAgICAgICAgICAgPC9JbmZvTGlzdD5cbiAgICAgICAgICAgICAgICAgIDwvbGk+XG4gICAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgfSl9XG4gICAgICAgICAgICA8L0luZm9MaXN0PlxuICAgICAgICAgIDwvbGk+XG4gICAgICAgICkpfVxuICAgICAgPC9JbmZvTGlzdD5cbiAgICAgIHtwYXJzZWRVc2VyLmdyZXBDb2Rlcy5sZW5ndGggPiAwICYmIChcbiAgICAgICAgPEluZm9MaXN0IGRhdGEtaGotc3VwcHJlc3M+XG4gICAgICAgICAgPGxpIGtleT1cImdyZXBDb2Rlc1wiPlxuICAgICAgICAgICAge3QoJ3VzZXIuZ3JvdXBUeXBlcy5ncmVwQ29kZScpfVxuICAgICAgICAgICAgPEluZm9MaXN0PlxuICAgICAgICAgICAgICB7cGFyc2VkVXNlci5ncmVwQ29kZXMubWFwKChjb2RlKSA9PiAoXG4gICAgICAgICAgICAgICAgPGxpIGtleT17Y29kZS5pZH0+e2Ake2NvZGUuZGlzcGxheU5hbWV9ICgke2NvZGUuY29kZX0pYH08L2xpPlxuICAgICAgICAgICAgICApKX1cbiAgICAgICAgICAgIDwvSW5mb0xpc3Q+XG4gICAgICAgICAgPC9saT5cbiAgICAgICAgPC9JbmZvTGlzdD5cbiAgICAgICl9XG4gICAgPC9kaXY+XG4gICk7XG59O1xuIl19 */",
|
|
39
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
40
|
-
});
|
|
41
|
-
var isTeacher = function isTeacher(affiliations) {
|
|
42
|
-
return affiliations.includes('employee');
|
|
43
|
-
};
|
|
44
|
-
var UserInfo = function UserInfo(_ref) {
|
|
45
|
-
var _user$mail;
|
|
46
|
-
var user = _ref.user;
|
|
47
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
48
|
-
t = _useTranslation.t;
|
|
49
|
-
var parsedUser = (0, _parseUserObject.parseUserObject)(user);
|
|
50
|
-
return (0, _jsxRuntime.jsxs)("div", {
|
|
51
|
-
children: [(0, _jsxRuntime.jsx)("p", {
|
|
52
|
-
children: t('user.loggedInAs', {
|
|
53
|
-
role: t("user.role.".concat(isTeacher(parsedUser.eduPersonAffiliation) ? 'employee' : 'student'))
|
|
54
|
-
})
|
|
55
|
-
}), (0, _jsxRuntime.jsxs)(ShortInfoDiv, {
|
|
56
|
-
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
57
|
-
"data-hj-suppress": true,
|
|
58
|
-
children: [t('user.username'), ": ", (0, _jsxRuntime.jsx)("b", {
|
|
59
|
-
children: user.uid
|
|
60
|
-
})]
|
|
61
|
-
}), (0, _jsxRuntime.jsxs)("div", {
|
|
62
|
-
"data-hj-suppress": true,
|
|
63
|
-
children: [t('user.name'), ": ", (0, _jsxRuntime.jsx)("b", {
|
|
64
|
-
children: user.displayName
|
|
65
|
-
})]
|
|
66
|
-
}), (0, _jsxRuntime.jsxs)("div", {
|
|
67
|
-
"data-hj-suppress": true,
|
|
68
|
-
children: [t('user.mail'), ": ", (0, _jsxRuntime.jsx)("b", {
|
|
69
|
-
children: (_user$mail = user.mail) === null || _user$mail === void 0 ? void 0 : _user$mail.join(', ')
|
|
70
|
-
})]
|
|
71
|
-
}), user.preferredLanguage && (0, _jsxRuntime.jsxs)("div", {
|
|
72
|
-
"data-hj-suppress": true,
|
|
73
|
-
children: [t('user.preferredLanguage'), ": ", (0, _jsxRuntime.jsx)("b", {
|
|
74
|
-
children: t("languages.".concat(user.preferredLanguage))
|
|
75
|
-
})]
|
|
76
|
-
}), user.mobile && (0, _jsxRuntime.jsxs)("div", {
|
|
77
|
-
"data-hj-suppress": true,
|
|
78
|
-
children: [t('user.mobile'), ": ", (0, _jsxRuntime.jsx)("b", {
|
|
79
|
-
children: user.mobile
|
|
80
|
-
})]
|
|
81
|
-
})]
|
|
82
|
-
}), (0, _jsxRuntime.jsx)(InfoList, {
|
|
83
|
-
"data-hj-suppress": true,
|
|
84
|
-
children: parsedUser.organizations.map(function (org) {
|
|
85
|
-
return (0, _jsxRuntime.jsxs)("li", {
|
|
86
|
-
children: ["".concat(org.displayName).concat(org.membership.primarySchool ? " (".concat(t('user.primarySchool'), ")") : ''), (0, _jsxRuntime.jsx)(InfoList, {
|
|
87
|
-
children: Object.entries(org.children).map(function (_ref2) {
|
|
88
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
89
|
-
groupType = _ref3[0],
|
|
90
|
-
val = _ref3[1];
|
|
91
|
-
if (val.length < 1) return null;
|
|
92
|
-
return (0, _jsxRuntime.jsxs)("li", {
|
|
93
|
-
children: [t("user.groupTypes.".concat(groupType)), (0, _jsxRuntime.jsx)(InfoList, {
|
|
94
|
-
children: val.map(function (group) {
|
|
95
|
-
return (0, _jsxRuntime.jsx)("li", {
|
|
96
|
-
children: "".concat(group.displayName).concat(group.grep ? " (".concat(group.grep.code, ")") : '')
|
|
97
|
-
}, group.id);
|
|
98
|
-
})
|
|
99
|
-
})]
|
|
100
|
-
}, groupType);
|
|
101
|
-
})
|
|
102
|
-
})]
|
|
103
|
-
}, org.id);
|
|
104
|
-
})
|
|
105
|
-
}), parsedUser.grepCodes.length > 0 && (0, _jsxRuntime.jsx)(InfoList, {
|
|
106
|
-
"data-hj-suppress": true,
|
|
107
|
-
children: (0, _jsxRuntime.jsxs)("li", {
|
|
108
|
-
children: [t('user.groupTypes.grepCode'), (0, _jsxRuntime.jsx)(InfoList, {
|
|
109
|
-
children: parsedUser.grepCodes.map(function (code) {
|
|
110
|
-
return (0, _jsxRuntime.jsx)("li", {
|
|
111
|
-
children: "".concat(code.displayName, " (").concat(code.code, ")")
|
|
112
|
-
}, code.id);
|
|
113
|
-
})
|
|
114
|
-
})]
|
|
115
|
-
}, "grepCodes")
|
|
116
|
-
})]
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
exports.UserInfo = UserInfo;
|
package/lib/User/apiTypes.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
type OrgType = 'higher_education' | 'primary_and_lower_secondary' | 'primary_and_lower_secondary_owner' | 'upper_secondary' | 'upper_secondary_owner';
|
|
9
|
-
export type AffiliationType = 'member' | 'student' | 'faculty' | 'staff' | 'affiliate' | 'employee';
|
|
10
|
-
export interface FeideMembershipType {
|
|
11
|
-
basic: 'member' | 'admin' | 'owner';
|
|
12
|
-
affiliation?: AffiliationType[];
|
|
13
|
-
primarySchool?: boolean;
|
|
14
|
-
primaryAffiliation?: AffiliationType;
|
|
15
|
-
displayName?: string;
|
|
16
|
-
}
|
|
17
|
-
interface FeideBaseGroup {
|
|
18
|
-
id: string;
|
|
19
|
-
type: 'fc:org' | 'fc:gogroup' | 'fc:grep';
|
|
20
|
-
displayName: string;
|
|
21
|
-
membership: FeideMembershipType;
|
|
22
|
-
}
|
|
23
|
-
export interface FeideOrg extends FeideBaseGroup {
|
|
24
|
-
type: 'fc:org';
|
|
25
|
-
orgType: OrgType[];
|
|
26
|
-
norEduOrgNIN?: string;
|
|
27
|
-
eduOrgLegalName?: string;
|
|
28
|
-
mail?: string;
|
|
29
|
-
parent?: string;
|
|
30
|
-
public: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface FeideGoGroup extends FeideBaseGroup {
|
|
33
|
-
type: 'fc:gogroup';
|
|
34
|
-
notBefore: string;
|
|
35
|
-
notAfter: string;
|
|
36
|
-
go_type: 'b' | 'u' | 'a';
|
|
37
|
-
parent: string;
|
|
38
|
-
go_type_displayName: string;
|
|
39
|
-
grep?: {
|
|
40
|
-
displayName: string;
|
|
41
|
-
code: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export interface FeideGrep extends FeideBaseGroup {
|
|
45
|
-
type: 'fc:grep';
|
|
46
|
-
code: string;
|
|
47
|
-
grep_type: 'aarstrinn' | 'fagkoder';
|
|
48
|
-
public: boolean;
|
|
49
|
-
}
|
|
50
|
-
export type FeideGroup = FeideOrg | FeideGoGroup | FeideGrep;
|
|
51
|
-
export interface FeideUser {
|
|
52
|
-
cn: string[];
|
|
53
|
-
displayName: string;
|
|
54
|
-
eduPersonAffiliation: AffiliationType[];
|
|
55
|
-
eduPersonPrimaryAffiliation: AffiliationType;
|
|
56
|
-
eduPersonPrincipalName: string;
|
|
57
|
-
givenName: string[];
|
|
58
|
-
mail?: string[];
|
|
59
|
-
schacHomeOrganization?: string;
|
|
60
|
-
sn: string[];
|
|
61
|
-
uid: string[];
|
|
62
|
-
preferredLanguage?: string;
|
|
63
|
-
mobile?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface FeideUserApiType extends FeideUser {
|
|
66
|
-
groups: FeideGroup[];
|
|
67
|
-
primarySchool?: FeideGroup;
|
|
68
|
-
baseOrg?: FeideGroup;
|
|
69
|
-
}
|
|
70
|
-
export {};
|
package/lib/User/apiTypes.js
DELETED
package/lib/User/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2021-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 { UserInfo } from './UserInfo';
|
|
9
|
-
import type { AffiliationType, FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser } from './apiTypes';
|
|
10
|
-
export { UserInfo };
|
|
11
|
-
export type { AffiliationType, FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser };
|
package/lib/User/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "UserInfo", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _UserInfo.UserInfo;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _UserInfo = require("./UserInfo");
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
import { FeideGoGroup, FeideGrep, FeideUserApiType } from './apiTypes';
|
|
8
|
-
type GoGroupType = 'basic' | 'teaching' | 'other';
|
|
9
|
-
/**
|
|
10
|
-
* @param user A user object coming from the API
|
|
11
|
-
* @returns A user object parsed in a presentable way to be handled by i.e UserInfo component.
|
|
12
|
-
*/
|
|
13
|
-
export declare const parseUserObject: (user: FeideUserApiType) => {
|
|
14
|
-
uid: string[];
|
|
15
|
-
eduPersonAffiliation: import("./apiTypes").AffiliationType[];
|
|
16
|
-
displayName: string;
|
|
17
|
-
mail: string[] | undefined;
|
|
18
|
-
organizations: {
|
|
19
|
-
children: Record<GoGroupType, FeideGoGroup[]>;
|
|
20
|
-
type: "fc:org";
|
|
21
|
-
orgType: ("higher_education" | "primary_and_lower_secondary" | "primary_and_lower_secondary_owner" | "upper_secondary" | "upper_secondary_owner")[];
|
|
22
|
-
norEduOrgNIN?: string | undefined;
|
|
23
|
-
eduOrgLegalName?: string | undefined;
|
|
24
|
-
mail?: string | undefined;
|
|
25
|
-
parent?: string | undefined;
|
|
26
|
-
public: boolean;
|
|
27
|
-
id: string;
|
|
28
|
-
displayName: string;
|
|
29
|
-
membership: import("./apiTypes").FeideMembershipType;
|
|
30
|
-
}[];
|
|
31
|
-
grepCodes: FeideGrep[];
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.parseUserObject = void 0;
|
|
8
|
-
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
|
|
21
|
-
* Copyright (c) 2022-present, NDLA.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* The keys come from:
|
|
28
|
-
* https://docs.feide.no/reference/apis/groups_api/groups_data_model/primary_and_secondary_education_groups.html?highlight=gogroup#specific-attributes-for-fc-gogroup
|
|
29
|
-
*/
|
|
30
|
-
var goGroupTypeMap = {
|
|
31
|
-
a: 'other',
|
|
32
|
-
b: 'basic',
|
|
33
|
-
u: 'teaching'
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param groups GoGroups to be mapped to specific GoGroupType
|
|
38
|
-
* @returns GoGroups mapped to GoGroupType. basic, teaching and other..
|
|
39
|
-
*/
|
|
40
|
-
var createGroupings = function createGroupings(groups) {
|
|
41
|
-
return groups.reduce(function (acc, curr) {
|
|
42
|
-
var type = goGroupTypeMap[curr.go_type];
|
|
43
|
-
if (!acc[type]) return acc;
|
|
44
|
-
acc[type] = acc[type].concat(curr);
|
|
45
|
-
return acc;
|
|
46
|
-
}, {
|
|
47
|
-
basic: [],
|
|
48
|
-
teaching: [],
|
|
49
|
-
other: []
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param groups GoGroups to be mapped to root/child relations.
|
|
55
|
-
* @returns An object containing root groups mapped with children.
|
|
56
|
-
*/
|
|
57
|
-
var parseOrgs = function parseOrgs(groups) {
|
|
58
|
-
var _groups$reduce = groups.reduce(function (acc, curr) {
|
|
59
|
-
if (curr.type === 'fc:org') {
|
|
60
|
-
return [acc[0].concat(curr), acc[1], acc[2]];
|
|
61
|
-
} else if (curr.type === 'fc:gogroup') {
|
|
62
|
-
return [acc[0], acc[1].concat(curr), acc[2]];
|
|
63
|
-
} else {
|
|
64
|
-
return [acc[0], acc[1], acc[2].concat(curr)];
|
|
65
|
-
}
|
|
66
|
-
}, [[], [], []]),
|
|
67
|
-
_groups$reduce2 = _slicedToArray(_groups$reduce, 3),
|
|
68
|
-
roots = _groups$reduce2[0],
|
|
69
|
-
children = _groups$reduce2[1],
|
|
70
|
-
grep = _groups$reduce2[2];
|
|
71
|
-
var childrenByParentId = (0, _groupBy.default)(children, function (c) {
|
|
72
|
-
return c.parent;
|
|
73
|
-
});
|
|
74
|
-
var rootsWithChildren = roots.map(function (root) {
|
|
75
|
-
var _childrenByParentId$r;
|
|
76
|
-
return _objectSpread(_objectSpread({}, root), {}, {
|
|
77
|
-
children: (_childrenByParentId$r = childrenByParentId[root.id]) !== null && _childrenByParentId$r !== void 0 ? _childrenByParentId$r : []
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
grepCodes: grep,
|
|
82
|
-
roots: rootsWithChildren.map(function (root) {
|
|
83
|
-
return _objectSpread(_objectSpread({}, root), {}, {
|
|
84
|
-
children: createGroupings(root.children)
|
|
85
|
-
});
|
|
86
|
-
})
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @param user A user object coming from the API
|
|
92
|
-
* @returns A user object parsed in a presentable way to be handled by i.e UserInfo component.
|
|
93
|
-
*/
|
|
94
|
-
var parseUserObject = function parseUserObject(user) {
|
|
95
|
-
var _parseOrgs = parseOrgs(user.groups),
|
|
96
|
-
roots = _parseOrgs.roots,
|
|
97
|
-
grepCodes = _parseOrgs.grepCodes;
|
|
98
|
-
return {
|
|
99
|
-
uid: user.uid,
|
|
100
|
-
eduPersonAffiliation: user.eduPersonAffiliation,
|
|
101
|
-
displayName: user.displayName,
|
|
102
|
-
mail: user.mail,
|
|
103
|
-
organizations: roots,
|
|
104
|
-
grepCodes: grepCodes
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
exports.parseUserObject = parseUserObject;
|
package/src/User/UserInfo.tsx
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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 styled from '@emotion/styled';
|
|
9
|
-
import { spacing } from '@ndla/core';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import { FeideUserApiType } from './apiTypes';
|
|
12
|
-
import { parseUserObject } from './parseUserObject';
|
|
13
|
-
|
|
14
|
-
const InfoList = styled.ul`
|
|
15
|
-
padding: 0 0 0 ${spacing.normal};
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
interface Props {
|
|
19
|
-
user: FeideUserApiType;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ShortInfoDiv = styled.div`
|
|
23
|
-
margin: 2rem auto;
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const isTeacher = (affiliations: FeideUserApiType['eduPersonAffiliation']) => affiliations.includes('employee');
|
|
27
|
-
|
|
28
|
-
export const UserInfo = ({ user }: Props) => {
|
|
29
|
-
const { t } = useTranslation();
|
|
30
|
-
|
|
31
|
-
const parsedUser = parseUserObject(user);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
{
|
|
36
|
-
<p>
|
|
37
|
-
{t('user.loggedInAs', {
|
|
38
|
-
role: t(`user.role.${isTeacher(parsedUser.eduPersonAffiliation) ? 'employee' : 'student'}`),
|
|
39
|
-
})}
|
|
40
|
-
</p>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
<ShortInfoDiv>
|
|
44
|
-
<div data-hj-suppress>
|
|
45
|
-
{t('user.username')}: <b>{user.uid}</b>
|
|
46
|
-
</div>
|
|
47
|
-
<div data-hj-suppress>
|
|
48
|
-
{t('user.name')}: <b>{user.displayName}</b>
|
|
49
|
-
</div>
|
|
50
|
-
<div data-hj-suppress>
|
|
51
|
-
{t('user.mail')}: <b>{user.mail?.join(', ')}</b>
|
|
52
|
-
</div>
|
|
53
|
-
{user.preferredLanguage && (
|
|
54
|
-
<div data-hj-suppress>
|
|
55
|
-
{t('user.preferredLanguage')}: <b>{t(`languages.${user.preferredLanguage}`)}</b>
|
|
56
|
-
</div>
|
|
57
|
-
)}
|
|
58
|
-
{user.mobile && (
|
|
59
|
-
<div data-hj-suppress>
|
|
60
|
-
{t('user.mobile')}: <b>{user.mobile}</b>
|
|
61
|
-
</div>
|
|
62
|
-
)}
|
|
63
|
-
</ShortInfoDiv>
|
|
64
|
-
|
|
65
|
-
<InfoList data-hj-suppress>
|
|
66
|
-
{parsedUser.organizations.map((org) => (
|
|
67
|
-
<li key={org.id}>
|
|
68
|
-
{`${org.displayName}${org.membership.primarySchool ? ` (${t('user.primarySchool')})` : ''}`}
|
|
69
|
-
<InfoList>
|
|
70
|
-
{Object.entries(org.children).map(([groupType, val]) => {
|
|
71
|
-
if (val.length < 1) return null;
|
|
72
|
-
return (
|
|
73
|
-
<li key={groupType}>
|
|
74
|
-
{t(`user.groupTypes.${groupType}`)}
|
|
75
|
-
<InfoList>
|
|
76
|
-
{val.map((group) => (
|
|
77
|
-
<li key={group.id}>{`${group.displayName}${group.grep ? ` (${group.grep.code})` : ''}`}</li>
|
|
78
|
-
))}
|
|
79
|
-
</InfoList>
|
|
80
|
-
</li>
|
|
81
|
-
);
|
|
82
|
-
})}
|
|
83
|
-
</InfoList>
|
|
84
|
-
</li>
|
|
85
|
-
))}
|
|
86
|
-
</InfoList>
|
|
87
|
-
{parsedUser.grepCodes.length > 0 && (
|
|
88
|
-
<InfoList data-hj-suppress>
|
|
89
|
-
<li key="grepCodes">
|
|
90
|
-
{t('user.groupTypes.grepCode')}
|
|
91
|
-
<InfoList>
|
|
92
|
-
{parsedUser.grepCodes.map((code) => (
|
|
93
|
-
<li key={code.id}>{`${code.displayName} (${code.code})`}</li>
|
|
94
|
-
))}
|
|
95
|
-
</InfoList>
|
|
96
|
-
</li>
|
|
97
|
-
</InfoList>
|
|
98
|
-
)}
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|