@ndla/ui 13.2.0 → 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/Notion/ConceptNotion.js +2 -1
- package/es/Notion/FigureNotion.js +14 -10
- package/es/Notion/NotionVisualElement.js +3 -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/SearchTypeResult/SearchViewType.js +5 -5
- 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 +13 -4
- package/es/locale/messages-nb.js +13 -4
- package/es/locale/messages-nn.js +13 -4
- package/es/locale/messages-se.js +13 -4
- package/es/locale/messages-sma.js +13 -4
- 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/Notion/ConceptNotion.js +2 -1
- package/lib/Notion/FigureNotion.d.ts +1 -1
- package/lib/Notion/FigureNotion.js +13 -9
- package/lib/Notion/NotionVisualElement.js +3 -2
- 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/SearchTypeResult/SearchViewType.js +5 -5
- 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 +13 -4
- package/lib/locale/messages-nb.d.ts +9 -0
- package/lib/locale/messages-nb.js +13 -4
- package/lib/locale/messages-nn.d.ts +9 -0
- package/lib/locale/messages-nn.js +13 -4
- package/lib/locale/messages-se.d.ts +9 -0
- package/lib/locale/messages-se.js +13 -4
- package/lib/locale/messages-sma.d.ts +9 -0
- package/lib/locale/messages-sma.js +13 -4
- 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/Notion/ConceptNotion.tsx +1 -0
- package/src/Notion/FigureNotion.tsx +13 -6
- package/src/Notion/NotionVisualElement.tsx +1 -1
- 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/SearchTypeResult/SearchViewType.tsx +1 -1
- 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 +13 -4
- package/src/locale/messages-nb.ts +13 -4
- package/src/locale/messages-nn.ts +13 -4
- package/src/locale/messages-se.ts +13 -4
- package/src/locale/messages-sma.ts +13 -4
package/lib/User/index.d.ts
CHANGED
|
@@ -6,4 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import AuthModal from './AuthModal';
|
|
9
|
+
import { UserInfo } from './UserInfo';
|
|
10
|
+
import type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType } from './apiTypes';
|
|
11
|
+
export { UserInfo };
|
|
12
|
+
export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType };
|
|
9
13
|
export default AuthModal;
|
package/lib/User/index.js
CHANGED
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "UserInfo", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _UserInfo.UserInfo;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
exports["default"] = void 0;
|
|
7
13
|
|
|
8
14
|
var _AuthModal = _interopRequireDefault(require("./AuthModal"));
|
|
9
15
|
|
|
16
|
+
var _UserInfo = require("./UserInfo");
|
|
17
|
+
|
|
10
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
19
|
|
|
12
20
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
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, FeideUserApiType } from './apiTypes';
|
|
8
|
+
declare 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
|
+
primaryAffiliation: string;
|
|
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
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseUserObject = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
|
|
18
|
+
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."); }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
+
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The keys come from:
|
|
30
|
+
* https://docs.feide.no/reference/apis/groups_api/groups_data_model/primary_and_secondary_education_groups.html?highlight=gogroup#specific-attributes-for-fc-gogroup
|
|
31
|
+
*/
|
|
32
|
+
var goGroupTypeMap = {
|
|
33
|
+
a: 'other',
|
|
34
|
+
b: 'basic',
|
|
35
|
+
u: 'teaching'
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @param groups GoGroups to be mapped to specific GoGroupType
|
|
39
|
+
* @returns GoGroups mapped to GoGroupType. basic, teaching and other..
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
var createGroupings = function createGroupings(groups) {
|
|
43
|
+
return groups.reduce(function (acc, curr) {
|
|
44
|
+
var type = goGroupTypeMap[curr.go_type];
|
|
45
|
+
if (!acc[type]) return acc;
|
|
46
|
+
acc[type] = acc[type].concat(curr);
|
|
47
|
+
return acc;
|
|
48
|
+
}, {
|
|
49
|
+
basic: [],
|
|
50
|
+
teaching: [],
|
|
51
|
+
other: []
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* @param groups GoGroups to be mapped to root/child relations.
|
|
56
|
+
* @returns An object containing root groups mapped with children.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var parseOrgs = function parseOrgs(groups) {
|
|
61
|
+
var _groups$reduce = groups.reduce(function (acc, curr) {
|
|
62
|
+
if (curr.type === 'fc:org') {
|
|
63
|
+
return [acc[0].concat(curr), acc[1]];
|
|
64
|
+
} else {
|
|
65
|
+
return [acc[0], acc[1].concat(curr)];
|
|
66
|
+
}
|
|
67
|
+
}, [[], []]),
|
|
68
|
+
_groups$reduce2 = _slicedToArray(_groups$reduce, 2),
|
|
69
|
+
roots = _groups$reduce2[0],
|
|
70
|
+
children = _groups$reduce2[1];
|
|
71
|
+
|
|
72
|
+
var childrenByParentId = (0, _lodash.groupBy)(children, function (c) {
|
|
73
|
+
return c.parent;
|
|
74
|
+
});
|
|
75
|
+
var rootsWithChildren = roots.map(function (root) {
|
|
76
|
+
var _childrenByParentId$r;
|
|
77
|
+
|
|
78
|
+
return _objectSpread(_objectSpread({}, root), {}, {
|
|
79
|
+
children: (_childrenByParentId$r = childrenByParentId[root.id]) !== null && _childrenByParentId$r !== void 0 ? _childrenByParentId$r : []
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return rootsWithChildren.map(function (root) {
|
|
83
|
+
return _objectSpread(_objectSpread({}, root), {}, {
|
|
84
|
+
children: createGroupings(root.children)
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @param user A user object coming from the API
|
|
90
|
+
* @returns A user object parsed in a presentable way to be handled by i.e UserInfo component.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
var parseUserObject = function parseUserObject(user) {
|
|
95
|
+
var orgs = parseOrgs(user.groups);
|
|
96
|
+
return {
|
|
97
|
+
uid: user.uid,
|
|
98
|
+
primaryAffiliation: user.eduPersonPrimaryAffiliation,
|
|
99
|
+
displayName: user.displayName,
|
|
100
|
+
mail: user.mail,
|
|
101
|
+
organizations: orgs
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
exports.parseUserObject = parseUserObject;
|