@databiosphere/findable-ui 34.1.0 → 35.0.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +26 -0
- package/lib/components/DataDictionary/components/Table/columns/columnDef.d.ts +6 -0
- package/lib/components/DataDictionary/components/Table/columns/columnDef.js +33 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.d.ts +5 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.js +5 -0
- package/lib/components/DataDictionary/components/Table/columns/types.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +4 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.js +1 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.d.ts +8 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.js +36 -0
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +25 -0
- package/lib/components/Filter/components/Filter/filter.stories.js +42 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +16 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +17 -0
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/filters.stories.js +91 -0
- package/lib/components/Index/components/Cell/cell.d.ts +7 -0
- package/lib/components/Index/components/Cell/cell.js +10 -0
- package/lib/components/Index/components/EntitiesView/constants.d.ts +1 -0
- package/lib/components/Index/components/EntitiesView/constants.js +1 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.d.ts +13 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.js +18 -0
- package/lib/components/Index/components/Hero/hero.stories.d.ts +23 -0
- package/lib/components/Index/components/Hero/hero.stories.js +22 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.d.ts +8 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.js +57 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.d.ts +4 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.js +10 -0
- package/lib/components/Index/components/NTag/nTag.d.ts +10 -0
- package/lib/components/Index/components/NTag/nTag.js +8 -0
- package/lib/components/Index/components/NTagCell/nTagCell.d.ts +11 -0
- package/lib/components/Index/components/NTagCell/nTagCell.js +29 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.d.ts +5 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.js +16 -0
- package/lib/components/Index/components/TitleCell/titleCell.d.ts +6 -0
- package/lib/components/Index/components/TitleCell/titleCell.js +10 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.d.ts +3 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.js +6 -0
- package/lib/components/Index/index.stories.d.ts +6 -0
- package/lib/components/Index/index.stories.js +26 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.d.ts +6 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.js +29 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.d.ts +6 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +13 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.js +9 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.js +9 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
- package/lib/components/Layout/components/Outline/common/constants.d.ts +2 -0
- package/lib/components/Layout/components/Outline/common/constants.js +1 -0
- package/lib/components/Login/login.stories.d.ts +6 -0
- package/lib/components/Login/login.stories.js +31 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +16 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +28 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +5 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +46 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +3 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +21 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.d.ts +2 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.js +37 -0
- package/lib/components/TableCreator/common/constants.d.ts +6 -0
- package/lib/components/TableCreator/common/constants.js +19 -0
- package/lib/components/TableCreator/common/entities.d.ts +5 -0
- package/lib/components/TableCreator/common/entities.js +1 -0
- package/lib/components/TableCreator/tableCreator.styles.d.ts +4 -0
- package/lib/components/TableCreator/tableCreator.styles.js +4 -0
- package/lib/components/common/Alert/alert.stories.d.ts +6 -0
- package/lib/components/common/Alert/alert.stories.js +36 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +4 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.js +19 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.d.ts +7 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.js +5 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.js +19 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.d.ts +10 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.js +16 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.js +21 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.d.ts +3 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.js +6 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.d.ts +7 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.js +11 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.d.ts +5 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.js +10 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.d.ts +3 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.js +9 -0
- package/lib/hooks/stateSyncManager/hook.d.ts +19 -0
- package/lib/hooks/stateSyncManager/hook.js +35 -0
- package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.d.ts +1 -0
- package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.js +21 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.d.ts +2 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.js +23 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/types.d.ts +4 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.d.ts +2 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.js +40 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.d.ts +30 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.js +41 -0
- package/lib/hooks/stateSyncManager/types.d.ts +26 -0
- package/lib/hooks/stateSyncManager/types.js +1 -0
- package/lib/hooks/useAuthentication/common/constants.d.ts +4 -0
- package/lib/hooks/useAuthentication/common/constants.js +19 -0
- package/lib/hooks/useAuthentication/common/entities.d.ts +25 -0
- package/lib/hooks/useAuthentication/common/entities.js +11 -0
- package/lib/hooks/useAuthentication/common/utils.d.ts +15 -0
- package/lib/hooks/useAuthentication/common/utils.js +25 -0
- package/lib/hooks/useAuthentication/useAuthentication.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthentication.js +9 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.js +55 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.js +88 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.d.ts +18 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.js +50 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.js +32 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.d.ts +21 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.js +41 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.d.ts +18 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.d.ts +24 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.d.ts +15 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.js +62 -0
- package/lib/hooks/useAuthentication/useTokenClient.d.ts +11 -0
- package/lib/hooks/useAuthentication/useTokenClient.js +29 -0
- package/lib/hooks/useAuthenticationConfig.d.ts +6 -0
- package/lib/hooks/useAuthenticationConfig.js +14 -0
- package/lib/hooks/useCategoryConfigs.d.ts +6 -0
- package/lib/hooks/useCategoryConfigs.js +17 -0
- package/lib/hooks/useEntityListRelatedView.d.ts +15 -0
- package/lib/hooks/useEntityListRelatedView.js +62 -0
- package/lib/hooks/useExploreMode.d.ts +14 -0
- package/lib/hooks/useExploreMode.js +20 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +15 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +27 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +5 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.js +11 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +9 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.js +37 -0
- package/lib/hooks/useLayoutState.d.ts +6 -0
- package/lib/hooks/useLayoutState.js +9 -0
- package/lib/hooks/useMenu.d.ts +10 -0
- package/lib/hooks/useMenu.js +17 -0
- package/lib/hooks/useMenuWithPosition.d.ts +14 -0
- package/lib/hooks/useMenuWithPosition.js +33 -0
- package/lib/hooks/useSessionTimeout.d.ts +11 -0
- package/lib/hooks/useSessionTimeout.js +28 -0
- package/lib/providers/authentication.d.ts +51 -0
- package/lib/providers/authentication.js +110 -0
- package/lib/providers/exploreState/actions/stateToUrl/action.d.ts +9 -0
- package/lib/providers/exploreState/actions/stateToUrl/action.js +14 -0
- package/lib/providers/exploreState/actions/stateToUrl/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/{syncStateFromUrl → stateToUrl}/dispatch.js +3 -3
- package/lib/providers/exploreState/actions/stateToUrl/types.d.ts +12 -0
- package/lib/providers/exploreState/actions/stateToUrl/types.js +5 -0
- package/lib/providers/exploreState/actions/urlToState/action.d.ts +9 -0
- package/lib/providers/exploreState/actions/urlToState/action.js +38 -0
- package/lib/providers/exploreState/actions/urlToState/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/urlToState/dispatch.js +12 -0
- package/lib/providers/exploreState/actions/urlToState/types.d.ts +9 -0
- package/lib/providers/exploreState/actions/urlToState/types.js +1 -0
- package/lib/providers/exploreState/actions/urlToState/utils.d.ts +7 -0
- package/lib/providers/exploreState/actions/urlToState/utils.js +13 -0
- package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.d.ts → exploreState/entities/query/buildQuery.d.ts} +10 -14
- package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.js → exploreState/entities/query/buildQuery.js} +13 -21
- package/lib/providers/exploreState/entities/state.d.ts +10 -0
- package/lib/providers/exploreState/entities/state.js +36 -0
- package/lib/providers/exploreState/entities/types.d.ts +16 -0
- package/lib/providers/exploreState/entities/types.js +1 -0
- package/lib/providers/exploreState/entities.d.ts +1 -1
- package/lib/providers/exploreState/initializer/constants.js +1 -0
- package/lib/providers/exploreState/initializer/utils.js +26 -1
- package/lib/providers/exploreState.d.ts +8 -4
- package/lib/providers/exploreState.js +20 -15
- package/lib/providers/layoutState.d.ts +40 -0
- package/lib/providers/layoutState.js +47 -0
- package/lib/providers/services/provider.d.ts +14 -0
- package/lib/providers/services/provider.js +18 -0
- package/lib/providers/services/wasPop/context.d.ts +2 -0
- package/lib/providers/services/wasPop/context.js +5 -0
- package/lib/providers/services/wasPop/hook.d.ts +2 -0
- package/lib/providers/services/wasPop/hook.js +5 -0
- package/lib/providers/services/wasPop/provider.d.ts +16 -0
- package/lib/providers/services/wasPop/provider.js +30 -0
- package/lib/providers/services/wasPop/types.d.ts +6 -0
- package/lib/providers/services/wasPop/types.js +1 -0
- package/lib/services/beforePopState/popStateBus.d.ts +20 -0
- package/lib/services/beforePopState/popStateBus.js +58 -0
- package/lib/services/beforePopState/types.d.ts +11 -0
- package/lib/services/beforePopState/types.js +1 -0
- package/lib/services/beforePopState/useOnPopState.d.ts +2 -0
- package/lib/services/beforePopState/useOnPopState.js +10 -0
- package/lib/services/beforePopState/usePopStateBus.d.ts +6 -0
- package/lib/services/beforePopState/usePopStateBus.js +12 -0
- package/lib/styles/common/mixins/shadows.d.ts +3 -0
- package/lib/styles/common/mixins/shadows.js +4 -0
- package/lib/styles/common/mui/palette.d.ts +47 -0
- package/lib/styles/common/mui/palette.js +47 -0
- package/lib/theme/common/entities.d.ts +6 -0
- package/lib/theme/common/entities.js +1 -0
- package/lib/views/ExploreView/exploreView.js +15 -2
- package/lib/views/ExploreView/utils.d.ts +14 -0
- package/lib/views/ExploreView/utils.js +17 -0
- package/package.json +1 -1
- package/src/hooks/stateSyncManager/hook.ts +47 -0
- package/src/hooks/stateSyncManager/hooks/UseBeforePopState/hook.ts +30 -0
- package/src/hooks/stateSyncManager/hooks/UseMetaCommands/hook.ts +30 -0
- package/src/hooks/stateSyncManager/hooks/UseMetaCommands/types.ts +4 -0
- package/src/hooks/stateSyncManager/hooks/UseStateSync/hook.ts +52 -0
- package/src/hooks/stateSyncManager/hooks/UseStateSync/utils.ts +58 -0
- package/src/hooks/stateSyncManager/types.ts +34 -0
- package/src/providers/exploreState/actions/stateToUrl/action.ts +20 -0
- package/src/providers/exploreState/actions/stateToUrl/dispatch.ts +14 -0
- package/src/providers/exploreState/actions/stateToUrl/types.ts +15 -0
- package/src/providers/exploreState/actions/urlToState/action.ts +74 -0
- package/src/providers/exploreState/actions/urlToState/dispatch.ts +14 -0
- package/src/providers/exploreState/actions/urlToState/types.ts +11 -0
- package/src/providers/exploreState/actions/urlToState/utils.ts +18 -0
- package/src/providers/{exploreStateSync/hooks/UseMetaCommands/utils.ts → exploreState/entities/query/buildQuery.ts} +23 -26
- package/src/providers/exploreState/entities/state.ts +50 -0
- package/src/providers/exploreState/entities/types.ts +19 -0
- package/src/providers/exploreState/entities.ts +1 -1
- package/src/providers/exploreState/initializer/constants.ts +1 -0
- package/src/providers/exploreState/initializer/utils.ts +30 -1
- package/src/providers/exploreState.tsx +27 -20
- package/src/providers/services/provider.tsx +25 -0
- package/src/providers/services/wasPop/context.ts +7 -0
- package/src/providers/services/wasPop/hook.ts +7 -0
- package/src/providers/services/wasPop/provider.tsx +45 -0
- package/src/providers/services/wasPop/types.ts +7 -0
- package/src/services/beforePopState/popStateBus.ts +64 -0
- package/src/services/beforePopState/types.ts +15 -0
- package/src/services/beforePopState/useOnPopState.ts +15 -0
- package/src/services/beforePopState/usePopStateBus.ts +14 -0
- package/src/views/ExploreView/exploreView.tsx +17 -3
- package/src/views/ExploreView/utils.ts +25 -0
- package/lib/providers/exploreState/actions/syncStateFromUrl/action.d.ts +0 -10
- package/lib/providers/exploreState/actions/syncStateFromUrl/action.js +0 -25
- package/lib/providers/exploreState/actions/syncStateFromUrl/dispatch.d.ts +0 -7
- package/lib/providers/exploreState/actions/syncStateFromUrl/types.d.ts +0 -8
- package/lib/providers/exploreState/actions/syncStateFromUrl/utils.d.ts +0 -9
- package/lib/providers/exploreState/actions/syncStateFromUrl/utils.js +0 -23
- package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.d.ts +0 -18
- package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.js +0 -41
- package/lib/providers/exploreState/hooks/UseBeforePopState/utils.d.ts +0 -23
- package/lib/providers/exploreState/hooks/UseBeforePopState/utils.js +0 -68
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +0 -10
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +0 -18
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +0 -1
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +0 -33
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +0 -11
- package/lib/providers/exploreStateSync/provider.d.ts +0 -19
- package/lib/providers/exploreStateSync/provider.js +0 -22
- package/src/providers/exploreState/actions/syncStateFromUrl/action.ts +0 -44
- package/src/providers/exploreState/actions/syncStateFromUrl/dispatch.ts +0 -16
- package/src/providers/exploreState/actions/syncStateFromUrl/types.ts +0 -13
- package/src/providers/exploreState/actions/syncStateFromUrl/utils.ts +0 -31
- package/src/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.ts +0 -46
- package/src/providers/exploreState/hooks/UseBeforePopState/utils.ts +0 -93
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +0 -25
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +0 -38
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +0 -13
- package/src/providers/exploreStateSync/provider.tsx +0 -29
- /package/lib/{providers/exploreState/actions/syncStateFromUrl → components/DataDictionary/components/Table/columns}/types.js +0 -0
- /package/lib/{providers/exploreStateSync → hooks/stateSyncManager}/hooks/UseMetaCommands/types.js +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEntityListRelatedView = exports.buildRelatedEntityList = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const exploreState_1 = require("../providers/exploreState");
|
|
6
|
+
const useAsync_1 = require("./useAsync");
|
|
7
|
+
const useConfig_1 = require("./useConfig");
|
|
8
|
+
const useExploreState_1 = require("./useExploreState");
|
|
9
|
+
/**
|
|
10
|
+
* Returns related entity lists filtered by related search results.
|
|
11
|
+
* @param listItems - Entity list items.
|
|
12
|
+
* @param relatedSearchResult - Related search result.
|
|
13
|
+
* @param excludedValues - Selected category values to be excluded from related entity lists.
|
|
14
|
+
* @returns related entities.
|
|
15
|
+
*/
|
|
16
|
+
function buildRelatedEntityList(listItems, relatedSearchResult, excludedValues) {
|
|
17
|
+
if (relatedSearchResult) {
|
|
18
|
+
const { resultKey, searchKey, values } = relatedSearchResult;
|
|
19
|
+
return listItems === null || listItems === void 0 ? void 0 : listItems.filter((listItem) => {
|
|
20
|
+
if (values.includes(listItem[resultKey].toLowerCase())) {
|
|
21
|
+
return !(excludedValues === null || excludedValues === void 0 ? void 0 : excludedValues.includes(listItem[searchKey])); // Exclude any row where any of the selected category values matches the corresponding row value.
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.buildRelatedEntityList = buildRelatedEntityList;
|
|
27
|
+
/**
|
|
28
|
+
* Updates related entity list.
|
|
29
|
+
*/
|
|
30
|
+
const useEntityListRelatedView = () => {
|
|
31
|
+
var _a;
|
|
32
|
+
const { entityConfig } = (0, useConfig_1.useConfig)();
|
|
33
|
+
const { exploreDispatch, exploreState } = (0, useExploreState_1.useExploreState)();
|
|
34
|
+
const { filterState, listItems } = exploreState;
|
|
35
|
+
const { listView } = entityConfig;
|
|
36
|
+
const relatedView = listView === null || listView === void 0 ? void 0 : listView.relatedView;
|
|
37
|
+
const { relatedSearchFn, resultKey, searchKey } = relatedView || {};
|
|
38
|
+
const { data: relatedSearchResult, run } = (0, useAsync_1.useAsync)();
|
|
39
|
+
const selectedCategoryValues = (_a = filterState.find(({ categoryKey }) => categoryKey === searchKey)) === null || _a === void 0 ? void 0 : _a.value;
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
if (relatedSearchFn) {
|
|
42
|
+
run(relatedSearchFn(searchKey, resultKey, selectedCategoryValues));
|
|
43
|
+
}
|
|
44
|
+
}, [relatedSearchFn, resultKey, run, searchKey, selectedCategoryValues]);
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
if (relatedSearchFn) {
|
|
47
|
+
exploreDispatch({
|
|
48
|
+
payload: {
|
|
49
|
+
relatedListItems: buildRelatedEntityList(listItems, relatedSearchResult, selectedCategoryValues),
|
|
50
|
+
},
|
|
51
|
+
type: exploreState_1.ExploreActionKind.ProcessRelatedResponse,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
exploreDispatch,
|
|
56
|
+
listItems,
|
|
57
|
+
relatedSearchFn,
|
|
58
|
+
relatedSearchResult,
|
|
59
|
+
selectedCategoryValues,
|
|
60
|
+
]);
|
|
61
|
+
};
|
|
62
|
+
exports.useEntityListRelatedView = useEntityListRelatedView;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ExploreMode = EXPLORE_MODE;
|
|
2
|
+
export declare enum EXPLORE_MODE {
|
|
3
|
+
CS_FETCH_CS_FILTERING = "CS_FETCH_CS_FILTERING",
|
|
4
|
+
SS_FETCH_CS_FILTERING = "SS_FETCH_CS_FILTERING",
|
|
5
|
+
SS_FETCH_SS_FILTERING = "SS_FETCH_SS_FILTERING"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns configured explore mode:
|
|
9
|
+
* - Client-side fetch, client-side filtering.
|
|
10
|
+
* - Server-side fetch, client-side filtering.
|
|
11
|
+
* - Server-side fetch, server-side filtering.
|
|
12
|
+
* @returns explore mode.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useExploreMode: () => ExploreMode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useConfig } from "./useConfig";
|
|
3
|
+
export var EXPLORE_MODE;
|
|
4
|
+
(function (EXPLORE_MODE) {
|
|
5
|
+
EXPLORE_MODE["CS_FETCH_CS_FILTERING"] = "CS_FETCH_CS_FILTERING";
|
|
6
|
+
EXPLORE_MODE["SS_FETCH_CS_FILTERING"] = "SS_FETCH_CS_FILTERING";
|
|
7
|
+
EXPLORE_MODE["SS_FETCH_SS_FILTERING"] = "SS_FETCH_SS_FILTERING";
|
|
8
|
+
})(EXPLORE_MODE || (EXPLORE_MODE = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Returns configured explore mode:
|
|
11
|
+
* - Client-side fetch, client-side filtering.
|
|
12
|
+
* - Server-side fetch, client-side filtering.
|
|
13
|
+
* - Server-side fetch, server-side filtering.
|
|
14
|
+
* @returns explore mode.
|
|
15
|
+
*/
|
|
16
|
+
export const useExploreMode = () => {
|
|
17
|
+
const { entityConfig } = useConfig();
|
|
18
|
+
const { exploreMode } = entityConfig;
|
|
19
|
+
return useMemo(() => exploreMode, [exploreMode]);
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ManifestDownloadFormat } from "../../../apis/azul/common/entities";
|
|
2
|
+
import { Filters } from "../../../common/entities";
|
|
3
|
+
export interface FileManifestRequestURL {
|
|
4
|
+
requestParams: URLSearchParams;
|
|
5
|
+
requestURL: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Build up file manifest request params and URL query string for the given search results, catalog and format.
|
|
9
|
+
* @param url - Data URL.
|
|
10
|
+
* @param filters - Selected filters.
|
|
11
|
+
* @param catalog - Configured catalog.
|
|
12
|
+
* @param manifestFormat - Manifest format.
|
|
13
|
+
* @returns file manifest request params and URL query string.
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildFileManifestRequestURL: (url: string, filters: Filters, catalog: string, manifestFormat: ManifestDownloadFormat | undefined) => FileManifestRequestURL | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AZUL_PARAM, } from "../../../apis/azul/common/entities";
|
|
2
|
+
import { transformFilters } from "../../../apis/azul/common/filterTransformer";
|
|
3
|
+
/**
|
|
4
|
+
* Build up file manifest request params and URL query string for the given search results, catalog and format.
|
|
5
|
+
* @param url - Data URL.
|
|
6
|
+
* @param filters - Selected filters.
|
|
7
|
+
* @param catalog - Configured catalog.
|
|
8
|
+
* @param manifestFormat - Manifest format.
|
|
9
|
+
* @returns file manifest request params and URL query string.
|
|
10
|
+
*/
|
|
11
|
+
export const buildFileManifestRequestURL = (url, filters, catalog, manifestFormat) => {
|
|
12
|
+
if (!manifestFormat) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
// Build request params.
|
|
16
|
+
const requestParams = new URLSearchParams({
|
|
17
|
+
[AZUL_PARAM.CATALOG]: catalog,
|
|
18
|
+
[AZUL_PARAM.FILTERS]: transformFilters(filters),
|
|
19
|
+
format: manifestFormat,
|
|
20
|
+
});
|
|
21
|
+
// Build file manifest URL
|
|
22
|
+
const requestURL = `${url}fetch/manifest/files?${requestParams.toString()}`;
|
|
23
|
+
return {
|
|
24
|
+
requestParams,
|
|
25
|
+
requestURL,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useConfig } from "../useConfig";
|
|
2
|
+
/**
|
|
3
|
+
* Returns data URL for the integrations end point.
|
|
4
|
+
* @returns data URL for the integrations end point.
|
|
5
|
+
*/
|
|
6
|
+
export const useFileManifestURL = () => {
|
|
7
|
+
const { config } = useConfig();
|
|
8
|
+
const { dataSource } = config;
|
|
9
|
+
const { url } = dataSource;
|
|
10
|
+
return url;
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManifestDownloadFormat } from "../../apis/azul/common/entities";
|
|
2
|
+
import { Filters } from "../../common/entities";
|
|
3
|
+
/**
|
|
4
|
+
* Initializes and fetches file manifest comprising file facets and summary for the given file manifest format.
|
|
5
|
+
* @param fileManifestFormat - File manifest format.
|
|
6
|
+
* @param initialFilters - Filters to initialize file manifest request.
|
|
7
|
+
* @param fileSummaryFacetName - File summary facet name.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useRequestFileManifest: (fileManifestFormat: ManifestDownloadFormat | undefined, initialFilters?: Filters | undefined, fileSummaryFacetName?: string) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { FileManifestActionKind } from "../../providers/fileManifestState";
|
|
3
|
+
import { useFileManifestState } from "../useFileManifestState";
|
|
4
|
+
/**
|
|
5
|
+
* Initializes and fetches file manifest comprising file facets and summary for the given file manifest format.
|
|
6
|
+
* @param fileManifestFormat - File manifest format.
|
|
7
|
+
* @param initialFilters - Filters to initialize file manifest request.
|
|
8
|
+
* @param fileSummaryFacetName - File summary facet name.
|
|
9
|
+
*/
|
|
10
|
+
export const useRequestFileManifest = (fileManifestFormat, initialFilters = [], fileSummaryFacetName) => {
|
|
11
|
+
// Initial file manifest filter.
|
|
12
|
+
const [initFilters] = useState(() => initialFilters);
|
|
13
|
+
// File manifest state.
|
|
14
|
+
const { fileManifestDispatch } = useFileManifestState();
|
|
15
|
+
// Fetches file manifest with the given file manifest filters, format.
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
fileManifestDispatch({
|
|
18
|
+
payload: {
|
|
19
|
+
fileManifestFormat,
|
|
20
|
+
fileSummaryFacetName,
|
|
21
|
+
filters: initFilters,
|
|
22
|
+
},
|
|
23
|
+
type: FileManifestActionKind.FetchFileManifest,
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
fileManifestDispatch({
|
|
27
|
+
payload: undefined,
|
|
28
|
+
type: FileManifestActionKind.ClearFileManifest,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}, [
|
|
32
|
+
fileManifestDispatch,
|
|
33
|
+
fileManifestFormat,
|
|
34
|
+
fileSummaryFacetName,
|
|
35
|
+
initFilters,
|
|
36
|
+
]);
|
|
37
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { LayoutStateContext, } from "../providers/layoutState";
|
|
3
|
+
/**
|
|
4
|
+
* Returns layout state context.
|
|
5
|
+
* @returns layout state context.
|
|
6
|
+
*/
|
|
7
|
+
export const useLayoutState = () => {
|
|
8
|
+
return useContext(LayoutStateContext);
|
|
9
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Menu functionality for menu dropdown.
|
|
4
|
+
* @returns menu functionality.
|
|
5
|
+
*/
|
|
6
|
+
export const useMenu = () => {
|
|
7
|
+
const [open, setOpen] = useState(false);
|
|
8
|
+
// Closes header menu.
|
|
9
|
+
const onClose = useCallback(() => {
|
|
10
|
+
setOpen(false);
|
|
11
|
+
}, []);
|
|
12
|
+
// Opens header menu.
|
|
13
|
+
const onOpen = useCallback(() => {
|
|
14
|
+
setOpen(true);
|
|
15
|
+
}, []);
|
|
16
|
+
return { onClose, onOpen, open };
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MenuProps as MMenuProps } from "@mui/material";
|
|
2
|
+
import { MouseEvent } from "react";
|
|
3
|
+
export interface UseMenuWithPosition {
|
|
4
|
+
anchorEl: MMenuProps["anchorEl"];
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onOpen: (event: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
onToggleOpen: (event: MouseEvent<HTMLElement>) => void;
|
|
8
|
+
open: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Menu functionality for menu dropdown, with menu position.
|
|
12
|
+
* @returns menu functionality.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useMenuWithPosition: () => UseMenuWithPosition;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Menu functionality for menu dropdown, with menu position.
|
|
4
|
+
* @returns menu functionality.
|
|
5
|
+
*/
|
|
6
|
+
export const useMenuWithPosition = () => {
|
|
7
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
8
|
+
const open = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
|
9
|
+
// Closes header menu.
|
|
10
|
+
const onClose = useCallback(() => {
|
|
11
|
+
setAnchorEl(null);
|
|
12
|
+
}, []);
|
|
13
|
+
// Opens header menu.
|
|
14
|
+
const onOpen = useCallback((event) => {
|
|
15
|
+
setAnchorEl(event.currentTarget);
|
|
16
|
+
}, []);
|
|
17
|
+
// Toggles menu open/close.
|
|
18
|
+
const onToggleOpen = useCallback((event) => {
|
|
19
|
+
if (open) {
|
|
20
|
+
setAnchorEl(null);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
setAnchorEl(event.currentTarget);
|
|
24
|
+
}
|
|
25
|
+
}, [open]);
|
|
26
|
+
return {
|
|
27
|
+
anchorEl,
|
|
28
|
+
onClose,
|
|
29
|
+
onOpen,
|
|
30
|
+
onToggleOpen,
|
|
31
|
+
open,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const INACTIVITY_PARAM = "inactivityTimeout";
|
|
2
|
+
interface UseSessionTimeout {
|
|
3
|
+
clearSessionTimeout: () => void;
|
|
4
|
+
isSessionTimeout: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Session timeout hook.
|
|
8
|
+
* @returns flag indicating if the session has timed out.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useSessionTimeout: () => UseSessionTimeout;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Router from "next/router";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { useConfig } from "./useConfig";
|
|
4
|
+
import { useLocation } from "./useLocation";
|
|
5
|
+
export const INACTIVITY_PARAM = "inactivityTimeout";
|
|
6
|
+
/**
|
|
7
|
+
* Session timeout hook.
|
|
8
|
+
* @returns flag indicating if the session has timed out.
|
|
9
|
+
*/
|
|
10
|
+
export const useSessionTimeout = () => {
|
|
11
|
+
const { config: { redirectRootToPath }, } = useConfig();
|
|
12
|
+
const [isSessionTimeout, setIsSessionTimeout] = useState(false);
|
|
13
|
+
// Get the session timeout from URL parameters.
|
|
14
|
+
const { search } = useLocation() || {};
|
|
15
|
+
const sessionTimeout = search?.get(INACTIVITY_PARAM);
|
|
16
|
+
// Clears session timeout state.
|
|
17
|
+
const clearSessionTimeout = useCallback(() => {
|
|
18
|
+
setIsSessionTimeout(false);
|
|
19
|
+
Router.replace(redirectRootToPath);
|
|
20
|
+
}, [redirectRootToPath]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setIsSessionTimeout(sessionTimeout === "true");
|
|
23
|
+
}, [sessionTimeout]);
|
|
24
|
+
return {
|
|
25
|
+
clearSessionTimeout,
|
|
26
|
+
isSessionTimeout,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { AUTHENTICATION_STATUS, LoginStatus } from "../hooks/useAuthentication/common/entities";
|
|
3
|
+
import { UserProfile } from "../hooks/useAuthentication/useFetchGoogleProfile";
|
|
4
|
+
import { TerraNIHResponse } from "../hooks/useAuthentication/useFetchTerraNIHProfile";
|
|
5
|
+
import { TerraResponse } from "../hooks/useAuthentication/useFetchTerraProfile";
|
|
6
|
+
import { TerraTermsOfServiceResponse } from "../hooks/useAuthentication/useFetchTerraTermsOfService";
|
|
7
|
+
export declare const ROUTE_LOGIN = "/login";
|
|
8
|
+
type AuthenticateUserFn = () => void;
|
|
9
|
+
type RequestAuthenticationFn = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Model of authentication context.
|
|
12
|
+
*/
|
|
13
|
+
export interface AuthContextProps {
|
|
14
|
+
authenticateUser: AuthenticateUserFn;
|
|
15
|
+
authenticationStatus: AUTHENTICATION_STATUS;
|
|
16
|
+
isAuthenticated: boolean;
|
|
17
|
+
isEnabled: boolean;
|
|
18
|
+
requestAuthentication: RequestAuthenticationFn;
|
|
19
|
+
terraNIHProfileLoginStatus: LoginStatus<TerraNIHResponse>;
|
|
20
|
+
terraProfileLoginStatus: LoginStatus<TerraResponse>;
|
|
21
|
+
terraTOSLoginStatus: LoginStatus<TerraTermsOfServiceResponse>;
|
|
22
|
+
token?: string;
|
|
23
|
+
userProfile?: UserProfile;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Auth context for storing and using auth-related state.
|
|
27
|
+
*/
|
|
28
|
+
export declare const AuthContext: React.Context<AuthContextProps>;
|
|
29
|
+
interface Props {
|
|
30
|
+
children: ReactNode | ReactNode[];
|
|
31
|
+
sessionTimeout?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Auth provider for consuming components to subscribe to changes in auth-related state.
|
|
35
|
+
* @param props - Component inputs.
|
|
36
|
+
* @param props.children - Set of children components that can possibly consume the query provider.
|
|
37
|
+
* @param props.sessionTimeout - If provided, will set the value for a session timeout (in milliseconds).
|
|
38
|
+
* @returns Provider element to be used by consumers to both update authentication state and subscribe to changes in authentication state.
|
|
39
|
+
*/
|
|
40
|
+
export declare function AuthProvider({ children, sessionTimeout }: Props): JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* Token is released for the following conditions:
|
|
43
|
+
* - Terra endpoint is configured and the terms of service response is successful, or
|
|
44
|
+
* - Terra endpoint is not configured and the user profile response is successful.
|
|
45
|
+
* @param userProfileLoginStatus - User profile login status.
|
|
46
|
+
* @param terraProfileLoginStatus - Terra profile login status.
|
|
47
|
+
* @param terraTOSLoginStatus - Terra terms of service login status.
|
|
48
|
+
* @returns true if the token should be released.
|
|
49
|
+
*/
|
|
50
|
+
export declare function shouldReleaseToken(userProfileLoginStatus: LoginStatus<UserProfile>, terraProfileLoginStatus: LoginStatus<TerraResponse>, terraTOSLoginStatus: LoginStatus<TerraTermsOfServiceResponse>): boolean;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import Router, { useRouter } from "next/router";
|
|
2
|
+
import React, { createContext, useCallback } from "react";
|
|
3
|
+
import { useIdleTimer } from "react-idle-timer";
|
|
4
|
+
import { LOGIN_STATUS_NOT_STARTED } from "../hooks/useAuthentication/common/constants";
|
|
5
|
+
import { AUTHENTICATION_STATUS, } from "../hooks/useAuthentication/common/entities";
|
|
6
|
+
import { useAuthenticationComplete } from "../hooks/useAuthentication/useAuthenticationComplete";
|
|
7
|
+
import { useAuthenticationStatus } from "../hooks/useAuthentication/useAuthenticationStatus";
|
|
8
|
+
import { useFetchGoogleProfile, } from "../hooks/useAuthentication/useFetchGoogleProfile";
|
|
9
|
+
import { useFetchTerraNIHProfile, } from "../hooks/useAuthentication/useFetchTerraNIHProfile";
|
|
10
|
+
import { useFetchTerraProfile, } from "../hooks/useAuthentication/useFetchTerraProfile";
|
|
11
|
+
import { useFetchTerraTermsOfService, } from "../hooks/useAuthentication/useFetchTerraTermsOfService";
|
|
12
|
+
import { useTokenClient } from "../hooks/useAuthentication/useTokenClient";
|
|
13
|
+
import { useConfig } from "../hooks/useConfig";
|
|
14
|
+
import { INACTIVITY_PARAM } from "../hooks/useSessionTimeout";
|
|
15
|
+
// Template constants
|
|
16
|
+
export const ROUTE_LOGIN = "/login";
|
|
17
|
+
/**
|
|
18
|
+
* Auth context for storing and using auth-related state.
|
|
19
|
+
*/
|
|
20
|
+
export const AuthContext = createContext({
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- allow dummy function for default state.
|
|
22
|
+
authenticateUser: () => { },
|
|
23
|
+
authenticationStatus: AUTHENTICATION_STATUS.INCOMPLETE,
|
|
24
|
+
isAuthenticated: false,
|
|
25
|
+
isEnabled: false,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- allow dummy function for default state.
|
|
27
|
+
requestAuthentication: () => { },
|
|
28
|
+
terraNIHProfileLoginStatus: LOGIN_STATUS_NOT_STARTED,
|
|
29
|
+
terraProfileLoginStatus: LOGIN_STATUS_NOT_STARTED,
|
|
30
|
+
terraTOSLoginStatus: LOGIN_STATUS_NOT_STARTED,
|
|
31
|
+
token: undefined,
|
|
32
|
+
userProfile: undefined,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Auth provider for consuming components to subscribe to changes in auth-related state.
|
|
36
|
+
* @param props - Component inputs.
|
|
37
|
+
* @param props.children - Set of children components that can possibly consume the query provider.
|
|
38
|
+
* @param props.sessionTimeout - If provided, will set the value for a session timeout (in milliseconds).
|
|
39
|
+
* @returns Provider element to be used by consumers to both update authentication state and subscribe to changes in authentication state.
|
|
40
|
+
*/
|
|
41
|
+
export function AuthProvider({ children, sessionTimeout }) {
|
|
42
|
+
const { config } = useConfig();
|
|
43
|
+
const { authentication, redirectRootToPath } = config;
|
|
44
|
+
const { basePath } = useRouter();
|
|
45
|
+
const { token, tokenClient } = useTokenClient();
|
|
46
|
+
const terraNIHProfileLoginStatus = useFetchTerraNIHProfile(token);
|
|
47
|
+
const terraProfileLoginStatus = useFetchTerraProfile(token);
|
|
48
|
+
const terraTOSLoginStatus = useFetchTerraTermsOfService(token);
|
|
49
|
+
const userProfileLoginStatus = useFetchGoogleProfile(token);
|
|
50
|
+
const isEnabled = Boolean(authentication);
|
|
51
|
+
const isAuthenticated = userProfileLoginStatus.isSuccess;
|
|
52
|
+
const releaseToken = shouldReleaseToken(userProfileLoginStatus, terraProfileLoginStatus, terraTOSLoginStatus);
|
|
53
|
+
const authenticationStatus = useAuthenticationStatus(userProfileLoginStatus, terraProfileLoginStatus, terraTOSLoginStatus, terraNIHProfileLoginStatus);
|
|
54
|
+
// Handle completion of authentication process.
|
|
55
|
+
useAuthenticationComplete(authenticationStatus);
|
|
56
|
+
/**
|
|
57
|
+
* If sessionTimeout is set and user is authenticated, the app will reload and redirect to
|
|
58
|
+
* origin, including base path, root path, and query param.
|
|
59
|
+
*/
|
|
60
|
+
useIdleTimer({
|
|
61
|
+
onIdle: () => isAuthenticated &&
|
|
62
|
+
sessionTimeout &&
|
|
63
|
+
(window.location.href =
|
|
64
|
+
window.location.origin +
|
|
65
|
+
basePath +
|
|
66
|
+
redirectRootToPath +
|
|
67
|
+
"?" +
|
|
68
|
+
`${INACTIVITY_PARAM}=true`),
|
|
69
|
+
timeout: sessionTimeout,
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Requests access token and authenticates user.
|
|
73
|
+
*/
|
|
74
|
+
const authenticateUser = useCallback(() => {
|
|
75
|
+
tokenClient.requestAccessToken();
|
|
76
|
+
}, [tokenClient]);
|
|
77
|
+
/**
|
|
78
|
+
* Navigates to login page.
|
|
79
|
+
*/
|
|
80
|
+
const requestAuthentication = useCallback(() => {
|
|
81
|
+
Router.push(ROUTE_LOGIN);
|
|
82
|
+
}, []);
|
|
83
|
+
return (React.createElement(AuthContext.Provider, { value: {
|
|
84
|
+
authenticateUser,
|
|
85
|
+
authenticationStatus,
|
|
86
|
+
isAuthenticated,
|
|
87
|
+
isEnabled,
|
|
88
|
+
requestAuthentication,
|
|
89
|
+
terraNIHProfileLoginStatus,
|
|
90
|
+
terraProfileLoginStatus,
|
|
91
|
+
terraTOSLoginStatus,
|
|
92
|
+
token: releaseToken ? token : undefined,
|
|
93
|
+
userProfile: userProfileLoginStatus.response,
|
|
94
|
+
} }, children));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Token is released for the following conditions:
|
|
98
|
+
* - Terra endpoint is configured and the terms of service response is successful, or
|
|
99
|
+
* - Terra endpoint is not configured and the user profile response is successful.
|
|
100
|
+
* @param userProfileLoginStatus - User profile login status.
|
|
101
|
+
* @param terraProfileLoginStatus - Terra profile login status.
|
|
102
|
+
* @param terraTOSLoginStatus - Terra terms of service login status.
|
|
103
|
+
* @returns true if the token should be released.
|
|
104
|
+
*/
|
|
105
|
+
export function shouldReleaseToken(userProfileLoginStatus, terraProfileLoginStatus, terraTOSLoginStatus) {
|
|
106
|
+
if (terraProfileLoginStatus.isSupported) {
|
|
107
|
+
return terraTOSLoginStatus.isSuccess;
|
|
108
|
+
}
|
|
109
|
+
return userProfileLoginStatus.isSuccess;
|
|
110
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExploreState } from "../../../exploreState";
|
|
2
|
+
import { StateToUrlPayload } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Reducer function to handle the "state >> URL sync" action.
|
|
5
|
+
* @param state - State.
|
|
6
|
+
* @param payload - Payload.
|
|
7
|
+
* @returns state.
|
|
8
|
+
*/
|
|
9
|
+
export declare function stateToUrlAction(state: ExploreState, payload: StateToUrlPayload): ExploreState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { META_COMMAND } from "../../../../hooks/stateSyncManager/hooks/UseMetaCommands/types";
|
|
2
|
+
import { ROUTER_METHOD } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Reducer function to handle the "state >> URL sync" action.
|
|
5
|
+
* @param state - State.
|
|
6
|
+
* @param payload - Payload.
|
|
7
|
+
* @returns state.
|
|
8
|
+
*/
|
|
9
|
+
export function stateToUrlAction(state, payload) {
|
|
10
|
+
const command = payload.method === ROUTER_METHOD.PUSH
|
|
11
|
+
? META_COMMAND.STATE_TO_URL_PUSH
|
|
12
|
+
: META_COMMAND.STATE_TO_URL_REPLACE;
|
|
13
|
+
return { ...state, meta: { command } };
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StateToUrlAction, StateToUrlPayload } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Action creator for state >> URL sync.
|
|
4
|
+
* @param payload - Payload.
|
|
5
|
+
* @returns Action with payload and action type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function stateToUrl(payload: StateToUrlPayload): StateToUrlAction;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ExploreActionKind } from "../../../exploreState";
|
|
2
2
|
/**
|
|
3
|
-
* Action creator for
|
|
3
|
+
* Action creator for state >> URL sync.
|
|
4
4
|
* @param payload - Payload.
|
|
5
5
|
* @returns Action with payload and action type.
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function stateToUrl(payload) {
|
|
8
8
|
return {
|
|
9
9
|
payload,
|
|
10
|
-
type: ExploreActionKind.
|
|
10
|
+
type: ExploreActionKind.StateToUrl,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExploreActionKind } from "../../../exploreState";
|
|
2
|
+
export declare enum ROUTER_METHOD {
|
|
3
|
+
PUSH = "push",
|
|
4
|
+
REPLACE = "replace"
|
|
5
|
+
}
|
|
6
|
+
export type StateToUrlAction = {
|
|
7
|
+
payload: StateToUrlPayload;
|
|
8
|
+
type: ExploreActionKind.StateToUrl;
|
|
9
|
+
};
|
|
10
|
+
export type StateToUrlPayload = {
|
|
11
|
+
method: ROUTER_METHOD;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExploreState } from "../../../exploreState";
|
|
2
|
+
import { UrlToStatePayload } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Reducer function to handle the "URL >> state sync" action.
|
|
5
|
+
* @param state - State.
|
|
6
|
+
* @param payload - Payload.
|
|
7
|
+
* @returns state.
|
|
8
|
+
*/
|
|
9
|
+
export declare function urlToStateAction(state: ExploreState, payload: UrlToStatePayload): ExploreState;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
|
|
2
|
+
import { buildNextEntities } from "../../entities/state";
|
|
3
|
+
import { getEntityCategoryGroupConfigKey, getFilterCount, updateEntityStateByCategoryGroupConfigKey, } from "../../utils";
|
|
4
|
+
import { decodeFilterParamValue } from "./utils";
|
|
5
|
+
/**
|
|
6
|
+
* Reducer function to handle the "URL >> state sync" action.
|
|
7
|
+
* @param state - State.
|
|
8
|
+
* @param payload - Payload.
|
|
9
|
+
* @returns state.
|
|
10
|
+
*/
|
|
11
|
+
export function urlToStateAction(state, payload) {
|
|
12
|
+
const { query } = payload;
|
|
13
|
+
// Get the entity list type from the query.
|
|
14
|
+
const { entityListType } = query;
|
|
15
|
+
// If the entityListType is not a string, return the current state.
|
|
16
|
+
if (typeof entityListType !== "string")
|
|
17
|
+
return state;
|
|
18
|
+
// Decode the catalog param value to catalog state.
|
|
19
|
+
const catalogState = query[EXPLORE_URL_PARAMS.CATALOG];
|
|
20
|
+
// Decode the filter param value to selected filters.
|
|
21
|
+
const filterState = decodeFilterParamValue(query[EXPLORE_URL_PARAMS.FILTER]);
|
|
22
|
+
// Decode the feature flag param value to feature flag state.
|
|
23
|
+
const featureFlagState = query[EXPLORE_URL_PARAMS.FEATURE_FLAG];
|
|
24
|
+
// Grab the category group config key for the entityListType.
|
|
25
|
+
const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(entityListType, state.entityPageState);
|
|
26
|
+
// Update the entity state by category group config key.
|
|
27
|
+
updateEntityStateByCategoryGroupConfigKey(state, { filterState, savedFilterState: [] }, categoryGroupConfigKey);
|
|
28
|
+
return {
|
|
29
|
+
...state,
|
|
30
|
+
catalogState,
|
|
31
|
+
entities: buildNextEntities({ ...state, catalogState, featureFlagState }, entityListType, { filterState }),
|
|
32
|
+
featureFlagState,
|
|
33
|
+
filterCount: entityListType === state.tabValue
|
|
34
|
+
? getFilterCount(filterState)
|
|
35
|
+
: state.filterCount,
|
|
36
|
+
filterState: entityListType === state.tabValue ? filterState : state.filterState,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UrlToStateAction, UrlToStatePayload } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Action creator for URL >> state sync.
|
|
4
|
+
* @param payload - Payload.
|
|
5
|
+
* @returns Action with payload and action type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function urlToState(payload: UrlToStatePayload): UrlToStateAction;
|