feat(typings): Enhance typing support with withAppTypes and custom services throughout OHIF (#4090)

This commit is contained in:
Ibrahim authored and GitHub committed 2024-05-08 12:12:49 -04:00
1 parent b2cd0172d6
commit 374065bc3b
153 files changed
+842 -657

No files matched your search

+4 -5
View File
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef } from 'react';
import { useParams, useLocation, useNavigate } from 'react-router';
import PropTypes from 'prop-types';
import { ServicesManager, utils } from '@ohif/core';
import { utils } from '@ohif/core';
import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui';
import { useSearchParams } from '@hooks';
import { useAppConfig } from '@state';
@@ -21,7 +21,7 @@ export default function ModeRoute({
servicesManager,
commandsManager,
hotkeysManager,
}) {
}: withAppTypes) {
const [appConfig] = useAppConfig();
// Parse route params/querystring
@@ -60,9 +60,8 @@ export default function ModeRoute({
locationRef.current = location;
}
const { displaySetService, panelService, hangingProtocolService, userAuthenticationService } = (
servicesManager as ServicesManager
).services;
const { displaySetService, panelService, hangingProtocolService, userAuthenticationService } =
servicesManager.services;
const { extensions, sopClassHandlers, hotkeys: hotkeyObj, hangingProtocol } = mode;
@@ -16,7 +16,7 @@ const { sortingCriteria, getSplitParam } = utils;
* @returns array of subscriptions to cancel
*/
export async function defaultRouteInit(
{ servicesManager, studyInstanceUIDs, dataSource, filters, appConfig },
{ servicesManager, studyInstanceUIDs, dataSource, filters, appConfig }: withAppTypes,
hangingProtocolId
) {
const { displaySetService, hangingProtocolService, uiNotificationService, customizationService } =
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useMemo } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import PropTypes, { object } from 'prop-types';
import { Link, useNavigate } from 'react-router-dom';
import moment from 'moment';
import qs from 'query-string';
@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next';
import filtersMeta from './filtersMeta.js';
import { useAppConfig } from '@state';
import { useDebounce, useSearchParams } from '@hooks';
import { utils, hotkeys, ServicesManager } from '@ohif/core';
import { utils, hotkeys } from '@ohif/core';
import {
Icon,
@@ -56,7 +56,7 @@ function WorkList({
dataPath,
onRefresh,
servicesManager,
}) {
}: withAppTypes) {
const { hotkeyDefinitions, hotkeyDefaults } = hotkeysManager;
const { show, hide } = useModal();
const { t } = useTranslation();
@@ -585,7 +585,7 @@ WorkList.propTypes = {
getConfig: PropTypes.func,
}).isRequired,
isLoadingData: PropTypes.bool.isRequired,
servicesManager: PropTypes.instanceOf(ServicesManager),
servicesManager: PropTypes.object.isRequired,
};
const defaultFilterValues = {
+1 -1
View File
@@ -28,7 +28,7 @@ export default function buildModeRoutes({
servicesManager,
commandsManager,
hotkeysManager,
}) {
}: withAppTypes) {
const routes = [];
const dataSourceNames = [];
+1 -1
View File
@@ -88,7 +88,7 @@ const createRoutes = ({
hotkeysManager,
routerBasename,
showStudyList,
}) => {
}: withAppTypes) => {
const routes =
buildModeRoutes({
modes,