@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
package/lib/index.d.ts
CHANGED
|
@@ -37,7 +37,9 @@ export { default as ContentTypeResult } from './Search/ContentTypeResult';
|
|
|
37
37
|
export { SearchFieldForm } from './Search/SearchFieldForm';
|
|
38
38
|
export { default as MastheadSearchModal } from './Masthead/MastheadSearchModal';
|
|
39
39
|
export { default as MastheadAuthModal } from './Masthead/MastheadAuthModal';
|
|
40
|
+
export { UserInfo } from './User';
|
|
40
41
|
export { default as AuthModal } from './User';
|
|
42
|
+
export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType } from './User';
|
|
41
43
|
export { default as CreatedBy } from './CreatedBy';
|
|
42
44
|
export { default as Breadcrumblist } from './Breadcrumblist';
|
|
43
45
|
export { MessageBox, MessageBoxTag, MessageBoxType } from './MessageBox';
|
package/lib/index.js
CHANGED
|
@@ -87,6 +87,7 @@ var _exportNames = {
|
|
|
87
87
|
SearchFieldForm: true,
|
|
88
88
|
MastheadSearchModal: true,
|
|
89
89
|
MastheadAuthModal: true,
|
|
90
|
+
UserInfo: true,
|
|
90
91
|
AuthModal: true,
|
|
91
92
|
CreatedBy: true,
|
|
92
93
|
Breadcrumblist: true,
|
|
@@ -665,6 +666,12 @@ Object.defineProperty(exports, "MastheadAuthModal", {
|
|
|
665
666
|
return _MastheadAuthModal["default"];
|
|
666
667
|
}
|
|
667
668
|
});
|
|
669
|
+
Object.defineProperty(exports, "UserInfo", {
|
|
670
|
+
enumerable: true,
|
|
671
|
+
get: function get() {
|
|
672
|
+
return _User.UserInfo;
|
|
673
|
+
}
|
|
674
|
+
});
|
|
668
675
|
Object.defineProperty(exports, "AuthModal", {
|
|
669
676
|
enumerable: true,
|
|
670
677
|
get: function get() {
|
|
@@ -1285,7 +1292,7 @@ var _MastheadSearchModal = _interopRequireDefault(require("./Masthead/MastheadSe
|
|
|
1285
1292
|
|
|
1286
1293
|
var _MastheadAuthModal = _interopRequireDefault(require("./Masthead/MastheadAuthModal"));
|
|
1287
1294
|
|
|
1288
|
-
var _User =
|
|
1295
|
+
var _User = _interopRequireWildcard(require("./User"));
|
|
1289
1296
|
|
|
1290
1297
|
var _CreatedBy = _interopRequireDefault(require("./CreatedBy"));
|
|
1291
1298
|
|
|
@@ -33,6 +33,15 @@ declare const messages: {
|
|
|
33
33
|
resource: {
|
|
34
34
|
accessDenied: string;
|
|
35
35
|
};
|
|
36
|
+
primarySchool: string;
|
|
37
|
+
name: string;
|
|
38
|
+
mail: string;
|
|
39
|
+
username: string;
|
|
40
|
+
groupTypes: {
|
|
41
|
+
basic: string;
|
|
42
|
+
teaching: string;
|
|
43
|
+
other: string;
|
|
44
|
+
};
|
|
36
45
|
};
|
|
37
46
|
checkOutNewFeature: string;
|
|
38
47
|
slateBlockMenu: {
|
|
@@ -906,6 +906,15 @@ var messages = _objectSpread(_objectSpread({
|
|
|
906
906
|
},
|
|
907
907
|
resource: {
|
|
908
908
|
accessDenied: 'We are sorry, but this resource is only available to teachers who are logged in with Feide.'
|
|
909
|
+
},
|
|
910
|
+
primarySchool: 'Primary School',
|
|
911
|
+
name: 'Name',
|
|
912
|
+
mail: 'E-mail',
|
|
913
|
+
username: 'Username',
|
|
914
|
+
groupTypes: {
|
|
915
|
+
basic: 'Basic group',
|
|
916
|
+
teaching: 'Teaching group',
|
|
917
|
+
other: 'Other groups'
|
|
909
918
|
}
|
|
910
919
|
},
|
|
911
920
|
checkOutNewFeature: 'New feature',
|
|
@@ -33,6 +33,15 @@ declare const messages: {
|
|
|
33
33
|
resource: {
|
|
34
34
|
accessDenied: string;
|
|
35
35
|
};
|
|
36
|
+
primarySchool: string;
|
|
37
|
+
name: string;
|
|
38
|
+
mail: string;
|
|
39
|
+
username: string;
|
|
40
|
+
groupTypes: {
|
|
41
|
+
basic: string;
|
|
42
|
+
teaching: string;
|
|
43
|
+
other: string;
|
|
44
|
+
};
|
|
36
45
|
};
|
|
37
46
|
checkOutNewFeature: string;
|
|
38
47
|
slateBlockMenu: {
|
|
@@ -906,6 +906,15 @@ var messages = _objectSpread(_objectSpread({
|
|
|
906
906
|
},
|
|
907
907
|
resource: {
|
|
908
908
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.'
|
|
909
|
+
},
|
|
910
|
+
primarySchool: 'Hovedskole',
|
|
911
|
+
name: 'Navn',
|
|
912
|
+
mail: 'E-post',
|
|
913
|
+
username: 'Brukernavn',
|
|
914
|
+
groupTypes: {
|
|
915
|
+
basic: 'Basisgruppe',
|
|
916
|
+
teaching: 'Undervisningsgruppe',
|
|
917
|
+
other: 'Andre grupper'
|
|
909
918
|
}
|
|
910
919
|
},
|
|
911
920
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
@@ -33,6 +33,15 @@ declare const messages: {
|
|
|
33
33
|
resource: {
|
|
34
34
|
accessDenied: string;
|
|
35
35
|
};
|
|
36
|
+
primarySchool: string;
|
|
37
|
+
name: string;
|
|
38
|
+
mail: string;
|
|
39
|
+
username: string;
|
|
40
|
+
groupTypes: {
|
|
41
|
+
basic: string;
|
|
42
|
+
teaching: string;
|
|
43
|
+
other: string;
|
|
44
|
+
};
|
|
36
45
|
};
|
|
37
46
|
checkOutNewFeature: string;
|
|
38
47
|
slateBlockMenu: {
|
|
@@ -906,6 +906,15 @@ var messages = _objectSpread(_objectSpread({
|
|
|
906
906
|
},
|
|
907
907
|
resource: {
|
|
908
908
|
accessDenied: 'Vi beklagar, men denne ressursen er berre for lærarar innlogga med Feide.'
|
|
909
|
+
},
|
|
910
|
+
primarySchool: 'Hovudskule',
|
|
911
|
+
name: 'Namn',
|
|
912
|
+
mail: 'E-post',
|
|
913
|
+
username: 'Brukarnamn',
|
|
914
|
+
groupTypes: {
|
|
915
|
+
basic: 'Basisgruppe',
|
|
916
|
+
teaching: 'Undervisningsgruppe',
|
|
917
|
+
other: 'Andre grupper'
|
|
909
918
|
}
|
|
910
919
|
},
|
|
911
920
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
@@ -33,6 +33,15 @@ declare const messages: {
|
|
|
33
33
|
resource: {
|
|
34
34
|
accessDenied: string;
|
|
35
35
|
};
|
|
36
|
+
primarySchool: string;
|
|
37
|
+
name: string;
|
|
38
|
+
mail: string;
|
|
39
|
+
username: string;
|
|
40
|
+
groupTypes: {
|
|
41
|
+
basic: string;
|
|
42
|
+
teaching: string;
|
|
43
|
+
other: string;
|
|
44
|
+
};
|
|
36
45
|
};
|
|
37
46
|
checkOutNewFeature: string;
|
|
38
47
|
slateBlockMenu: {
|
|
@@ -906,6 +906,15 @@ var messages = _objectSpread(_objectSpread({
|
|
|
906
906
|
},
|
|
907
907
|
resource: {
|
|
908
908
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.'
|
|
909
|
+
},
|
|
910
|
+
primarySchool: 'Hovudskule',
|
|
911
|
+
name: 'Namn',
|
|
912
|
+
mail: 'E-post',
|
|
913
|
+
username: 'Brukarnamn',
|
|
914
|
+
groupTypes: {
|
|
915
|
+
basic: 'Basisgruppe',
|
|
916
|
+
teaching: 'Undervisningsgruppe',
|
|
917
|
+
other: 'Andre grupper'
|
|
909
918
|
}
|
|
910
919
|
},
|
|
911
920
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
|
@@ -33,6 +33,15 @@ declare const messages: {
|
|
|
33
33
|
resource: {
|
|
34
34
|
accessDenied: string;
|
|
35
35
|
};
|
|
36
|
+
primarySchool: string;
|
|
37
|
+
name: string;
|
|
38
|
+
mail: string;
|
|
39
|
+
username: string;
|
|
40
|
+
groupTypes: {
|
|
41
|
+
basic: string;
|
|
42
|
+
teaching: string;
|
|
43
|
+
other: string;
|
|
44
|
+
};
|
|
36
45
|
};
|
|
37
46
|
checkOutNewFeature: string;
|
|
38
47
|
slateBlockMenu: {
|
|
@@ -906,6 +906,15 @@ var messages = _objectSpread(_objectSpread({
|
|
|
906
906
|
},
|
|
907
907
|
resource: {
|
|
908
908
|
accessDenied: 'Vi beklager, men denne ressursen er bare for lærere innlogget med Feide.'
|
|
909
|
+
},
|
|
910
|
+
primarySchool: 'Hovudskule',
|
|
911
|
+
name: 'Namn',
|
|
912
|
+
mail: 'E-post',
|
|
913
|
+
username: 'Brukarnamn',
|
|
914
|
+
groupTypes: {
|
|
915
|
+
basic: 'Basisgruppe',
|
|
916
|
+
teaching: 'Undervisningsgruppe',
|
|
917
|
+
other: 'Andre grupper'
|
|
909
918
|
}
|
|
910
919
|
},
|
|
911
920
|
checkOutNewFeature: 'Sjekk ut ny funksjonalitet',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@ndla/core": "^2.1.1",
|
|
37
37
|
"@ndla/hooks": "^1.1.4",
|
|
38
38
|
"@ndla/icons": "^1.7.1",
|
|
39
|
-
"@ndla/licenses": "^4.1.
|
|
39
|
+
"@ndla/licenses": "^4.1.3",
|
|
40
40
|
"@ndla/modal": "^1.2.8",
|
|
41
|
-
"@ndla/notion": "^3.1.
|
|
41
|
+
"@ndla/notion": "^3.1.10",
|
|
42
42
|
"@ndla/safelink": "^2.0.2",
|
|
43
43
|
"@ndla/switch": "^0.1.5",
|
|
44
44
|
"@ndla/tabs": "^1.1.6",
|
|
45
|
-
"@ndla/tooltip": "^0.
|
|
45
|
+
"@ndla/tooltip": "^1.0.0",
|
|
46
46
|
"@ndla/util": "^3.0.0",
|
|
47
47
|
"@reach/menu-button": "^0.16.2",
|
|
48
48
|
"@reach/slider": "^0.16.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "79850025a1ab61d341fc5a507bed6fde7d7f4f84"
|
|
85
85
|
}
|
|
@@ -6,15 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
9
|
import styled from '@emotion/styled';
|
|
10
|
+
import Button from '@ndla/button';
|
|
12
11
|
import { animations, colors, fonts, spacing } from '@ndla/core';
|
|
13
12
|
import { ChevronDown, FeideText, LogIn, LogOut } from '@ndla/icons/common';
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import { AuthModalProps } from '../User/AuthModal';
|
|
17
|
-
import AuthModal from '../User';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import AuthModal, { AuthModalProps } from '../User/AuthModal';
|
|
18
16
|
|
|
19
17
|
const Wrapper = styled.div`
|
|
20
18
|
display: flex;
|
|
@@ -66,7 +64,7 @@ const AuthedButton = styled(Button)`
|
|
|
66
64
|
}
|
|
67
65
|
`;
|
|
68
66
|
|
|
69
|
-
const FooterAuth = ({ isAuthenticated,
|
|
67
|
+
const FooterAuth = ({ isAuthenticated, user, onAuthenticateClick, ...rest }: AuthModalProps) => {
|
|
70
68
|
const { t } = useTranslation();
|
|
71
69
|
return (
|
|
72
70
|
<Wrapper>
|
|
@@ -78,11 +76,11 @@ const FooterAuth = ({ isAuthenticated, onAuthenticateClick, authorizedRole, ...r
|
|
|
78
76
|
<AuthModal
|
|
79
77
|
{...rest}
|
|
80
78
|
isAuthenticated={isAuthenticated}
|
|
79
|
+
user={user}
|
|
81
80
|
onAuthenticateClick={onAuthenticateClick}
|
|
82
|
-
authorizedRole={authorizedRole}
|
|
83
81
|
activateButton={
|
|
84
82
|
<AuthedButton ghostPill size="medium">
|
|
85
|
-
{t('user.loggedInAsButton', { role:
|
|
83
|
+
{t('user.loggedInAsButton', { role: user?.eduPersonPrimaryAffiliation })}
|
|
86
84
|
<ChevronDown />
|
|
87
85
|
</AuthedButton>
|
|
88
86
|
}
|
|
@@ -123,7 +123,7 @@ const LearningPathMenu = ({
|
|
|
123
123
|
css={css`
|
|
124
124
|
padding-left: ${spacing.small};
|
|
125
125
|
`}>
|
|
126
|
-
<Tooltip
|
|
126
|
+
<Tooltip tooltip={t('learningPath.openMenuTooltip')}>
|
|
127
127
|
<StyledToggleMenubutton type="button" onClick={() => toggleOpenState(!isOpen)}>
|
|
128
128
|
{!isOpen ? <ArrowExpandRight /> : <ArrowExpandLeft />}
|
|
129
129
|
</StyledToggleMenubutton>
|
|
@@ -11,8 +11,7 @@ import styled from '@emotion/styled';
|
|
|
11
11
|
import Button from '@ndla/button';
|
|
12
12
|
import { Feide } from '@ndla/icons/common';
|
|
13
13
|
|
|
14
|
-
import AuthModal from '../User';
|
|
15
|
-
import { AuthModalProps } from '../User/AuthModal';
|
|
14
|
+
import AuthModal, { AuthModalProps } from '../User/AuthModal';
|
|
16
15
|
|
|
17
16
|
type FeideWrapperProps = {
|
|
18
17
|
inverted?: boolean;
|
|
@@ -31,11 +30,11 @@ const StyledButton = styled(Button)<FeideWrapperProps>`
|
|
|
31
30
|
}
|
|
32
31
|
`;
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
interface Props extends AuthModalProps {
|
|
35
34
|
inverted?: boolean;
|
|
36
|
-
}
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
const MastheadAuthModal = ({ inverted, ...rest }: Props
|
|
37
|
+
const MastheadAuthModal = ({ inverted, ...rest }: Props) => {
|
|
39
38
|
return (
|
|
40
39
|
<AuthModal
|
|
41
40
|
{...rest}
|
|
@@ -273,19 +273,19 @@ const ResourceItem = ({
|
|
|
273
273
|
<TypeWrapper>
|
|
274
274
|
{contentTypeName && <ContentTypeName>{contentTypeName}</ContentTypeName>}
|
|
275
275
|
{access && access === 'teacher' && (
|
|
276
|
-
<Tooltip tooltip={t('article.access.onlyTeacher')}
|
|
276
|
+
<Tooltip tooltip={t('article.access.onlyTeacher')}>
|
|
277
277
|
<HumanMaleBoard className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons" />
|
|
278
278
|
</Tooltip>
|
|
279
279
|
)}
|
|
280
280
|
{showAdditionalResources && contentTypeDescription && (
|
|
281
281
|
<>
|
|
282
282
|
{additional && (
|
|
283
|
-
<Tooltip tooltip={contentTypeDescription}
|
|
283
|
+
<Tooltip tooltip={contentTypeDescription}>
|
|
284
284
|
<Additional className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons" />
|
|
285
285
|
</Tooltip>
|
|
286
286
|
)}
|
|
287
287
|
{!additional && (
|
|
288
|
-
<Tooltip tooltip={contentTypeDescription}
|
|
288
|
+
<Tooltip tooltip={contentTypeDescription}>
|
|
289
289
|
<Core className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons" />
|
|
290
290
|
</Tooltip>
|
|
291
291
|
)}
|
|
@@ -85,7 +85,6 @@ const ActiveFilters = ({ filters, onFilterRemove, showOnSmallScreen }) => {
|
|
|
85
85
|
<StyledActiveFilterWrapper key={filterKey}>
|
|
86
86
|
{filterLength > 1 ? (
|
|
87
87
|
<Tooltip
|
|
88
|
-
align="top"
|
|
89
88
|
tooltip={t('searchPage.searchFilterMessages.removeFilter', {
|
|
90
89
|
filterName: filter.title,
|
|
91
90
|
})}>
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, ReactElement } from 'react';
|
|
2
1
|
import Button from '@ndla/button';
|
|
3
|
-
import
|
|
4
|
-
import { Additional, ChevronUp, ChevronDown } from '@ndla/icons/common';
|
|
2
|
+
import { Additional, ChevronDown, ChevronUp } from '@ndla/icons/common';
|
|
5
3
|
import SafeLink from '@ndla/safelink';
|
|
4
|
+
import Tooltip from '@ndla/tooltip';
|
|
5
|
+
import React, { ReactElement, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import ContentTypeBadge from '../ContentTypeBadge';
|
|
8
8
|
import { ContentTypeResultType, Resource } from '../types';
|
|
9
9
|
import {
|
|
10
10
|
highlightStyle,
|
|
11
|
+
noWidthhighlightStyle,
|
|
11
12
|
showAllButtonStyle,
|
|
12
|
-
tooltipStyle,
|
|
13
|
-
StyledNoHit,
|
|
14
|
-
StyledWrapper,
|
|
15
13
|
StyledHeader,
|
|
16
|
-
StyledListItem,
|
|
17
14
|
StyledList,
|
|
15
|
+
StyledListItem,
|
|
16
|
+
StyledNoHit,
|
|
18
17
|
StyledTag,
|
|
19
|
-
|
|
18
|
+
StyledWrapper,
|
|
20
19
|
} from './ContentTypeResultStyles';
|
|
21
20
|
import { isPathToHighlight } from './IsPathToHighlight';
|
|
22
21
|
|
|
23
22
|
const renderAdditionalIcon = (label: string, isAdditional?: boolean): ReactElement | null => {
|
|
24
23
|
if (isAdditional && label) {
|
|
25
24
|
return (
|
|
26
|
-
<Tooltip tooltip={label}
|
|
25
|
+
<Tooltip tooltip={label}>
|
|
27
26
|
<Additional className="c-icon--20" />
|
|
28
27
|
</Tooltip>
|
|
29
28
|
);
|
|
@@ -120,8 +120,6 @@ const ActiveFilters = ({
|
|
|
120
120
|
<StyledActiveFilterWrapper key={filterKey}>
|
|
121
121
|
{filterLength > 1 ? (
|
|
122
122
|
<Tooltip
|
|
123
|
-
delay={2000}
|
|
124
|
-
align="bottom"
|
|
125
123
|
tooltip={t('searchPage.searchFilterMessages.removeFilter', {
|
|
126
124
|
filterName: filter.title,
|
|
127
125
|
})}>
|
|
@@ -139,7 +137,7 @@ const ActiveFilters = ({
|
|
|
139
137
|
{filterItems}
|
|
140
138
|
{filterLength > showFilterCount && (
|
|
141
139
|
<StyledActiveFilterWrapper>
|
|
142
|
-
<Tooltip
|
|
140
|
+
<Tooltip tooltip={t('searchPage.searchFilterMessages.noValuesButtonText')}>
|
|
143
141
|
<Button
|
|
144
142
|
aria-label={t('searchPage.searchFilterMessages.additionalSubjectFilters', {
|
|
145
143
|
count: filterLength - showFilterCount + 1,
|
|
@@ -64,12 +64,12 @@ export const TopicIntroduction = ({
|
|
|
64
64
|
{contentTypeDescription}
|
|
65
65
|
</span>
|
|
66
66
|
{additional && (
|
|
67
|
-
<Tooltip tooltip={t('resource.tooltipAdditionalTopic')}
|
|
67
|
+
<Tooltip tooltip={t('resource.tooltipAdditionalTopic')}>
|
|
68
68
|
<Additional className="c-icon--20 u-margin-left-tiny" />
|
|
69
69
|
</Tooltip>
|
|
70
70
|
)}
|
|
71
71
|
{!additional && showAdditionalCores && (
|
|
72
|
-
<Tooltip tooltip={t('resource.tooltipCoreTopic')}
|
|
72
|
+
<Tooltip tooltip={t('resource.tooltipCoreTopic')}>
|
|
73
73
|
<Core className="c-icon--20 u-margin-left-tiny" />
|
|
74
74
|
</Tooltip>
|
|
75
75
|
)}
|
|
@@ -17,11 +17,7 @@ interface Props {
|
|
|
17
17
|
const ShortcutItem = ({ shortcut: { id, tooltip, contentType, url, count } }: Props) => {
|
|
18
18
|
const { t } = useTranslation();
|
|
19
19
|
return (
|
|
20
|
-
<Tooltip
|
|
21
|
-
id={`shortcut-tooltip-${id}`}
|
|
22
|
-
tooltip={t('resource.shortcutsTooltip', { count })}
|
|
23
|
-
delay={100}
|
|
24
|
-
align="bottom">
|
|
20
|
+
<Tooltip id={`shortcut-tooltip-${id}`} tooltip={t('resource.shortcutsTooltip', { count })}>
|
|
25
21
|
<SafeLink {...classes('item-link')} aria-label={tooltip} to={url}>
|
|
26
22
|
<ContentTypeBadge type={contentType} size="x-small" background />
|
|
27
23
|
<span {...classes('count')}>{count}</span>
|
package/src/User/AuthModal.tsx
CHANGED
|
@@ -13,6 +13,8 @@ import Modal, { ModalCloseButton } from '@ndla/modal';
|
|
|
13
13
|
import Button from '@ndla/button';
|
|
14
14
|
import { FeideText, LogIn, LogOut, HumanMaleBoard } from '@ndla/icons/common';
|
|
15
15
|
import { fonts, spacing } from '@ndla/core';
|
|
16
|
+
import { UserInfo } from './UserInfo';
|
|
17
|
+
import { FeideUserApiType } from './apiTypes';
|
|
16
18
|
|
|
17
19
|
const StyledModalBody = styled.div`
|
|
18
20
|
padding: ${spacing.normal} ${spacing.medium} ${spacing.medium};
|
|
@@ -38,17 +40,6 @@ const StyledHeading = styled.h2`
|
|
|
38
40
|
}
|
|
39
41
|
`;
|
|
40
42
|
|
|
41
|
-
const StyledAuthorizedInfoList = styled.ul`
|
|
42
|
-
margin: 0;
|
|
43
|
-
padding: 0 0 0 ${spacing.normal};
|
|
44
|
-
list-style-image: unset;
|
|
45
|
-
|
|
46
|
-
li {
|
|
47
|
-
margin: 0;
|
|
48
|
-
font-weight: ${fonts.weight.semibold};
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
43
|
const StyledHumanMaleBoardIconWrapper = styled.span`
|
|
53
44
|
margin-left: ${spacing.xsmall};
|
|
54
45
|
`;
|
|
@@ -63,9 +54,8 @@ const StyledButtonWrapper = styled.div`
|
|
|
63
54
|
|
|
64
55
|
export type AuthModalProps = {
|
|
65
56
|
isAuthenticated?: boolean;
|
|
57
|
+
user?: FeideUserApiType;
|
|
66
58
|
showGeneralMessage?: boolean;
|
|
67
|
-
authorizedRole?: string;
|
|
68
|
-
authorizedCollectedInfo?: string[];
|
|
69
59
|
onAuthenticateClick: () => void;
|
|
70
60
|
position?: 'top' | 'bottom';
|
|
71
61
|
activateButton?: ReactElement;
|
|
@@ -76,9 +66,8 @@ export type AuthModalProps = {
|
|
|
76
66
|
|
|
77
67
|
const AuthModal = ({
|
|
78
68
|
isAuthenticated,
|
|
69
|
+
user,
|
|
79
70
|
showGeneralMessage = true,
|
|
80
|
-
authorizedRole,
|
|
81
|
-
authorizedCollectedInfo,
|
|
82
71
|
onAuthenticateClick,
|
|
83
72
|
position = 'top',
|
|
84
73
|
activateButton,
|
|
@@ -104,17 +93,7 @@ const AuthModal = ({
|
|
|
104
93
|
<ModalCloseButton onClick={onClose} title="Lukk" />
|
|
105
94
|
</StyledModalHeader>
|
|
106
95
|
<StyledModalContent>
|
|
107
|
-
{
|
|
108
|
-
{authorizedCollectedInfo && authorizedCollectedInfo.length > 0 && (
|
|
109
|
-
<div>
|
|
110
|
-
{t('user.modal.collectedInfo')}
|
|
111
|
-
<StyledAuthorizedInfoList>
|
|
112
|
-
{authorizedCollectedInfo.map((value) => (
|
|
113
|
-
<li key={value}>{value}</li>
|
|
114
|
-
))}
|
|
115
|
-
</StyledAuthorizedInfoList>
|
|
116
|
-
</div>
|
|
117
|
-
)}
|
|
96
|
+
{user && <UserInfo user={user} />}
|
|
118
97
|
{children}
|
|
119
98
|
{showGeneralMessage && (
|
|
120
99
|
<p>
|
|
@@ -0,0 +1,80 @@
|
|
|
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 React from 'react';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { FeideUserApiType } from './apiTypes';
|
|
13
|
+
import { parseUserObject } from './parseUserObject';
|
|
14
|
+
|
|
15
|
+
const InfoList = styled.ul`
|
|
16
|
+
padding: 0 0 0 ${spacing.normal};
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
user: FeideUserApiType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ShortInfoDiv = styled.div`
|
|
24
|
+
margin: 2rem auto;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const UserInfo = ({ user }: Props) => {
|
|
28
|
+
const { t } = useTranslation();
|
|
29
|
+
|
|
30
|
+
const parsedUser = parseUserObject(user);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
{
|
|
35
|
+
<p>
|
|
36
|
+
{t('user.loggedInAs', {
|
|
37
|
+
role: t(`user.role.${parsedUser.primaryAffiliation}`),
|
|
38
|
+
})}
|
|
39
|
+
</p>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
<ShortInfoDiv>
|
|
43
|
+
<div>
|
|
44
|
+
{t('user.username')}: <b>{user.uid}</b>
|
|
45
|
+
</div>
|
|
46
|
+
<div>
|
|
47
|
+
{t('user.name')}: <b>{user.displayName}</b>
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
{t('user.mail')}: <b>{user.mail?.join(', ')}</b>
|
|
51
|
+
</div>
|
|
52
|
+
</ShortInfoDiv>
|
|
53
|
+
|
|
54
|
+
{t('user.modal.collectedInfo')}
|
|
55
|
+
|
|
56
|
+
<InfoList>
|
|
57
|
+
{parsedUser.organizations.map((org) => (
|
|
58
|
+
<li key={org.id}>
|
|
59
|
+
{`${org.displayName}${org.membership.primarySchool ? ` (${t('user.primarySchool')})` : ''}`}
|
|
60
|
+
<InfoList>
|
|
61
|
+
{Object.entries(org.children).map(([groupType, val]) => {
|
|
62
|
+
if (val.length < 1) return null;
|
|
63
|
+
return (
|
|
64
|
+
<li key={groupType}>
|
|
65
|
+
{t(`user.groupTypes.${groupType}`)}
|
|
66
|
+
<InfoList>
|
|
67
|
+
{val.map((group) => (
|
|
68
|
+
<li key={group.id}>{`${group.displayName}${group.grep ? ` (${group.grep.code})` : ''}`}</li>
|
|
69
|
+
))}
|
|
70
|
+
</InfoList>
|
|
71
|
+
</li>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</InfoList>
|
|
75
|
+
</li>
|
|
76
|
+
))}
|
|
77
|
+
</InfoList>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|