@gen-epix/ui-client-common 4.5.0 → 4.6.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/README.md +5 -4
- package/dist/@types/mui.d.ts +13 -5
- package/dist/@types/ui-client-common.d.ts +1 -0
- package/dist/_chunks/ApplicationFooter.js +45 -46
- package/dist/_chunks/ApplicationFooter.js.map +1 -1
- package/dist/_chunks/Breadcrumbs.js +14 -15
- package/dist/_chunks/CrudPage.js +301 -302
- package/dist/_chunks/CrudPage.js.map +1 -1
- package/dist/_chunks/GeoFilter.js +1 -2
- package/dist/_chunks/GeoFilter.js.map +1 -1
- package/dist/_chunks/Notifications.js +52 -53
- package/dist/_chunks/OutageList.js +30 -31
- package/dist/_chunks/OutageList.js.map +1 -1
- package/dist/_chunks/OutageUtil.js +4 -8
- package/dist/_chunks/OutageUtil.js.map +1 -1
- package/dist/_chunks/QueryClientProvider.js +1 -2
- package/dist/_chunks/QueryClientProvider.js.map +1 -1
- package/dist/_chunks/QueryClientService.js +101 -395
- package/dist/_chunks/QueryClientService.js.map +1 -1
- package/dist/_chunks/Reflect.js +1 -2
- package/dist/_chunks/Table.js +523 -522
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/TableUtil.js +10 -20
- package/dist/_chunks/TableUtil.js.map +1 -1
- package/dist/_chunks/TextFilter.js +18 -20
- package/dist/_chunks/TextFilter.js.map +1 -1
- package/dist/_chunks/UserInvitationsAdminPage.js +78 -79
- package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
- package/dist/_chunks/UserManagerUtil.js +212 -213
- package/dist/_chunks/UserManagerUtil.js.map +1 -1
- package/dist/_chunks/_baseAssignValue.js +1 -2
- package/dist/_chunks/_baseFlatten.js +9 -10
- package/dist/_chunks/_baseFlatten.js.map +1 -1
- package/dist/_chunks/_baseGet.js +279 -0
- package/dist/_chunks/_baseGet.js.map +1 -0
- package/dist/_chunks/_baseIteratee.js +273 -0
- package/dist/_chunks/_baseIteratee.js.map +1 -0
- package/dist/_chunks/_baseUnset.js +22 -300
- package/dist/_chunks/_baseUnset.js.map +1 -1
- package/dist/_chunks/_cacheHas.js +1 -2
- package/dist/_chunks/_setToString.js +1 -2
- package/dist/_chunks/decorate.js +1 -2
- package/dist/_chunks/decorateParam.js +1 -2
- package/dist/_chunks/format.js +27 -54
- package/dist/_chunks/format.js.map +1 -1
- package/dist/_chunks/isArrayLike.js +1 -2
- package/dist/_chunks/isObject.js +1 -2
- package/dist/_chunks/isSymbol.js +1 -2
- package/dist/_chunks/last.js +12 -0
- package/dist/_chunks/last.js.map +1 -0
- package/dist/_chunks/middleware.js +2 -3
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/omit.js +42 -42
- package/dist/_chunks/omit.js.map +1 -1
- package/dist/_chunks/query.js +8 -15
- package/dist/_chunks/query.js.map +1 -1
- package/dist/_chunks/react.js +2 -3
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/rolldown-runtime.js +2 -3
- package/dist/_chunks/tableStore.js +231 -224
- package/dist/_chunks/tableStore.js.map +1 -1
- package/dist/_chunks/toDate.js +8 -14
- package/dist/_chunks/toDate.js.map +1 -1
- package/dist/_chunks/uniq.js +43 -0
- package/dist/_chunks/uniq.js.map +1 -0
- package/dist/_chunks/useColumnsMenu.js +3 -6
- package/dist/_chunks/useColumnsMenu.js.map +1 -1
- package/dist/_chunks/useMutation.js +24 -26
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +33 -22
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -2
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -4
- package/dist/_chunks/yup.js.map +1 -1
- package/dist/classes/TableEventBus/index.js +1 -2
- package/dist/classes/abstracts/FilterAbstract/index.js +4 -3
- package/dist/classes/abstracts/FilterAbstract/index.js.map +1 -1
- package/dist/classes/filters/MultiSelectFilter.d.ts +1 -1
- package/dist/classes/services/AuthenticationService/AuthenticationService.d.ts +1 -1
- package/dist/classes/services/AuthenticationService/index.js +15 -16
- package/dist/classes/services/AuthenticationService/index.js.map +1 -1
- package/dist/classes/services/AuthorizationService/index.js +5 -6
- package/dist/classes/services/AuthorizationService/index.js.map +1 -1
- package/dist/classes/services/BackendVersionService/index.js +4 -4
- package/dist/classes/services/BackendVersionService/index.js.map +1 -1
- package/dist/classes/services/BreadcrumbService/index.js +16 -39
- package/dist/classes/services/BreadcrumbService/index.js.map +1 -1
- package/dist/classes/services/EmotionCacheService/index.js +10 -10
- package/dist/classes/services/EmotionCacheService/index.js.map +1 -1
- package/dist/classes/services/FeatureFlagsService/index.js +1 -2
- package/dist/classes/services/I18nService/index.js +12 -12
- package/dist/classes/services/I18nService/index.js.map +1 -1
- package/dist/classes/services/InactivityService/index.js +13 -14
- package/dist/classes/services/InactivityService/index.js.map +1 -1
- package/dist/classes/services/LogService/index.js +40 -35
- package/dist/classes/services/LogService/index.js.map +1 -1
- package/dist/classes/services/NavigationHistoryService/index.js +1 -2
- package/dist/classes/services/NotificationService/index.js +9 -10
- package/dist/classes/services/NotificationService/index.js.map +1 -1
- package/dist/classes/services/PageEventBusService/index.js +14 -11
- package/dist/classes/services/PageEventBusService/index.js.map +1 -1
- package/dist/classes/services/RouterService/index.js +4 -8
- package/dist/classes/services/RouterService/index.js.map +1 -1
- package/dist/classes/services/UserSettingsService/index.js +1 -2
- package/dist/components/app/App/App.d.ts +1 -1
- package/dist/components/app/App/index.js +35 -40
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +29 -30
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js +48 -47
- package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
- package/dist/components/app/AuthenticationWrapper/index.js +36 -37
- package/dist/components/app/AuthenticationWrapper/index.js.map +1 -1
- package/dist/components/app/AuthorizationWrapper/index.js +20 -21
- package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
- package/dist/components/app/RouterRoot/index.js +53 -52
- package/dist/components/app/RouterRoot/index.js.map +1 -1
- package/dist/components/epi/EpiContactDetailsDialog/index.js +22 -23
- package/dist/components/filters/BooleanFilterField/index.js +6 -7
- package/dist/components/filters/DateFilterField/index.js +4 -5
- package/dist/components/filters/GeoFilterField/index.js +5 -6
- package/dist/components/filters/MultiSelectFilterField/index.js +5 -6
- package/dist/components/filters/NumberRangeFilterField/index.js +4 -5
- package/dist/components/filters/TextFilterField/index.js +4 -5
- package/dist/components/ui/ApplicationBar/index.js +189 -190
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/ConsentDialog/index.js +1 -2
- package/dist/components/ui/GenericErrorMessage/index.js +30 -31
- package/dist/components/ui/LicensesDialog/index.js +39 -40
- package/dist/components/ui/LicensesDialog/index.js.map +1 -1
- package/dist/components/ui/MyPermissionsDialog/index.js +17 -18
- package/dist/components/ui/NavLink/index.js +7 -8
- package/dist/components/ui/OrganizationSwitcherDialog/index.js +22 -23
- package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
- package/dist/components/ui/OutagesDialog/index.js +1 -2
- package/dist/components/ui/PageContainer/index.js +25 -26
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/components/ui/ResponseHandler/index.js +1 -2
- package/dist/components/ui/Sidebar/index.js +31 -32
- package/dist/components/ui/UserFeedbackDialog/index.js +13 -14
- package/dist/components/ui/UserInactivityConfirmation/index.js +1 -2
- package/dist/constants/api.constants.js +1 -2
- package/dist/constants/config.constants.d.ts +0 -2
- package/dist/constants/config.constants.js +3 -4
- package/dist/constants/config.constants.js.map +1 -1
- package/dist/constants/query.constants.js +1 -2
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js +13 -14
- package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js.map +1 -1
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js +15 -16
- package/dist/dataHooks/useIdentifierIssuerQuery/index.js.map +1 -1
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js +13 -14
- package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js +14 -15
- package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js.map +1 -1
- package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js +5 -6
- package/dist/dataHooks/useOrganizationsQuery/index.js +14 -15
- package/dist/dataHooks/useOrganizationsQuery/index.js.map +1 -1
- package/dist/dataHooks/useUsersQuery/index.js +11 -12
- package/dist/dataHooks/useUsersQuery/index.js.map +1 -1
- package/dist/hoc/withPermissions/index.js +1 -2
- package/dist/hooks/useConfig/index.js +3 -4
- package/dist/hooks/useConfig/index.js.map +1 -1
- package/dist/hooks/useCreateMutation/index.js +13 -14
- package/dist/hooks/useCreateMutation/index.js.map +1 -1
- package/dist/hooks/useDeleteMutation/index.js +17 -11
- package/dist/hooks/useDeleteMutation/index.js.map +1 -1
- package/dist/hooks/useEditMutation/index.js +49 -35
- package/dist/hooks/useEditMutation/index.js.map +1 -1
- package/dist/hooks/useInitializeTableStore/index.js +1 -2
- package/dist/hooks/useItemQuery/index.js +5 -6
- package/dist/hooks/useItemQuery/index.js.map +1 -1
- package/dist/hooks/useUpdateBreadcrumb/index.js +1 -2
- package/dist/hooks/useUpdateDocumentTitle/index.js +1 -2
- package/dist/locale/en.json +1 -0
- package/dist/locale/nl.json +1 -0
- package/dist/models/admin.models.js +1 -2
- package/dist/models/admin.models.js.map +1 -1
- package/dist/models/config.models.d.ts +1 -5
- package/dist/models/table.models.js +1 -2
- package/dist/models/table.models.js.map +1 -1
- package/dist/models/theme.models.d.ts +19 -16
- package/dist/pages/AcceptInvitationPage/index.js +26 -27
- package/dist/pages/AcceptInvitationPage/index.js.map +1 -1
- package/dist/pages/AdminPage/index.js +17 -18
- package/dist/pages/ChooseIdentityProviderPage/index.js +22 -23
- package/dist/pages/ErrorPage/index.js +1 -2
- package/dist/pages/IdentifierIssuersAdminPage/index.js +6 -7
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +6 -7
- package/dist/pages/OrganizationContactsAdminPage/index.js +7 -8
- package/dist/pages/OrganizationSitesAdminPage/index.js +10 -11
- package/dist/pages/OrganizationsAdminPage/index.js +14 -15
- package/dist/pages/OrganizationsAdminPage/index.js.map +1 -1
- package/dist/pages/OutagesAdminPage/index.js +21 -22
- package/dist/pages/PostLoginPage/index.js +8 -9
- package/dist/pages/PostLoginPage/index.js.map +1 -1
- package/dist/pages/PostLogoutPage/index.js +9 -10
- package/dist/pages/RouterErrorPage/index.js +1 -2
- package/dist/pages/UsersAdminPage/index.js +40 -41
- package/dist/pages/UsersAdminPage/index.js.map +1 -1
- package/dist/routes/index.js +1 -2
- package/dist/setup/setup.js +12 -6
- package/dist/setup/setup.js.map +1 -1
- package/dist/stores/oidcStore/index.js +1 -2
- package/dist/stores/outagesStore/index.js +1 -2
- package/dist/theme/demoTheme/index.js +18 -17
- package/dist/theme/demoTheme/index.js.map +1 -1
- package/dist/utils/AxiosUtil/index.js +1 -2
- package/dist/utils/DataHookUtil/index.js +2 -3
- package/dist/utils/DataHookUtil/index.js.map +1 -1
- package/dist/utils/DependencyContainerUtil/DependencyContainerUtil.d.ts +2 -3
- package/dist/utils/DependencyContainerUtil/index.js +10 -16
- package/dist/utils/DependencyContainerUtil/index.js.map +1 -1
- package/dist/utils/LoadableUtil/index.js +1 -2
- package/dist/utils/MenuDataUtil/index.js +2 -3
- package/dist/utils/MenuDataUtil/index.js.map +1 -1
- package/dist/utils/NotificationUtil/index.js +1 -2
- package/dist/utils/StandardConfigUtil/index.js +1 -6
- package/dist/utils/StandardConfigUtil/index.js.map +1 -1
- package/dist/utils/TimeUtil/index.js +2 -3
- package/dist/utils/TimeUtil/index.js.map +1 -1
- package/dist/utils/UserUtil/index.js +1 -2
- package/package.json +26 -29
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContext.d.ts +0 -9
- package/dist/context/ClientCommonConfigContext/ClientCommonConfigContextProvider.d.ts +0 -6
- package/dist/context/ClientCommonConfigContext/index.d.ts +0 -3
- package/dist/context/ClientCommonConfigContext/index.js +0 -34
- package/dist/context/ClientCommonConfigContext/index.js.map +0 -1
- package/dist/context/ClientCommonConfigContext/useClientCommonConfigContext.d.ts +0 -3
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { LoadableUtil as e } from "../../../utils/LoadableUtil/index.js";
|
|
2
|
+
import { API_SYSTEM_TOKEN as t } from "../../../constants/api.constants.js";
|
|
3
|
+
import { PageContainer as n } from "../../ui/PageContainer/index.js";
|
|
4
|
+
import { ResponseHandler as r } from "../../ui/ResponseHandler/index.js";
|
|
5
|
+
import { t as i } from "../../../_chunks/useQueryMemo.js";
|
|
6
|
+
import { t as a } from "../../../_chunks/QueryClientService.js";
|
|
7
|
+
import { COMMON_QUERY_KEY as o } from "../../../constants/query.constants.js";
|
|
8
|
+
import { ErrorPage as s } from "../../../pages/ErrorPage/index.js";
|
|
9
|
+
import { FeatureFlagsService as c } from "../../../classes/services/FeatureFlagsService/index.js";
|
|
10
|
+
import { I18nService as l } from "../../../classes/services/I18nService/index.js";
|
|
11
|
+
import { container as u } from "tsyringe";
|
|
12
|
+
import { WindowService as d } from "@gen-epix/ui-core/classes/services/WindowService";
|
|
13
|
+
import { useCallback as f, useEffect as p, useRef as m, useState as h } from "react";
|
|
14
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
15
|
+
import { useTranslation as v } from "react-i18next";
|
|
16
|
+
import { TestIdUtil as y } from "@gen-epix/ui-core/utils/TestIdUtil";
|
|
17
|
+
import { Spinner as b } from "@gen-epix/ui-core-components/components/Spinner";
|
|
18
|
+
import { useArray as x } from "@gen-epix/ui-core/hooks/useArray";
|
|
19
|
+
import { Confirmation as S } from "@gen-epix/ui-core-components/components/Confirmation";
|
|
20
|
+
// src/components/app/ApplicationBootstrapWithoutAuthorization/ApplicationBootstrapWithoutAuthorization.tsx
|
|
21
|
+
var C = ({ children: C }) => {
|
|
22
|
+
let { t: w } = v(), T = m(null), E = m(null), [D, O] = h(!1);
|
|
23
|
+
p(() => {
|
|
24
|
+
let e = u.resolve(l), t = (e) => {
|
|
25
|
+
E.current = e, T.current?.open();
|
|
24
26
|
};
|
|
25
27
|
return e.addEventListener("onUserLanguageChange", t), () => {
|
|
26
28
|
e.removeEventListener("onUserLanguageChange", t);
|
|
27
29
|
};
|
|
28
30
|
}, []);
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
}, []),
|
|
31
|
+
let k = f(async () => {
|
|
32
|
+
E.current && (O(!0), await u.resolve(l).switchLanguageConfig(E.current), u.resolve(d).window.location.reload());
|
|
33
|
+
}, []), A = i({
|
|
32
34
|
gcTime: Infinity,
|
|
33
|
-
queryFn: async ({ signal: e }) => (await
|
|
34
|
-
queryKey:
|
|
35
|
+
queryFn: async ({ signal: e }) => (await u.resolve(t).retrieveFeatureFlags({ signal: e })).data,
|
|
36
|
+
queryKey: u.resolve(a).getGenericKey(o.FEATURE_FLAGS),
|
|
35
37
|
staleTime: Infinity
|
|
36
38
|
});
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
return
|
|
39
|
+
A.data && (u.resolve(c).featureFlags = A.data.feature_flags);
|
|
40
|
+
let j = x([A]);
|
|
41
|
+
return e.hasSomeError(j) ? /* @__PURE__ */ g(s, { error: A.error }) : D ? /* @__PURE__ */ g(n, {
|
|
40
42
|
singleAction: !0,
|
|
41
|
-
testIdAttributes:
|
|
42
|
-
title:
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
testIdAttributes: y.createAttributes("LanguageChangingPage"),
|
|
44
|
+
title: w`Changing language`,
|
|
45
|
+
children: /* @__PURE__ */ g(b, {
|
|
44
46
|
inline: !0,
|
|
45
|
-
label:
|
|
47
|
+
label: w`Changing language...`
|
|
46
48
|
})
|
|
47
|
-
}) : /* @__PURE__ */
|
|
48
|
-
loadables:
|
|
49
|
-
loadingMessage:
|
|
50
|
-
children: [
|
|
51
|
-
body:
|
|
52
|
-
cancelLabel:
|
|
53
|
-
confirmLabel:
|
|
49
|
+
}) : /* @__PURE__ */ _(r, {
|
|
50
|
+
loadables: j,
|
|
51
|
+
loadingMessage: w`Loading`,
|
|
52
|
+
children: [C, /* @__PURE__ */ g(S, {
|
|
53
|
+
body: w`Changing language will reload the application. Do you want to continue?`,
|
|
54
|
+
cancelLabel: w`Cancel`,
|
|
55
|
+
confirmLabel: w`Change language`,
|
|
54
56
|
maxWidth: "xs",
|
|
55
|
-
onConfirm:
|
|
56
|
-
ref:
|
|
57
|
-
title:
|
|
57
|
+
onConfirm: k,
|
|
58
|
+
ref: T,
|
|
59
|
+
title: w`Are you sure?`
|
|
58
60
|
})]
|
|
59
61
|
});
|
|
60
62
|
};
|
|
61
|
-
|
|
62
|
-
export { x as ApplicationBootstrapWithoutAuthorization };
|
|
63
|
+
export { C as ApplicationBootstrapWithoutAuthorization };
|
|
63
64
|
|
|
64
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["QueryClientService","ApplicationBootstrapWithoutAuthorization","useTranslation","confirmationRef","useRef","newLanguageCodeRef","isLanguageChanging","setIsLanguageChanging","useState","i18nService","container","I18nService","callback","code","onLanguageChangeConfirm","useCallback","WindowService","featureFlagsQuery","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useQueryMemo","QueryClientService","ApplicationBootstrapWithoutAuthorization","useTranslation","confirmationRef","useRef","newLanguageCodeRef","isLanguageChanging","setIsLanguageChanging","useState","i18nService","container","I18nService","callback","code","onLanguageChangeConfirm","useCallback","WindowService","featureFlagsQuery","API_SYSTEM_TOKEN","COMMON_QUERY_KEY","FeatureFlagsService","loadables","useArray","LoadableUtil","ErrorPage","PageContainer","TestIdUtil","Spinner","ResponseHandler","children","Confirmation"],"sources":["../../../../src/components/app/ApplicationBootstrapWithoutAuthorization/ApplicationBootstrapWithoutAuthorization.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport type {\n PropsWithChildren,\n ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\nimport type { ConfirmationRefMethods } from '@gen-epix/ui-core-components/components/Confirmation';\nimport { Confirmation } from '@gen-epix/ui-core-components/components/Confirmation';\nimport { Spinner } from '@gen-epix/ui-core-components/components/Spinner';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\n\nimport { API_SYSTEM_TOKEN } from '../../../constants/api.constants';\nimport { useQueryMemo } from '../../../hooks/useQueryMemo';\nimport { FeatureFlagsService } from '../../../classes/services/FeatureFlagsService';\nimport { I18nService } from '../../../classes/services/I18nService';\nimport { QueryClientService } from '../../../classes/services/QueryClientService';\nimport { PageContainer } from '../../ui/PageContainer';\nimport { ResponseHandler } from '../../ui/ResponseHandler';\nimport { COMMON_QUERY_KEY } from '../../../constants/query.constants';\nimport { LoadableUtil } from '../../../utils/LoadableUtil';\nimport { ErrorPage } from '../../../pages/ErrorPage';\n\n\nexport const ApplicationBootstrapWithoutAuthorization = ({ children }: PropsWithChildren): ReactNode => {\n const { t } = useTranslation();\n\n const confirmationRef = useRef<ConfirmationRefMethods>(null);\n const newLanguageCodeRef = useRef<string>(null);\n const [isLanguageChanging, setIsLanguageChanging] = useState(false);\n\n useEffect(() => {\n const i18nService = container.resolve(I18nService);\n const callback = (code: string) => {\n newLanguageCodeRef.current = code;\n confirmationRef.current?.open();\n };\n i18nService.addEventListener('onUserLanguageChange', callback);\n return () => {\n i18nService.removeEventListener('onUserLanguageChange', callback);\n };\n }, []);\n\n const onLanguageChangeConfirm = useCallback(async () => {\n if (newLanguageCodeRef.current) {\n setIsLanguageChanging(true);\n await container.resolve(I18nService).switchLanguageConfig(newLanguageCodeRef.current);\n container.resolve(WindowService).window.location.reload();\n }\n }, []);\n\n const featureFlagsQuery = useQueryMemo({\n gcTime: Infinity,\n queryFn: async ({ signal }) => (await container.resolve(API_SYSTEM_TOKEN).retrieveFeatureFlags({ signal })).data,\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.FEATURE_FLAGS),\n staleTime: Infinity,\n });\n\n if (featureFlagsQuery.data) {\n container.resolve(FeatureFlagsService).featureFlags = featureFlagsQuery.data.feature_flags;\n }\n\n const loadables = useArray([featureFlagsQuery]);\n\n if (LoadableUtil.hasSomeError(loadables)) {\n return (\n <ErrorPage error={featureFlagsQuery.error} />\n );\n }\n\n if (isLanguageChanging) {\n return (\n <PageContainer\n singleAction\n testIdAttributes={TestIdUtil.createAttributes('LanguageChangingPage')}\n title={t`Changing language`}\n >\n <Spinner\n inline\n label={t`Changing language...`}\n />\n </PageContainer>\n );\n }\n\n return (\n <ResponseHandler\n loadables={loadables}\n loadingMessage={t`Loading`}\n >\n {children}\n <Confirmation\n body={t`Changing language will reload the application. Do you want to continue?`}\n cancelLabel={t`Cancel`}\n confirmLabel={t`Change language`}\n maxWidth={'xs'}\n onConfirm={onLanguageChangeConfirm}\n ref={confirmationRef}\n title={t`Are you sure?`}\n />\n </ResponseHandler>\n );\n\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,IAAaE,KAA4C,EAAE,kBAA6C;CACtG,IAAM,EAAE,SAAMC,EAAe,GAEvBC,IAAkBC,EAA+B,IAAI,GACrDC,IAAqBD,EAAe,IAAI,GACxC,CAACE,GAAoBC,KAAyBC,EAAS,EAAK;CAElE,QAAgB;EACd,IAAMC,IAAcC,EAAU,QAAQC,CAAW,GAC3CC,KAAY,MAAiB;GAEjC,AADA,EAAmB,UAAUC,GAC7BV,EAAgB,SAAS,KAAK;EAChC;EAEA,OADAM,EAAY,iBAAiB,wBAAwBG,CAAQ,SAChD;GACX,EAAY,oBAAoB,wBAAwBA,CAAQ;EAClE;CACF,GAAG,CAAC,CAAC;CAEL,IAAME,IAA0BC,EAAY,YAAY;EACtD,AAAIV,EAAmB,YACrBE,EAAsB,EAAI,GAC1B,MAAMG,EAAU,QAAQC,CAAW,CAAC,CAAC,qBAAqBN,EAAmB,OAAO,GACpFK,EAAU,QAAQM,CAAa,CAAC,CAAC,OAAO,SAAS,OAAO;CAE5D,GAAG,CAAC,CAAC,GAECC,IAAoBlB,EAAa;EACrC,QAAQ;EACR,SAAS,OAAO,EAAE,iBAAc,MAAMW,EAAU,QAAQQ,CAAgB,CAAC,CAAC,qBAAqB,EAAE,UAAO,CAAC,EAAA,CAAG;EAC5G,UAAUR,EAAU,QAAQV,CAAkB,CAAC,CAAC,cAAcmB,EAAiB,aAAa;EAC5F,WAAW;CACb,CAAC;CAED,AAAIF,EAAkB,SACpB,EAAU,QAAQG,CAAmB,CAAC,CAAC,eAAeH,EAAkB,KAAK;CAG/E,IAAMI,IAAYC,EAAS,CAACL,CAAiB,CAAC;CAuB9C,OArBIM,EAAa,aAAaF,CAAS,IAEnC,kBAACG,GAAD,EAAW,OAAOP,EAAkB,MAAQ,CAAA,IAI5CX,IAEA,kBAACmB,GAAD;EACE,cAAA;EACA,kBAAkBC,EAAW,iBAAiB,sBAAsB;EACpE,OAAO,CAAC;EAER,UAAA,kBAACC,GAAD;GACE,QAAA;GACA,OAAO,CAAC;EACT,CAAA;CACY,CAAA,IAKjB,kBAACC,GAAD;EACa;EACX,gBAAgB,CAAC;EAFnB,UAAA,CAIGC,GACD,kBAACC,GAAD;GACE,MAAM,CAAC;GACP,aAAa,CAAC;GACd,cAAc,CAAC;GACf,UAAU;GACV,WAAWhB;GACX,KAAKX;GACL,OAAO,CAAC;EACT,CAAA,CACc;;AAGrB"}
|
|
@@ -3,50 +3,50 @@ import { PageContainer as t } from "../../ui/PageContainer/index.js";
|
|
|
3
3
|
import { AuthenticationService as n } from "../../../classes/services/AuthenticationService/index.js";
|
|
4
4
|
import { LogService as r } from "../../../classes/services/LogService/index.js";
|
|
5
5
|
import { ConsentDialog as i } from "../../ui/ConsentDialog/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { container as a } from "tsyringe";
|
|
7
|
+
import { WindowService as o } from "@gen-epix/ui-core/classes/services/WindowService";
|
|
8
|
+
import { CommonDbLogLevel as s } from "@gen-epix/api-commondb";
|
|
9
|
+
import { Box as c, Button as l, Typography as u } from "@mui/material";
|
|
10
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
11
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
12
12
|
import { useTranslation as y } from "react-i18next";
|
|
13
13
|
import { TestIdUtil as b } from "@gen-epix/ui-core/utils/TestIdUtil";
|
|
14
14
|
import { useSubscribable as x } from "@gen-epix/ui-core/hooks/useSubscribable";
|
|
15
15
|
import { Spinner as S } from "@gen-epix/ui-core-components/components/Spinner";
|
|
16
16
|
import { useAuth as C } from "react-oidc-context";
|
|
17
|
-
|
|
17
|
+
// src/components/app/AuthenticationWrapper/AuthenticationWrapper.tsx
|
|
18
18
|
var w = ({ children: w }) => {
|
|
19
|
-
let { t: T } = y(), E = C(), D = e(), O =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [E]),
|
|
19
|
+
let { t: T } = y(), E = C(), D = e(), O = m(null), [k, A] = h(!D.consentDialog?.getShouldShow()), j = x(a.resolve(n)), M = D.login?.AfterLoginElement;
|
|
20
|
+
f(() => {
|
|
21
|
+
a.resolve(n).authContextProps = E;
|
|
22
|
+
}, [E]), f(() => {
|
|
23
23
|
E.isAuthenticated && !k && O.current.open();
|
|
24
24
|
}, [E.isAuthenticated, k]);
|
|
25
|
-
let N =
|
|
26
|
-
|
|
27
|
-
level:
|
|
25
|
+
let N = d(() => {
|
|
26
|
+
a.resolve(r).log([{
|
|
27
|
+
level: s.INFO,
|
|
28
28
|
topic: "CONSENT"
|
|
29
29
|
}]), A(!0), O.current.close();
|
|
30
|
-
}, []), P =
|
|
30
|
+
}, []), P = d(() => {
|
|
31
31
|
(async () => {
|
|
32
|
-
let { hash: e, pathname: t, search: n } = a.
|
|
32
|
+
let { hash: e, pathname: t, search: n } = a.resolve(o).window.location, r = { preLoginLocation: {
|
|
33
33
|
hash: e,
|
|
34
34
|
pathname: t,
|
|
35
35
|
search: n
|
|
36
36
|
} };
|
|
37
37
|
await E.signinRedirect({ state: r });
|
|
38
38
|
})();
|
|
39
|
-
}, [E]), F =
|
|
39
|
+
}, [E]), F = d(() => {
|
|
40
40
|
P();
|
|
41
|
-
}, [P]), I =
|
|
42
|
-
n.clearStaleState(),
|
|
43
|
-
}, []), L =
|
|
44
|
-
/* @__PURE__ */
|
|
41
|
+
}, [P]), I = d(() => {
|
|
42
|
+
n.clearStaleState(), a.resolve(n).next(void 0);
|
|
43
|
+
}, []), L = p(() => (/* @__PURE__ */ new Date()).getTime(), []), R = p(() => /* @__PURE__ */ v(g, { children: [
|
|
44
|
+
/* @__PURE__ */ _(c, {
|
|
45
45
|
sx: {
|
|
46
46
|
marginY: 2,
|
|
47
47
|
textAlign: "center"
|
|
48
48
|
},
|
|
49
|
-
children: /* @__PURE__ */
|
|
49
|
+
children: /* @__PURE__ */ _(l, {
|
|
50
50
|
color: "primary",
|
|
51
51
|
"data-name": j.name,
|
|
52
52
|
onClick: F,
|
|
@@ -54,19 +54,19 @@ var w = ({ children: w }) => {
|
|
|
54
54
|
children: j.label
|
|
55
55
|
})
|
|
56
56
|
}),
|
|
57
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ _(c, {
|
|
58
58
|
sx: {
|
|
59
59
|
marginY: 2,
|
|
60
60
|
textAlign: "center"
|
|
61
61
|
},
|
|
62
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ _(l, {
|
|
63
63
|
color: "primary",
|
|
64
64
|
onClick: I,
|
|
65
65
|
variant: "outlined",
|
|
66
66
|
children: T`Choose a different identity provider`
|
|
67
67
|
})
|
|
68
68
|
}),
|
|
69
|
-
M && /* @__PURE__ */
|
|
69
|
+
M && /* @__PURE__ */ _(M, {})
|
|
70
70
|
] }), [
|
|
71
71
|
j,
|
|
72
72
|
I,
|
|
@@ -74,54 +74,53 @@ var w = ({ children: w }) => {
|
|
|
74
74
|
T,
|
|
75
75
|
M
|
|
76
76
|
]);
|
|
77
|
-
if (E.activeNavigator || E.isLoading) return /* @__PURE__ */
|
|
77
|
+
if (E.activeNavigator || E.isLoading) return /* @__PURE__ */ _(t, {
|
|
78
78
|
ignorePageEvent: !0,
|
|
79
79
|
singleAction: !0,
|
|
80
80
|
testIdAttributes: b.createAttributes("RedirectingPage"),
|
|
81
81
|
title: T`Redirecting`,
|
|
82
|
-
children: /* @__PURE__ */
|
|
82
|
+
children: /* @__PURE__ */ _(S, { label: T`Redirecting` })
|
|
83
83
|
});
|
|
84
|
-
if (E.error) return n.clearStaleState(),
|
|
84
|
+
if (E.error) return n.clearStaleState(), a.resolve(r).log([{
|
|
85
85
|
detail: { error: E.error },
|
|
86
|
-
level:
|
|
86
|
+
level: s.ERROR,
|
|
87
87
|
topic: "Authentication Error"
|
|
88
|
-
}]), /* @__PURE__ */
|
|
88
|
+
}]), /* @__PURE__ */ v(t, {
|
|
89
89
|
singleAction: !0,
|
|
90
90
|
testIdAttributes: b.createAttributes("LoginPageSessionExpired"),
|
|
91
91
|
title: T`Login`,
|
|
92
|
-
children: [/* @__PURE__ */
|
|
92
|
+
children: [/* @__PURE__ */ _(u, {
|
|
93
93
|
component: "p",
|
|
94
94
|
sx: { textAlign: "center" },
|
|
95
95
|
children: T`We could not log you in, or your session has expired.`
|
|
96
96
|
}), R]
|
|
97
97
|
});
|
|
98
98
|
if (!E.isAuthenticated) {
|
|
99
|
-
if (
|
|
99
|
+
if (a.resolve(n).getUserManagerSettingsCreatedAt() && L - a.resolve(n).getUserManagerSettingsCreatedAt() < n.autoLoginSkew) {
|
|
100
100
|
P();
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
return /* @__PURE__ */
|
|
103
|
+
return /* @__PURE__ */ v(t, {
|
|
104
104
|
singleAction: !0,
|
|
105
105
|
testIdAttributes: b.createAttributes("LoginPage"),
|
|
106
106
|
title: T`Login`,
|
|
107
|
-
children: [/* @__PURE__ */
|
|
107
|
+
children: [/* @__PURE__ */ _(c, {
|
|
108
108
|
sx: {
|
|
109
109
|
marginY: 2,
|
|
110
110
|
textAlign: "center"
|
|
111
111
|
},
|
|
112
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ _(u, {
|
|
113
113
|
component: "p",
|
|
114
114
|
children: T`You need to login to access this application.`
|
|
115
115
|
})
|
|
116
116
|
}), R]
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
return /* @__PURE__ */
|
|
119
|
+
return /* @__PURE__ */ v(g, { children: [w, D.consentDialog?.getShouldShow() && /* @__PURE__ */ _(i, {
|
|
120
120
|
onConsent: N,
|
|
121
121
|
ref: O
|
|
122
122
|
})] });
|
|
123
123
|
};
|
|
124
|
-
//#endregion
|
|
125
124
|
export { w as AuthenticationWrapper };
|
|
126
125
|
|
|
127
126
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Fragment$1","AuthenticationWrapper","useTranslation","auth","useAuth","config","useConfig","consentDialogRef","useRef","hasGivenConsent","setHasGivenConsent","useState","oidcConfiguration","useSubscribable","container","AuthenticationService","AfterLoginElement","useEffect","onConsentDialogConsent","useCallback","LogService","CommonDbLogLevel","login","WindowService","state","onLoginButtonClick","onChangeLoginProviderButtonClick","now","useMemo","loginElement","Box","Button","t","PageContainer","TestIdUtil","Spinner","Typography","children","ConsentDialog"],"sources":["../../../../src/components/app/AuthenticationWrapper/AuthenticationWrapper.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n Box,\n Button,\n Typography,\n} from '@mui/material';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { PropsWithChildren } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useAuth } from 'react-oidc-context';\nimport { CommonDbLogLevel } from '@gen-epix/api-commondb';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Fragment$1","AuthenticationWrapper","useTranslation","auth","useAuth","config","useConfig","consentDialogRef","useRef","hasGivenConsent","setHasGivenConsent","useState","oidcConfiguration","useSubscribable","container","AuthenticationService","AfterLoginElement","useEffect","onConsentDialogConsent","useCallback","LogService","CommonDbLogLevel","login","WindowService","state","onLoginButtonClick","onChangeLoginProviderButtonClick","now","useMemo","loginElement","Box","Button","t","PageContainer","TestIdUtil","Spinner","Typography","children","ConsentDialog"],"sources":["../../../../src/components/app/AuthenticationWrapper/AuthenticationWrapper.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport {\n Box,\n Button,\n Typography,\n} from '@mui/material';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { PropsWithChildren } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useAuth } from 'react-oidc-context';\nimport { CommonDbLogLevel } from '@gen-epix/api-commondb';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { useSubscribable } from '@gen-epix/ui-core/hooks/useSubscribable';\nimport { Spinner } from '@gen-epix/ui-core-components/components/Spinner';\n\nimport { AuthenticationService } from '../../../classes/services/AuthenticationService';\nimport { LogService } from '../../../classes/services/LogService';\nimport { useConfig } from '../../../hooks/useConfig';\nimport type { AuthState } from '../../../models/auth.models';\nimport type { ConsentDialogRefMethods } from '../../ui/ConsentDialog';\nimport { ConsentDialog } from '../../ui/ConsentDialog';\nimport { PageContainer } from '../../ui/PageContainer';\n\nexport const AuthenticationWrapper = ({ children }: PropsWithChildren) => {\n const { t } = useTranslation();\n const auth = useAuth();\n const config = useConfig();\n const consentDialogRef = useRef<ConsentDialogRefMethods>(null);\n const [hasGivenConsent, setHasGivenConsent] = useState<boolean>(\n !config.consentDialog?.getShouldShow(),\n );\n\n const oidcConfiguration = useSubscribable(container.resolve(AuthenticationService));\n const AfterLoginElement = config.login?.AfterLoginElement;\n\n useEffect(() => {\n container.resolve(AuthenticationService).authContextProps = auth;\n }, [auth]);\n\n useEffect(() => {\n if (auth.isAuthenticated && !hasGivenConsent) {\n consentDialogRef.current.open();\n }\n }, [auth.isAuthenticated, hasGivenConsent]);\n\n const onConsentDialogConsent = useCallback(() => {\n container.resolve(LogService).log([\n {\n level: CommonDbLogLevel.INFO,\n topic: 'CONSENT',\n },\n ]);\n setHasGivenConsent(true);\n consentDialogRef.current.close();\n }, []);\n\n const login = useCallback(() => {\n const perform = async () => {\n const { hash, pathname, search } = container.resolve(WindowService).window.location;\n\n const state: AuthState = {\n preLoginLocation: {\n hash,\n pathname,\n search,\n },\n };\n await auth.signinRedirect({\n state,\n });\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n perform();\n }, [auth]);\n\n const onLoginButtonClick = useCallback(() => {\n login();\n }, [login]);\n\n const onChangeLoginProviderButtonClick = useCallback(() => {\n AuthenticationService.clearStaleState();\n container.resolve(AuthenticationService).next(undefined);\n }, []);\n\n const now = useMemo(() => new Date().getTime(), []);\n\n const loginElement = useMemo(\n () => (\n <>\n <Box\n sx={{\n marginY: 2,\n textAlign: 'center',\n }}\n >\n <Button\n color={'primary'}\n data-name={oidcConfiguration.name}\n onClick={onLoginButtonClick}\n variant={'contained'}\n >\n {oidcConfiguration.label}\n </Button>\n </Box>\n <Box\n sx={{\n marginY: 2,\n textAlign: 'center',\n }}\n >\n <Button\n color={'primary'}\n onClick={onChangeLoginProviderButtonClick}\n variant={'outlined'}\n >\n {t`Choose a different identity provider`}\n </Button>\n </Box>\n {AfterLoginElement && <AfterLoginElement />}\n </>\n ), [oidcConfiguration, onChangeLoginProviderButtonClick, onLoginButtonClick, t, AfterLoginElement],\n );\n\n if (auth.activeNavigator || auth.isLoading) {\n return (\n <PageContainer\n ignorePageEvent\n singleAction\n testIdAttributes={TestIdUtil.createAttributes('RedirectingPage')}\n title={t`Redirecting`}\n >\n <Spinner label={t`Redirecting`} />\n </PageContainer>\n );\n }\n\n if (auth.error) {\n AuthenticationService.clearStaleState();\n container.resolve(LogService).log([\n {\n detail: {\n error: auth.error,\n },\n level: CommonDbLogLevel.ERROR,\n topic: 'Authentication Error',\n },\n ]);\n\n return (\n <PageContainer\n singleAction\n testIdAttributes={TestIdUtil.createAttributes(\n 'LoginPageSessionExpired',\n )}\n title={t`Login`}\n >\n <Typography\n component={'p'}\n sx={{ textAlign: 'center' }}\n >\n {t`We could not log you in, or your session has expired.`}\n </Typography>\n {loginElement}\n </PageContainer>\n );\n }\n\n if (!auth.isAuthenticated) {\n if (\n container.resolve(AuthenticationService).getUserManagerSettingsCreatedAt() &&\n now -\n container.resolve(AuthenticationService).getUserManagerSettingsCreatedAt() <\n AuthenticationService.autoLoginSkew\n ) {\n login();\n return;\n }\n return (\n <PageContainer\n singleAction\n testIdAttributes={TestIdUtil.createAttributes('LoginPage')}\n title={t`Login`}\n >\n <Box\n sx={{\n marginY: 2,\n textAlign: 'center',\n }}\n >\n <Typography component={'p'}>\n {t`You need to login to access this application.`}\n </Typography>\n </Box>\n {loginElement}\n </PageContainer>\n );\n }\n\n return (\n <>\n {children}\n {config.consentDialog?.getShouldShow() && (\n <ConsentDialog\n onConsent={onConsentDialogConsent}\n ref={consentDialogRef}\n />\n )}\n </>\n );\n};\n"],"mappings":"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"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as e } from "../../../_chunks/rolldown-runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as n } from "../../../_chunks/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { LoadableUtil as t } from "../../../utils/LoadableUtil/index.js";
|
|
3
|
+
import { t as n } from "../../../_chunks/last.js";
|
|
4
|
+
import { API_ORGANIZATION_TOKEN as r } from "../../../constants/api.constants.js";
|
|
5
|
+
import { AuthorizationService as i } from "../../../classes/services/AuthorizationService/index.js";
|
|
6
|
+
import { PageContainer as a } from "../../ui/PageContainer/index.js";
|
|
7
|
+
import { ResponseHandler as o } from "../../ui/ResponseHandler/index.js";
|
|
8
|
+
import { t as s } from "../../../_chunks/useQueryMemo.js";
|
|
9
|
+
import { t as c } from "../../../_chunks/QueryClientService.js";
|
|
10
10
|
import { COMMON_QUERY_KEY as l } from "../../../constants/query.constants.js";
|
|
11
11
|
import { container as u } from "tsyringe";
|
|
12
12
|
import { useMemo as d } from "react";
|
|
@@ -15,33 +15,32 @@ import { useTranslation as p } from "react-i18next";
|
|
|
15
15
|
import { TestIdUtil as m } from "@gen-epix/ui-core/utils/TestIdUtil";
|
|
16
16
|
import { useMatches as h } from "react-router-dom";
|
|
17
17
|
import { useArray as g } from "@gen-epix/ui-core/hooks/useArray";
|
|
18
|
-
|
|
19
|
-
var _ = /* @__PURE__ */ e(
|
|
20
|
-
let { t } = p(), v = h(), y = d(() => (0, _.default)(v).handle.requiresUserProfile, [v]), b =
|
|
18
|
+
// src/components/app/AuthorizationWrapper/AuthorizationWrapper.tsx
|
|
19
|
+
var _ = /* @__PURE__ */ e(n(), 1), v = ({ children: e }) => {
|
|
20
|
+
let { t: n } = p(), v = h(), y = d(() => (0, _.default)(v).handle.requiresUserProfile, [v]), b = s({
|
|
21
21
|
enabled: y,
|
|
22
22
|
gcTime: Infinity,
|
|
23
|
-
queryFn: async ({ signal: e }) => (await u.resolve(
|
|
24
|
-
queryKey: u.resolve(
|
|
23
|
+
queryFn: async ({ signal: e }) => (await u.resolve(r).userMeGetOne({ signal: e })).data,
|
|
24
|
+
queryKey: u.resolve(c).getGenericKey(l.USER_ME),
|
|
25
25
|
staleTime: Infinity
|
|
26
|
-
}), x =
|
|
26
|
+
}), x = s({
|
|
27
27
|
enabled: y,
|
|
28
28
|
gcTime: Infinity,
|
|
29
|
-
queryFn: async ({ signal: e }) => (await u.resolve(
|
|
30
|
-
queryKey: u.resolve(
|
|
29
|
+
queryFn: async ({ signal: e }) => (await u.resolve(r).userMeRetrievePermissions({ signal: e })).data,
|
|
30
|
+
queryKey: u.resolve(c).getGenericKey(l.USER_PERMISSIONS),
|
|
31
31
|
staleTime: Infinity
|
|
32
32
|
}), S = g([b, x]);
|
|
33
|
-
return b.data && (u.resolve(
|
|
33
|
+
return b.data && (u.resolve(i).user = b.data), x.data && (u.resolve(i).apiPermissions = x.data), y && (t.isSomeLoading(S) || t.hasSomeError(S)) ? /* @__PURE__ */ f(a, {
|
|
34
34
|
ignorePageEvent: !0,
|
|
35
35
|
singleAction: !0,
|
|
36
36
|
testIdAttributes: m.createAttributes("LoadingUserDataPage"),
|
|
37
|
-
title:
|
|
38
|
-
children: /* @__PURE__ */ f(
|
|
37
|
+
title: n`Loading user data`,
|
|
38
|
+
children: /* @__PURE__ */ f(o, {
|
|
39
39
|
loadables: S,
|
|
40
|
-
loadingMessage:
|
|
40
|
+
loadingMessage: n`Loading user data`
|
|
41
41
|
})
|
|
42
42
|
}) : e;
|
|
43
43
|
};
|
|
44
|
-
//#endregion
|
|
45
44
|
export { v as AuthorizationWrapper };
|
|
46
45
|
|
|
47
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["last","__toESM","require_last","
|
|
1
|
+
{"version":3,"file":"index.js","names":["last","__toESM","require_last","useQueryMemo","QueryClientService","import_last","AuthorizationWrapper","useTranslation","matches","useMatches","requiresUserProfile","useMemo","userQuery","container","API_ORGANIZATION_TOKEN","COMMON_QUERY_KEY","userPermissionsQuery","loadables","useArray","AuthorizationService","LoadableUtil","PageContainer","TestIdUtil","ResponseHandler","children"],"sources":["../../../../src/components/app/AuthorizationWrapper/AuthorizationWrapper.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useMemo } from 'react';\nimport type {\n PropsWithChildren,\n ReactNode,\n} from 'react';\nimport { useMatches } from 'react-router-dom';\nimport type { UIMatch } from 'react-router-dom';\nimport { useTranslation } from 'react-i18next';\nimport last from 'lodash/last';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\n\nimport { API_ORGANIZATION_TOKEN } from '../../../constants/api.constants';\nimport { AuthorizationService } from '../../../classes/services/AuthorizationService';\nimport type { MyNonIndexRouteObject } from '../../../models/react-router.models';\nimport { useQueryMemo } from '../../../hooks/useQueryMemo';\nimport { LoadableUtil } from '../../../utils/LoadableUtil';\nimport { PageContainer } from '../../ui/PageContainer';\nimport { ResponseHandler } from '../../ui/ResponseHandler';\nimport { QueryClientService } from '../../../classes/services/QueryClientService';\nimport { COMMON_QUERY_KEY } from '../../../constants/query.constants';\n\nexport const AuthorizationWrapper = ({ children }: PropsWithChildren): ReactNode => {\n const { t } = useTranslation();\n const matches = (useMatches() as UIMatch<unknown, MyNonIndexRouteObject['handle']>[]);\n\n const requiresUserProfile = useMemo(() => last(matches).handle.requiresUserProfile, [matches]);\n\n const userQuery = useQueryMemo({\n enabled: requiresUserProfile,\n gcTime: Infinity,\n queryFn: async ({ signal }) => (await container.resolve(API_ORGANIZATION_TOKEN).userMeGetOne({ signal })).data,\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USER_ME),\n staleTime: Infinity,\n });\n const userPermissionsQuery = useQueryMemo({\n enabled: requiresUserProfile,\n gcTime: Infinity,\n queryFn: async ({ signal }) => (await container.resolve(API_ORGANIZATION_TOKEN).userMeRetrievePermissions({ signal })).data,\n queryKey: container.resolve(QueryClientService).getGenericKey(COMMON_QUERY_KEY.USER_PERMISSIONS),\n staleTime: Infinity,\n });\n\n const loadables = useArray([\n userQuery,\n userPermissionsQuery,\n ]);\n\n\n if (userQuery.data) {\n container.resolve(AuthorizationService).user = userQuery.data;\n }\n if (userPermissionsQuery.data) {\n container.resolve(AuthorizationService).apiPermissions = userPermissionsQuery.data;\n }\n\n if (requiresUserProfile && (LoadableUtil.isSomeLoading(loadables) || LoadableUtil.hasSomeError(loadables))) {\n return (\n <PageContainer\n ignorePageEvent\n singleAction\n testIdAttributes={TestIdUtil.createAttributes('LoadingUserDataPage')}\n title={t`Loading user data`}\n >\n <ResponseHandler\n loadables={loadables}\n loadingMessage={t`Loading user data`}\n />\n </PageContainer>\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;A,mCAuBaM,KAAwB,EAAE,kBAA6C;CAClF,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAAWC,EAAW,GAEtBC,IAAsBC,SAAA,GAAcX,EAAAA,QAAAA,CAAKQ,CAAO,CAAC,CAAC,OAAO,qBAAqB,CAACA,CAAO,CAAC,GAEvFI,IAAYT,EAAa;EAC7B,SAASO;EACT,QAAQ;EACR,SAAS,OAAO,EAAE,iBAAc,MAAMG,EAAU,QAAQC,CAAsB,CAAC,CAAC,aAAa,EAAE,UAAO,CAAC,EAAA,CAAG;EAC1G,UAAUD,EAAU,QAAQT,CAAkB,CAAC,CAAC,cAAcW,EAAiB,OAAO;EACtF,WAAW;CACb,CAAC,GACKC,IAAuBb,EAAa;EACxC,SAASO;EACT,QAAQ;EACR,SAAS,OAAO,EAAE,iBAAc,MAAMG,EAAU,QAAQC,CAAsB,CAAC,CAAC,0BAA0B,EAAE,UAAO,CAAC,EAAA,CAAG;EACvH,UAAUD,EAAU,QAAQT,CAAkB,CAAC,CAAC,cAAcW,EAAiB,gBAAgB;EAC/F,WAAW;CACb,CAAC,GAEKE,IAAYC,EAAS,CACzBN,GACAI,CACF,CAAC;CA0BD,OAvBIJ,EAAU,SACZ,EAAU,QAAQO,CAAoB,CAAC,CAAC,OAAOP,EAAU,OAEvDI,EAAqB,SACvB,EAAU,QAAQG,CAAoB,CAAC,CAAC,iBAAiBH,EAAqB,OAG5EN,MAAwBU,EAAa,cAAcH,CAAS,KAAKG,EAAa,aAAaH,CAAS,KAEpG,kBAACI,GAAD;EACE,iBAAA;EACA,cAAA;EACA,kBAAkBC,EAAW,iBAAiB,qBAAqB;EACnE,OAAO,CAAC;EAER,UAAA,kBAACC,GAAD;GACa;GACX,gBAAgB,CAAC;EAClB,CAAA;CACY,CAAA,IAIZC;AACT"}
|