@aarhus-university/au-lib-react-components 11.1.2 → 11.2.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/package.json +1 -1
- package/src/lib/portals.tsx +101 -0
- package/src/lib/portals.ts +0 -37
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { replace } from './helpers';
|
|
4
|
+
|
|
5
|
+
const impersonationLabels = {
|
|
6
|
+
IMPERSONATION_SELECT_OPTION_CPR: { da: 'CPR-nr.', en: 'CPR no.' },
|
|
7
|
+
IMPERSONATION_SELECT_OPTION_EMAIL: { da: 'E-mail', en: 'Email' },
|
|
8
|
+
IMPERSONATION_SELECT_OPTION_AUID: { da: 'AU-id', en: 'AU ID' },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
IMPERSONATE_AUID: string;
|
|
14
|
+
IMPERSONATE_VALUE: string;
|
|
15
|
+
IMPERSONATE_TYPE: string;
|
|
16
|
+
PHASE: string;
|
|
17
|
+
authenticated: boolean;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const portals: (lang: string) => AU.IPortalContext[] = (lang: string) => [
|
|
22
|
+
{
|
|
23
|
+
name: 'mitstudie',
|
|
24
|
+
impersonationSetup: {
|
|
25
|
+
auid: window.IMPERSONATE_AUID,
|
|
26
|
+
value: window.IMPERSONATE_VALUE,
|
|
27
|
+
type: window.IMPERSONATE_TYPE,
|
|
28
|
+
},
|
|
29
|
+
impersonationOptions: [
|
|
30
|
+
{
|
|
31
|
+
value: 'auid',
|
|
32
|
+
label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
deactivateFormContent: (
|
|
36
|
+
activatedText: string,
|
|
37
|
+
replaceText: string[],
|
|
38
|
+
replaceWith: string[],
|
|
39
|
+
portal: AU.IPortalContext,
|
|
40
|
+
) => (
|
|
41
|
+
<>
|
|
42
|
+
<div
|
|
43
|
+
className="content-container vertical-spacing-bottom typography-dense"
|
|
44
|
+
dangerouslySetInnerHTML={
|
|
45
|
+
// eslint-disable-next-line max-len
|
|
46
|
+
{ __html: replace(activatedText, replaceText, replaceWith) }
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
<input type="hidden" name="type" value={portal.impersonationSetup.type} />
|
|
50
|
+
<input type="hidden" name="value" value={portal.impersonationSetup.value} />
|
|
51
|
+
</>
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'minansoegning',
|
|
56
|
+
impersonationSetup: {
|
|
57
|
+
auid: window.IMPERSONATE_AUID,
|
|
58
|
+
value: window.IMPERSONATE_VALUE,
|
|
59
|
+
type: window.IMPERSONATE_TYPE,
|
|
60
|
+
phase: window.PHASE,
|
|
61
|
+
},
|
|
62
|
+
impersonationOptions: [
|
|
63
|
+
{
|
|
64
|
+
value: 'auid',
|
|
65
|
+
label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: 'cpr',
|
|
69
|
+
label: impersonationLabels.IMPERSONATION_SELECT_OPTION_CPR[lang],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: 'email',
|
|
73
|
+
label: impersonationLabels.IMPERSONATION_SELECT_OPTION_EMAIL[lang],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
deactivateFormContent: (
|
|
77
|
+
activatedText: string,
|
|
78
|
+
replaceText: string[],
|
|
79
|
+
replaceWith: string[],
|
|
80
|
+
portal: AU.IPortalContext,
|
|
81
|
+
) => (
|
|
82
|
+
<>
|
|
83
|
+
<div
|
|
84
|
+
className="content-container vertical-spacing-bottom typography-dense"
|
|
85
|
+
dangerouslySetInnerHTML={
|
|
86
|
+
// eslint-disable-next-line max-len
|
|
87
|
+
{ __html: replace(activatedText, replaceText, replaceWith) }
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
<input type="hidden" name="type" value={portal.impersonationSetup.type} />
|
|
91
|
+
<input type="hidden" name="value" value={portal.impersonationSetup.value} />
|
|
92
|
+
<input type="hidden" name="phase" value={portal.impersonationSetup.phase} />
|
|
93
|
+
</>
|
|
94
|
+
),
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
export const getPortalByName = (
|
|
99
|
+
lang: string,
|
|
100
|
+
name: string,
|
|
101
|
+
): AU.IPortalContext | null => portals(lang).find((portal) => portal.name === name) ?? null;
|
package/src/lib/portals.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
const impersonationLabels = {
|
|
3
|
-
IMPERSONATION_SELECT_OPTION_CPR: { da: 'CPR-nr.', en: 'CPR no.' },
|
|
4
|
-
IMPERSONATION_SELECT_OPTION_EMAIL: { da: 'E-mail', en: 'Email' },
|
|
5
|
-
IMPERSONATION_SELECT_OPTION_AUID: { da: 'AU-id', en: 'AU ID' },
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare global {
|
|
9
|
-
interface Window {
|
|
10
|
-
IMPERSONATE_AUID: string,
|
|
11
|
-
IMPERSONATE_VALUE: string;
|
|
12
|
-
IMPERSONATE_TYPE: string;
|
|
13
|
-
authenticated: boolean,
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const portals: (lang: string) => AU.IPortalContext[] = (lang: string) => [
|
|
18
|
-
{
|
|
19
|
-
name: 'mitstudie',
|
|
20
|
-
impersonationSetup: {
|
|
21
|
-
auid: window.IMPERSONATE_AUID,
|
|
22
|
-
value: window.IMPERSONATE_VALUE,
|
|
23
|
-
type: window.IMPERSONATE_TYPE,
|
|
24
|
-
},
|
|
25
|
-
impersonationOptions: [
|
|
26
|
-
{
|
|
27
|
-
value: 'auid',
|
|
28
|
-
label: impersonationLabels.IMPERSONATION_SELECT_OPTION_AUID[lang],
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
export const getPortalByName = (
|
|
35
|
-
lang: string,
|
|
36
|
-
name: string,
|
|
37
|
-
): AU.IPortalContext | null => portals(lang).find((portal) => portal.name === name) ?? null;
|