@gen3/frontend 0.11.25 → 0.11.27
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/dist/cjs/index.js +257 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/dts/components/Buttons/index.d.ts +1 -0
- package/dist/dts/components/Buttons/index.d.ts.map +1 -1
- package/dist/dts/components/Buttons/index.js +1 -0
- package/dist/dts/components/Buttons/index.js.map +1 -1
- package/dist/dts/components/Providers/Gen3Provider.d.ts +6 -6
- package/dist/dts/components/SegmentedControl.stories.d.ts +374 -0
- package/dist/dts/components/SegmentedControl.stories.d.ts.map +1 -0
- package/dist/dts/components/SegmentedControl.stories.js +28 -0
- package/dist/dts/components/SegmentedControl.stories.js.map +1 -0
- package/dist/dts/features/Analysis/AnalysisCardCompact.stories.d.ts +4 -4
- package/dist/dts/features/CohortBuilder/ExplorerTable/AccessCellRenderers.d.ts +3 -0
- package/dist/dts/features/CohortBuilder/ExplorerTable/AccessCellRenderers.d.ts.map +1 -0
- package/dist/dts/features/CohortBuilder/ExplorerTable/AccessCellRenderers.js +46 -0
- package/dist/dts/features/CohortBuilder/ExplorerTable/AccessCellRenderers.js.map +1 -0
- package/dist/dts/features/CohortBuilder/ExplorerTable/ArrayCellRenderer.d.ts +1 -1
- package/dist/dts/features/CohortBuilder/Repository/Repository.d.ts +4 -0
- package/dist/dts/features/CohortBuilder/Repository/Repository.d.ts.map +1 -0
- package/dist/dts/features/CohortBuilder/Repository/Repository.js +8 -0
- package/dist/dts/features/CohortBuilder/Repository/Repository.js.map +1 -0
- package/dist/dts/features/CohortBuilder/Repository/index.d.ts +4 -0
- package/dist/dts/features/CohortBuilder/Repository/index.d.ts.map +1 -0
- package/dist/dts/features/CohortBuilder/Repository/index.js +3 -0
- package/dist/dts/features/CohortBuilder/Repository/index.js.map +1 -0
- package/dist/dts/features/CohortBuilder/Repository/types.d.ts +12 -0
- package/dist/dts/features/CohortBuilder/Repository/types.d.ts.map +1 -0
- package/dist/dts/features/CohortBuilder/Repository/types.js.map +1 -0
- package/dist/dts/lib/session/session.d.ts.map +1 -1
- package/dist/dts/lib/session/session.js +36 -1
- package/dist/dts/lib/session/session.js.map +1 -1
- package/dist/dts/pages/Repository/Repository.d.ts +4 -0
- package/dist/dts/pages/Repository/Repository.d.ts.map +1 -0
- package/dist/dts/pages/Repository/Repository.js +24 -0
- package/dist/dts/pages/Repository/Repository.js.map +1 -0
- package/dist/dts/pages/Repository/data.d.ts +4 -0
- package/dist/dts/pages/Repository/data.d.ts.map +1 -0
- package/dist/dts/{features/CohortBuilder/CohortManager/cohortActionHooks.js → pages/Repository/data.js} +55 -42
- package/dist/dts/pages/Repository/data.js.map +1 -0
- package/dist/dts/pages/Repository/index.d.ts +4 -0
- package/dist/dts/pages/Repository/index.d.ts.map +1 -0
- package/dist/dts/pages/Repository/index.js +4 -0
- package/dist/dts/pages/Repository/index.js.map +1 -0
- package/dist/dts/pages/Repository/types.d.ts +6 -0
- package/dist/dts/pages/Repository/types.d.ts.map +1 -0
- package/dist/dts/pages/Repository/types.js +2 -0
- package/dist/dts/pages/Repository/types.js.map +1 -0
- package/dist/dts/types/icons.d.ts +2 -2
- package/dist/dts/types/icons.d.ts.map +1 -1
- package/dist/dts/types/icons.js +2 -2
- package/dist/dts/types/icons.js.map +1 -1
- package/dist/esm/index.js +259 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/dts/components/DropdownMenu/DropdownMenu.d.ts +0 -64
- package/dist/dts/components/DropdownMenu/DropdownMenu.d.ts.map +0 -1
- package/dist/dts/components/DropdownMenu/DropdownMenu.js +0 -38
- package/dist/dts/components/DropdownMenu/DropdownMenu.js.map +0 -1
- package/dist/dts/components/DropdownMenu/DropdownMenu.unit.test.d.ts +0 -2
- package/dist/dts/components/DropdownMenu/DropdownMenu.unit.test.d.ts.map +0 -1
- package/dist/dts/components/DropdownMenu/DropdownMenu.unit.test.js +0 -141
- package/dist/dts/components/DropdownMenu/DropdownMenu.unit.test.js.map +0 -1
- package/dist/dts/components/DropdownMenu/index.d.ts +0 -3
- package/dist/dts/components/DropdownMenu/index.d.ts.map +0 -1
- package/dist/dts/components/DropdownMenu/index.js +0 -3
- package/dist/dts/components/DropdownMenu/index.js.map +0 -1
- package/dist/dts/components/MessageCards/ErrorMessage.d.ts +0 -7
- package/dist/dts/components/MessageCards/ErrorMessage.d.ts.map +0 -1
- package/dist/dts/components/MessageCards/ErrorMessage.js +0 -8
- package/dist/dts/components/MessageCards/ErrorMessage.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortActions.d.ts +0 -20
- package/dist/dts/features/CohortBuilder/CohortManager/CohortActions.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortActions.js +0 -37
- package/dist/dts/features/CohortBuilder/CohortManager/CohortActions.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotificationProvider.d.ts +0 -9
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotificationProvider.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotificationProvider.js +0 -122
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotificationProvider.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotifications.d.ts +0 -19
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotifications.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotifications.js +0 -52
- package/dist/dts/features/CohortBuilder/CohortManager/CohortNotifications.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortSelector.d.ts +0 -10
- package/dist/dts/features/CohortBuilder/CohortManager/CohortSelector.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CohortSelector.js +0 -37
- package/dist/dts/features/CohortBuilder/CohortManager/CohortSelector.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CustomCohortSelectItem.d.ts +0 -13
- package/dist/dts/features/CohortBuilder/CohortManager/CustomCohortSelectItem.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/CustomCohortSelectItem.js +0 -33
- package/dist/dts/features/CohortBuilder/CohortManager/CustomCohortSelectItem.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/cohortActionHooks.d.ts +0 -7
- package/dist/dts/features/CohortBuilder/CohortManager/cohortActionHooks.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/cohortActionHooks.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/commonIcons.d.ts +0 -5
- package/dist/dts/features/CohortBuilder/CohortManager/commonIcons.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/commonIcons.js +0 -5
- package/dist/dts/features/CohortBuilder/CohortManager/commonIcons.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/index.d.ts +0 -5
- package/dist/dts/features/CohortBuilder/CohortManager/index.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/index.js +0 -4
- package/dist/dts/features/CohortBuilder/CohortManager/index.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/GenericCohortModal.d.ts +0 -13
- package/dist/dts/features/CohortBuilder/CohortManager/modals/GenericCohortModal.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/GenericCohortModal.js +0 -15
- package/dist/dts/features/CohortBuilder/CohortManager/modals/GenericCohortModal.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortErrorModal.d.ts +0 -4
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortErrorModal.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortErrorModal.js +0 -8
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortErrorModal.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.d.ts +0 -32
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.js +0 -190
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.unit.test.d.ts +0 -2
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.unit.test.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.unit.test.js +0 -145
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveCohortModal.unit.test.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveOrCreateEntityModal.d.ts +0 -29
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveOrCreateEntityModal.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveOrCreateEntityModal.js +0 -79
- package/dist/dts/features/CohortBuilder/CohortManager/modals/SaveOrCreateEntityModal.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/style.d.ts +0 -5
- package/dist/dts/features/CohortBuilder/CohortManager/style.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/style.js +0 -21
- package/dist/dts/features/CohortBuilder/CohortManager/style.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/types.d.ts +0 -49
- package/dist/dts/features/CohortBuilder/CohortManager/types.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager/types.js.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager.d.ts +0 -6
- package/dist/dts/features/CohortBuilder/CohortManager.d.ts.map +0 -1
- package/dist/dts/features/CohortBuilder/CohortManager.js +0 -8
- package/dist/dts/features/CohortBuilder/CohortManager.js.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortStorage.d.ts +0 -64
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortStorage.d.ts.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortStorage.js +0 -572
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortStorage.js.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSelectors.d.ts +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSelectors.d.ts.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSelectors.js +0 -41
- package/dist/dts/features/CohortDiscovery/CohortSelectors.js.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSlice.d.ts +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSlice.d.ts.map +0 -1
- package/dist/dts/features/CohortDiscovery/CohortSlice.js +0 -162
- package/dist/dts/features/CohortDiscovery/CohortSlice.js.map +0 -1
- package/dist/dts/features/CohortDiscovery/SavedCohortManagerSlice.d.ts +0 -1
- package/dist/dts/features/CohortDiscovery/SavedCohortManagerSlice.d.ts.map +0 -1
- package/dist/dts/features/CohortDiscovery/SavedCohortManagerSlice.js +0 -284
- package/dist/dts/features/CohortDiscovery/SavedCohortManagerSlice.js.map +0 -1
- /package/dist/dts/features/CohortBuilder/{CohortManager → Repository}/types.js +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { createContext, useState, useMemo, useEffect, useCallback, useContext,
|
|
3
|
+
import React__default, { createContext, useState, useMemo, useEffect, useRef, useCallback, useContext, createElement, forwardRef, useReducer } from 'react';
|
|
4
4
|
import { useUserAuth, useCoreSelector, selectUserDetails, useGetAuthzMappingsQuery, fetchFence, isFetchError, WorkspaceStatus, useGetWorkspaceStatusQuery, useGetWorkspacePayModelsQuery, useTerminateWorkspaceMutation, selectRequestedWorkspaceStatus, selectRequestedWorkspaceStatusTimestamp, useCoreDispatch, setActiveWorkspaceStatus, RequestedWorkspaceStatus, setRequestedWorkspaceStatus, isTimeGreaterThan, useGetCSRFQuery, useLazyFetchUserDetailsQuery, selectUserAuthStatus, GEN3_REDIRECT_URL, GEN3_FENCE_API, showModal, Modals, isAuthenticated, useGetLoginProvidersQuery, hideModal, selectCurrentModal, fieldNameToTitle, isOperationWithField, extractEnumFilterValue, selectIndexedFilterByName, selectShouldShareFilters, selectSharedFilters, updateCohortFilter as updateCohortFilter$1, isOperatorWithFieldAndArrayOfOperands, isUnion, removeCohortFilter as removeCohortFilter$1, trimFirstFieldNameToTitle, selectAllCohortFiltersCollapsed, Accessibility, toggleCohortBuilderAllFilters, setShouldShareFilters, useIsUserLoggedIn, GEN3_DOMAIN, useDataLibrary, DataLibraryStoreMode, buildListItemsGroupedByDataset, extractFileDatasetsInRecords, useGetMDSQuery, selectAuthzMappingData, useGetAggMDSQuery, useAskQuestionMutation, useGetIndexAggMDSQuery, useGetTagsQuery, useGetRawDataAndTotalCountsQuery, selectIndexFilters, isJSONValue, downloadFromGuppyToBlob, downloadJSONDataFromGuppy, toggleCohortBuilderCategoryFilter, selectCohortFilterExpanded, setCohortFilterCombineMode, selectCohortFilterCombineMode, selectCohortFilters, setCohortFilter as setCohortFilter$1, clearCohortFilters as clearCohortFilters$1, handleOperation, selectAvailableCohorts, selectCurrentCohortId as selectCurrentCohortId$1, selectCurrentCohortModified, selectCurrentCohortSaved, setCohortIndexFilters, setCurrentCohortId as setCurrentCohortId$1, selectCurrentCohortName as selectCurrentCohortName$1, useGetAggsQuery, useGetAggsNoFilterSelfQuery, isIntersection, useGetCountsQuery, selectAllCohorts as selectAllCohorts$1, selectCurrentCohort as selectCurrentCohort$1, isIndexedFilterSetEmpty, removeCohort as removeCohort$1, updateCohortName as updateCohortName$1, createNewCohort as createNewCohort$1, duplicateCohort, setSharedFilters, usePrevious, selectHeadersWithCSRFToken, GEN3_GUPPY_API, useLaunchWorkspaceMutation, selectActiveWorkspaceStatus, isFetchBaseQueryError, setActiveWorkspace, getCurrentTimestamp, selectWorkspaceStatusFromService, selectActiveWorkspaceId, useGetWorkspaceOptionsQuery, GEN3_WORKSPACE_API, useGetExternalLoginsQuery, useSetCurrentPayModelMutation, PodStatus, PodConditionType, isWorkspaceRunningOrStopping, GEN3_API, GEN3_COMMONS_NAME, CohortStorage, createAppStore, getRemoteSupportServiceRegistry, isHttpStatusError, MissingServiceConfigurationError, useLazyGetAggsNoFilterSelfQuery, useCreateRequestMutation, buildGetAggregationQuery, processHistogramResponse, roundHistogramResponse, selectCSRFToken, useUserRequestQuery, getGen3AppId, createGen3AppWithOwnStore, useGeneralGQLQuery, createAppApiForRTKQ, useGetDictionaryQuery, useGetMetadataByIdQuery, createGen3App, CoreProvider, fetchJSONDataFromURL, HttpMethod, groupSharedFields, useGetCredentialsQuery, useRemoveCredentialMutation, useAddNewCredentialMutation, useGetProjectsDetailsQuery, useGetSubmissionsQuery, isCohortItem, isFileItem, fetchFencePresignedURL, HTTPError, getFederatedLoginStatus, queryMultipleMDSRecords, GEN3_MANIFEST_API, extractIndexFromDataLibraryCohort, isFilterSet, getNumberOfItemsInDatalist, isAdditionalDataItem, useLazyGetCrosswalkDataQuery } from '@gen3/core';
|
|
5
5
|
import { LoadingOverlay, Card, Group, Avatar, Text, Checkbox, Stack, Center, Loader, Tooltip, UnstyledButton, ThemeIcon, Box, Select, Button, Divider, Textarea, FileButton, Anchor, Modal, Grid, Table, ColorSwatch, useMantineTheme, Accordion, Switch, SegmentedControl as SegmentedControl$1, ActionIcon, Badge, TextInput, NumberInput, RangeSlider, MultiSelect, Tabs, SimpleGrid, Highlight, MantineProvider, Flex, Menu, Alert, Drawer, CopyButton, factory, useProps, getStyleObject, Paper, useCombobox, Combobox, ScrollArea, Autocomplete, Title, Transition, rem, Stepper, Spoiler, Image as Image$1, NavLink, List, createTheme, Pagination, FileInput, CloseButton } from '@mantine/core';
|
|
6
6
|
import { useDeepCompareEffect, useDeepCompareMemo, useDeepCompareCallback } from 'use-deep-compare';
|
|
@@ -12,7 +12,7 @@ import useSWR from 'swr';
|
|
|
12
12
|
import { errors, importSPKI, jwtVerify, decodeJwt } from 'jose';
|
|
13
13
|
import { notifications, showNotification, cleanNotifications, Notifications } from '@mantine/notifications';
|
|
14
14
|
import tinycolor from 'tinycolor2';
|
|
15
|
-
import { capitalize as capitalize$1, toString, isArray, get, omit, partial, cloneDeep, unset } from 'lodash';
|
|
15
|
+
import { capitalize as capitalize$1, toString, isArray, uniqueId, reduce, includes, isPlainObject, get, omit, partial, cloneDeep, unset } from 'lodash';
|
|
16
16
|
import { twMerge } from 'tailwind-merge';
|
|
17
17
|
import { BsExclamationTriangle, BsArrowsFullscreen } from 'react-icons/bs';
|
|
18
18
|
import { IoMdInformationCircleOutline, IoMdArrowDropdown, IoMdRefresh, IoMdLogIn } from 'react-icons/io';
|
|
@@ -45,7 +45,7 @@ import MiniSearch from 'minisearch';
|
|
|
45
45
|
import uniq from 'lodash/uniq';
|
|
46
46
|
import sum from 'lodash/sum';
|
|
47
47
|
import { LuCircleSlash, LuClock, LuLock, LuUnlock } from 'react-icons/lu';
|
|
48
|
-
import 'universal-cookie';
|
|
48
|
+
import Cookies from 'universal-cookie';
|
|
49
49
|
import GraphiQL from 'graphiql';
|
|
50
50
|
import fs from 'fs';
|
|
51
51
|
import path from 'path';
|
|
@@ -860,6 +860,7 @@ const workspaceShutdownAlertLimit = 30000; // 5 minutes: 5 * 60 * 1000 TODO Figu
|
|
|
860
860
|
}
|
|
861
861
|
};
|
|
862
862
|
|
|
863
|
+
const ACTIVITY_CHANNEL = 'gen3-user-activity';
|
|
863
864
|
const logoutSession = async ()=>{
|
|
864
865
|
// logged in using credentials then execute credentials logout first
|
|
865
866
|
const accessToken = getCookie('credentials_token');
|
|
@@ -943,6 +944,27 @@ const UPDATE_SESSION_LIMIT = MinutesToMilliseconds(5);
|
|
|
943
944
|
const [getUserDetails] = useLazyFetchUserDetailsQuery(); // Fetch user details
|
|
944
945
|
const userStatus = useCoreSelector((state)=>selectUserAuthStatus(state));
|
|
945
946
|
const [mostRecentActivityTimestamp, setMostRecentActivityTimestamp] = useState(Date.now());
|
|
947
|
+
const broadcastChannelRef = useRef(null);
|
|
948
|
+
// Initialize BroadcastChannel for cross-tab communication
|
|
949
|
+
// any user event on one tab or window will update mostRecentActivityTimestamp
|
|
950
|
+
useEffect(()=>{
|
|
951
|
+
if (typeof window !== 'undefined') {
|
|
952
|
+
broadcastChannelRef.current = new BroadcastChannel(ACTIVITY_CHANNEL);
|
|
953
|
+
// Listen for activity updates from other tabs
|
|
954
|
+
const handleActivityMessage = (event)=>{
|
|
955
|
+
if (event.data.type === 'activity-update') {
|
|
956
|
+
setMostRecentActivityTimestamp(event.data.timestamp);
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
broadcastChannelRef.current.addEventListener('message', handleActivityMessage);
|
|
960
|
+
return ()=>{
|
|
961
|
+
if (broadcastChannelRef.current) {
|
|
962
|
+
broadcastChannelRef.current.removeEventListener('message', handleActivityMessage);
|
|
963
|
+
broadcastChannelRef.current.close();
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
}, []);
|
|
946
968
|
const [mostRecentSessionRefreshTimestamp, setMostRecentSessionRefreshTimestamp] = useState(Date.now());
|
|
947
969
|
const inactiveTimeLimitMilliseconds = MinutesToMilliseconds(inactiveTimeLimit);
|
|
948
970
|
const workspaceInactivityTimeLimitMilliseconds = MinutesToMilliseconds(workspaceInactivityTimeLimit);
|
|
@@ -979,15 +1001,28 @@ const UPDATE_SESSION_LIMIT = MinutesToMilliseconds(5);
|
|
|
979
1001
|
updateSession();
|
|
980
1002
|
if (updateSessionIntervalMilliseconds <= 0) return; // do not poll if updateSessionInterval is 0
|
|
981
1003
|
const updateUserActivity = ()=>{
|
|
982
|
-
|
|
1004
|
+
const timestamp = Date.now();
|
|
1005
|
+
setMostRecentActivityTimestamp(timestamp);
|
|
1006
|
+
if (broadcastChannelRef.current) {
|
|
1007
|
+
broadcastChannelRef.current.postMessage({
|
|
1008
|
+
type: 'activity-update',
|
|
1009
|
+
timestamp
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
983
1012
|
};
|
|
984
1013
|
window.addEventListener('mousedown', updateUserActivity);
|
|
985
1014
|
window.addEventListener('keypress', updateUserActivity);
|
|
986
1015
|
window.addEventListener('updateUserActivity', updateUserActivity);
|
|
1016
|
+
window.addEventListener('scroll', updateUserActivity);
|
|
1017
|
+
window.addEventListener('click', updateUserActivity);
|
|
1018
|
+
window.addEventListener('touchstart', updateUserActivity);
|
|
987
1019
|
return ()=>{
|
|
988
1020
|
window.removeEventListener('mousedown', updateUserActivity);
|
|
989
1021
|
window.removeEventListener('keypress', updateUserActivity);
|
|
990
1022
|
window.removeEventListener('updateUserActivity', updateUserActivity);
|
|
1023
|
+
window.removeEventListener('scroll', updateUserActivity);
|
|
1024
|
+
window.removeEventListener('click', updateUserActivity);
|
|
1025
|
+
window.removeEventListener('touchstart', updateUserActivity);
|
|
991
1026
|
};
|
|
992
1027
|
}, []); // only call on mount/dismount
|
|
993
1028
|
useInterval(()=>{
|
|
@@ -1413,7 +1448,7 @@ const CredentialsLogin = ({ handleLogin })=>{
|
|
|
1413
1448
|
};
|
|
1414
1449
|
|
|
1415
1450
|
// separate function for hashing logic
|
|
1416
|
-
function hashString(str) {
|
|
1451
|
+
function hashString$1(str) {
|
|
1417
1452
|
let hash = 0;
|
|
1418
1453
|
for(let i = 0; i < str.length; i++){
|
|
1419
1454
|
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
@@ -1425,7 +1460,7 @@ function hashCode(str) {
|
|
|
1425
1460
|
if (str === null || str === '') {
|
|
1426
1461
|
return 0;
|
|
1427
1462
|
}
|
|
1428
|
-
return hashString(str);
|
|
1463
|
+
return hashString$1(str);
|
|
1429
1464
|
}
|
|
1430
1465
|
|
|
1431
1466
|
/**
|
|
@@ -11161,6 +11196,22 @@ const CountsValue = ({ label, isSuccess, counts })=>{
|
|
|
11161
11196
|
});
|
|
11162
11197
|
};
|
|
11163
11198
|
|
|
11199
|
+
const hashString = (s)=>s.split('').reduce((acc, c)=>(acc << 5) - acc + c.charCodeAt(0), 0);
|
|
11200
|
+
const getBody = (iframe)=>{
|
|
11201
|
+
const document1 = iframe?.contentWindow || iframe?.contentDocument;
|
|
11202
|
+
return document1?.document?.body || document1?.body;
|
|
11203
|
+
};
|
|
11204
|
+
const toHtml = (key, value)=>`<input
|
|
11205
|
+
type="hidden"
|
|
11206
|
+
name="${key}"
|
|
11207
|
+
value="${isPlainObject(value) ? JSON.stringify(value).replace(/"/g, '"') : value}"
|
|
11208
|
+
/>`;
|
|
11209
|
+
const customKeys = [
|
|
11210
|
+
'expand',
|
|
11211
|
+
'fields',
|
|
11212
|
+
'facets'
|
|
11213
|
+
];
|
|
11214
|
+
const processParamObj = (key, value)=>includes(customKeys, key) ? [].concat(value).join() : value;
|
|
11164
11215
|
/**
|
|
11165
11216
|
* A notification box that is used to alert the user that their
|
|
11166
11217
|
* selected file downloads are in progress
|
|
@@ -11186,6 +11237,136 @@ const CountsValue = ({ label, isSuccess, counts })=>{
|
|
|
11186
11237
|
]
|
|
11187
11238
|
});
|
|
11188
11239
|
};
|
|
11240
|
+
/**
|
|
11241
|
+
* Trigger a download by attaching an iFrame to the document with the parameters of the request as fields in a form
|
|
11242
|
+
* @param endpoint - endpoint to be attached with
|
|
11243
|
+
* @param params - body to be attached with post request
|
|
11244
|
+
* @param method - Request Method: GET, PUT, POST
|
|
11245
|
+
* @param dispatch - dispatch send from the parent component to dispatch Modals
|
|
11246
|
+
* @param done - callback function to be called after the download has been initiated
|
|
11247
|
+
* @param Modal400 - Modal for 400 error
|
|
11248
|
+
* @param Modal403 - Modal for 403 error
|
|
11249
|
+
* @param customErrorMessage - custom message to be passed for 400 errors
|
|
11250
|
+
* @param hideNotification - hide the notification
|
|
11251
|
+
*/ const download = async ({ endpoint, params, method, dispatch, done, Modal400 = Modals.GeneralErrorModal, Modal403 = Modals.NoAccessModal, customErrorMessage, hideNotification = false })=>{
|
|
11252
|
+
const cookies = new Cookies();
|
|
11253
|
+
/* Create a cookie with a unique identifier to attach to request. Response from server will use the set-cookie header
|
|
11254
|
+
to remove the cookie when the response is received (aka the download starts). This will only work on when the FE and BE
|
|
11255
|
+
are on the same domain.
|
|
11256
|
+
*/ const downloadToken = uniqueId(`${+new Date()}-`);
|
|
11257
|
+
const cookieKey = navigator.cookieEnabled ? Math.abs(hashString(JSON.stringify(params) + downloadToken)).toString(16) : null;
|
|
11258
|
+
if (cookieKey) {
|
|
11259
|
+
cookies.set(cookieKey, downloadToken);
|
|
11260
|
+
}
|
|
11261
|
+
// place notification in timeout to avoid flicker on fast calls
|
|
11262
|
+
const showNotificationTimeout = setTimeout(()=>showNotification({
|
|
11263
|
+
message: /*#__PURE__*/ jsx(DownloadNotification, {
|
|
11264
|
+
onClick: ()=>{
|
|
11265
|
+
iFrame.remove();
|
|
11266
|
+
cleanNotifications();
|
|
11267
|
+
if (done) {
|
|
11268
|
+
done();
|
|
11269
|
+
}
|
|
11270
|
+
}
|
|
11271
|
+
}),
|
|
11272
|
+
styles: ()=>({
|
|
11273
|
+
root: {
|
|
11274
|
+
textAlign: 'center',
|
|
11275
|
+
display: hideNotification ? 'none' : 'block'
|
|
11276
|
+
},
|
|
11277
|
+
closeButton: {
|
|
11278
|
+
color: 'black',
|
|
11279
|
+
'&:hover': {
|
|
11280
|
+
backgroundColor: 'lightslategray'
|
|
11281
|
+
}
|
|
11282
|
+
}
|
|
11283
|
+
}),
|
|
11284
|
+
closeButtonProps: {
|
|
11285
|
+
'aria-label': 'Close notification'
|
|
11286
|
+
}
|
|
11287
|
+
}), 100); // set to 100 as that is perceived as instant
|
|
11288
|
+
const fields = reduce({
|
|
11289
|
+
...params,
|
|
11290
|
+
downloadCookieKey: cookieKey,
|
|
11291
|
+
downloadCookiePath: '/',
|
|
11292
|
+
attachment: true,
|
|
11293
|
+
...params.filename !== undefined ? {
|
|
11294
|
+
download: params.filename
|
|
11295
|
+
} : {}
|
|
11296
|
+
}, (result, value, key)=>{
|
|
11297
|
+
const paramValue = processParamObj(key, value);
|
|
11298
|
+
return result + [].concat(paramValue).reduce((acc, v)=>acc + toHtml(key, v), '');
|
|
11299
|
+
}, '');
|
|
11300
|
+
const iFrame = document.createElement('iframe');
|
|
11301
|
+
iFrame.style.display = 'none';
|
|
11302
|
+
iFrame.src = 'about:blank';
|
|
11303
|
+
// Appending to document body to allow navigation away from the current
|
|
11304
|
+
// page and downloads in the background
|
|
11305
|
+
document.body.appendChild(iFrame);
|
|
11306
|
+
const pollForDownloadResult = async ()=>{
|
|
11307
|
+
const executePoll = async (resolve)=>{
|
|
11308
|
+
// Request has been canceled
|
|
11309
|
+
const body = getBody(iFrame);
|
|
11310
|
+
if (body === undefined) {
|
|
11311
|
+
resolve();
|
|
11312
|
+
return;
|
|
11313
|
+
}
|
|
11314
|
+
const content = body?.textContent;
|
|
11315
|
+
// Download has started
|
|
11316
|
+
if (cookieKey !== null && !cookies.get(cookieKey)) {
|
|
11317
|
+
clearTimeout(showNotificationTimeout);
|
|
11318
|
+
cleanNotifications();
|
|
11319
|
+
if (done) {
|
|
11320
|
+
done();
|
|
11321
|
+
}
|
|
11322
|
+
resolve();
|
|
11323
|
+
} else {
|
|
11324
|
+
const iFrameHasContent = iFrame.contentWindow?.document.body;
|
|
11325
|
+
const requestError = iFrame.contentWindow?.document.getElementsByTagName('form').length === 0 && content !== '';
|
|
11326
|
+
if (iFrameHasContent && requestError) {
|
|
11327
|
+
clearTimeout(showNotificationTimeout);
|
|
11328
|
+
cleanNotifications();
|
|
11329
|
+
const errorMessage = /{"(?:message|error)":"([^"]*)"/g.exec(content ?? 'Undefined')?.[1];
|
|
11330
|
+
if (errorMessage === 'internal server error' || errorMessage === undefined) {
|
|
11331
|
+
dispatch(showModal({
|
|
11332
|
+
modal: Modal400,
|
|
11333
|
+
message: errorMessage
|
|
11334
|
+
}));
|
|
11335
|
+
} else if (errorMessage === 'Your token is invalid or expired. Please get a new token.') {
|
|
11336
|
+
dispatch(showModal({
|
|
11337
|
+
modal: Modal403,
|
|
11338
|
+
message: errorMessage
|
|
11339
|
+
}));
|
|
11340
|
+
} else {
|
|
11341
|
+
dispatch(showModal({
|
|
11342
|
+
modal: Modal400,
|
|
11343
|
+
message: customErrorMessage || errorMessage
|
|
11344
|
+
}));
|
|
11345
|
+
}
|
|
11346
|
+
if (done) {
|
|
11347
|
+
done();
|
|
11348
|
+
}
|
|
11349
|
+
resolve();
|
|
11350
|
+
} else {
|
|
11351
|
+
setTimeout(executePoll, 1000, resolve);
|
|
11352
|
+
}
|
|
11353
|
+
}
|
|
11354
|
+
};
|
|
11355
|
+
return new Promise(executePoll);
|
|
11356
|
+
};
|
|
11357
|
+
const addFormAndSubmit = ()=>{
|
|
11358
|
+
//do all of this together for FireFox support
|
|
11359
|
+
const form = document.createElement('form');
|
|
11360
|
+
form.method = method.toUpperCase();
|
|
11361
|
+
form.action = endpoint;
|
|
11362
|
+
form.innerHTML = fields;
|
|
11363
|
+
getBody(iFrame).appendChild(form);
|
|
11364
|
+
form.submit();
|
|
11365
|
+
};
|
|
11366
|
+
addFormAndSubmit();
|
|
11367
|
+
await pollForDownloadResult();
|
|
11368
|
+
iFrame.remove();
|
|
11369
|
+
};
|
|
11189
11370
|
|
|
11190
11371
|
const showErrorMessage = (error)=>{
|
|
11191
11372
|
showNotification({
|
|
@@ -19719,6 +19900,78 @@ border-solid
|
|
|
19719
19900
|
rounded-[7px]
|
|
19720
19901
|
`;
|
|
19721
19902
|
|
|
19903
|
+
/**
|
|
19904
|
+
* A Button component that downloads data from a given endpoint.
|
|
19905
|
+
* The component will handle all download logic including fetching
|
|
19906
|
+
* the data, creating the file, and downloading the file.
|
|
19907
|
+
* @param endpoint - The endpoint to download from.
|
|
19908
|
+
* @param disabled - Whether the button is disabled.
|
|
19909
|
+
* @param inactiveText - The text to display when the button is inactive.
|
|
19910
|
+
* @param activeText - The text to display when the button is active.
|
|
19911
|
+
* @param filename - The name of the file to download.
|
|
19912
|
+
* @param size - The size of the download.
|
|
19913
|
+
* @param format - The format of the download.
|
|
19914
|
+
* @param fields - The fields to download.
|
|
19915
|
+
* @param caseFilters - The case filters to download.
|
|
19916
|
+
* @param filters - The filters to download.
|
|
19917
|
+
* @param extraParams - Any extra parameters to download.
|
|
19918
|
+
* @param method - The method to use for the download.
|
|
19919
|
+
* @param customStyle - Any custom styles to apply to the button.
|
|
19920
|
+
* @param showLoading - Whether to show the loading icon.
|
|
19921
|
+
* @param showIcon - Whether to show the download icon.
|
|
19922
|
+
* @param preventClickEvent - Whether to prevent the default click event.
|
|
19923
|
+
* @param onClick - The function to call when the button is clicked.
|
|
19924
|
+
* @param setActive - The function to call when the button is set active.
|
|
19925
|
+
* @param active - Whether the button is active.
|
|
19926
|
+
* @param Modal403 - The modal to display when a 403 error occurs.
|
|
19927
|
+
* @param Modal400 - The modal to display when a 400 error occurs.
|
|
19928
|
+
* @param toolTip - The tooltip to display.
|
|
19929
|
+
* @category Buttons
|
|
19930
|
+
*/ const DownloadButton = /*#__PURE__*/ forwardRef(({ endpoint = '', disabled = false, inactiveText, activeText, params = {}, method = 'POST', customStyle, setActive, onClick, showLoading = true, showIcon = true, preventClickEvent = false, active, Modal400 = Modals.GeneralErrorModal, Modal403 = Modals.NoAccessModal, toolTip, ...buttonProps }, ref)=>{
|
|
19931
|
+
const text = active ? activeText : inactiveText;
|
|
19932
|
+
const dispatch = useCoreDispatch();
|
|
19933
|
+
const Icon = active ? /*#__PURE__*/ jsx(Loader, {
|
|
19934
|
+
size: "sm",
|
|
19935
|
+
className: "p-1"
|
|
19936
|
+
}) : /*#__PURE__*/ jsx(FiDownload, {
|
|
19937
|
+
title: "download",
|
|
19938
|
+
size: 16
|
|
19939
|
+
});
|
|
19940
|
+
return /*#__PURE__*/ jsx(Tooltip, {
|
|
19941
|
+
disabled: !toolTip,
|
|
19942
|
+
label: toolTip,
|
|
19943
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
19944
|
+
ref: ref,
|
|
19945
|
+
leftSection: showIcon && inactiveText && /*#__PURE__*/ jsx(FiDownload, {}),
|
|
19946
|
+
disabled: disabled,
|
|
19947
|
+
className: customStyle || `text-base-lightest ${disabled ? 'bg-base' : 'bg-primary hover:bg-primary-darker'} `,
|
|
19948
|
+
loading: showLoading && active,
|
|
19949
|
+
onClick: ()=>{
|
|
19950
|
+
if (!preventClickEvent && onClick) {
|
|
19951
|
+
onClick();
|
|
19952
|
+
return;
|
|
19953
|
+
}
|
|
19954
|
+
dispatch(hideModal());
|
|
19955
|
+
if (setActive) setActive(true);
|
|
19956
|
+
download({
|
|
19957
|
+
endpoint,
|
|
19958
|
+
params,
|
|
19959
|
+
method,
|
|
19960
|
+
dispatch,
|
|
19961
|
+
done: ()=>{
|
|
19962
|
+
if (setActive) setActive(false);
|
|
19963
|
+
},
|
|
19964
|
+
Modal400,
|
|
19965
|
+
Modal403
|
|
19966
|
+
});
|
|
19967
|
+
},
|
|
19968
|
+
...buttonProps,
|
|
19969
|
+
children: text || Icon
|
|
19970
|
+
})
|
|
19971
|
+
});
|
|
19972
|
+
});
|
|
19973
|
+
DownloadButton.displayName = 'DownloadButton';
|
|
19974
|
+
|
|
19722
19975
|
// Define theme for mantine v7
|
|
19723
19976
|
const createMantineTheme = (fonts, colors)=>{
|
|
19724
19977
|
const theme = createTheme({
|