Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code splitting #8979

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"hi-profiles": "^1.1.0",
"i18next": "^23.11.4",
"i18next-browser-languagedetector": "^7.2.1",
"i18next-xhr-backend": "^3.2.2",
"lodash-es": "^4.17.21",
"postcss-loader": "^7.3.3",
"qrcode.react": "^3.1.0",
Expand Down Expand Up @@ -168,4 +169,4 @@
"node": ">=20.12.0"
},
"packageManager": "[email protected]"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions src/Locale/TRANSLATION_CONTRIBUTION.md

This file was deleted.

77 changes: 0 additions & 77 deletions src/Locale/update_locale.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/PluginEngine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import React, { Suspense } from "react";
import { SupportedPluginComponents, pluginMap } from "./pluginTypes";

import ErrorBoundary from "@/components/Common/ErrorBoundary";
import Loading from "./components/Common/Loading";

export default function PluginEngine({
children,
}: {
children: React.ReactNode;
}) {
return (
<Suspense fallback={<div>Loading plugins...</div>}>
<Suspense fallback={<Loading />}>
<ErrorBoundary
fallback={
<div className="flex h-screen w-screen items-center justify-center">
Expand Down
7 changes: 5 additions & 2 deletions src/Routers/SessionRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Login, ResetPassword } from "@/components/Auth";
import { lazy } from "react";
import { useRoutes } from "raviger";
import SessionExpired from "@/components/ErrorPages/SessionExpired";
import InvalidReset from "@/components/ErrorPages/InvalidReset";
import LicensesPage from "@/components/Licenses/LicensesPage";
import ResetPassword from "@/components/Auth/ResetPassword";

const LicensesPage = lazy(() => import("@/components/Licenses/LicensesPage"));
const Login = lazy(() => import("@/components/Auth/Login"));

const routes = {
"/": () => <Login />,
Expand Down
9 changes: 6 additions & 3 deletions src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import FiltersCache from "../../Utils/FiltersCache";
import { classNames } from "../../Utils/utils";
import BrowserWarning from "../ErrorPages/BrowserWarning";
import careConfig from "@careConfig";
import { Link } from "raviger";

export const Login = (props: { forgot?: boolean }) => {
const Login = (props: { forgot?: boolean }) => {
const { signIn } = useAuthContext();
const {
mainLogo,
Expand Down Expand Up @@ -247,14 +248,14 @@ export const Login = (props: { forgot?: boolean }) => {
{t("contribute_github")}
</a>
<span className="mx-2 text-primary-400">|</span>
<a
<Link
href="/licenses"
target="_blank"
rel="noopener noreferrer"
className="text-primary-400 hover:text-primary-500"
>
{t("third_party_software_licenses")}
</a>
</Link>
</div>
</div>
</div>
Expand Down Expand Up @@ -417,3 +418,5 @@ export const Login = (props: { forgot?: boolean }) => {
</div>
);
};

export default Login;
4 changes: 3 additions & 1 deletion src/components/Auth/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { validateRule } from "../Users/UserAdd";
import { validatePassword } from "@/common/validation";
import routes from "../../Redux/api";

export const ResetPassword = (props: any) => {
const ResetPassword = (props: any) => {
const initForm: any = {
password: "",
confirm: "",
Expand Down Expand Up @@ -169,3 +169,5 @@ export const ResetPassword = (props: any) => {
</div>
);
};

export default ResetPassword;
2 changes: 0 additions & 2 deletions src/components/Auth/index.tsx

This file was deleted.

30 changes: 20 additions & 10 deletions src/components/Common/FilePreviewDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import CircularProgress from "./components/CircularProgress";
import { useTranslation } from "react-i18next";
import { StateInterface } from "../Files/FileUpload";
import { Dispatch, ReactNode, SetStateAction, useState } from "react";
import {
Dispatch,
ReactNode,
SetStateAction,
useState,
lazy,
Suspense,
} from "react";
import CareIcon, { IconName } from "../../CAREUI/icons/CareIcon";
import ButtonV2, { Cancel } from "./components/ButtonV2";
import DialogModal from "./Dialog";
import PDFViewer from "./PDFViewer";

const PDFViewer = lazy(() => import("@/components/Common/PDFViewer"));

export const zoom_values = [
"scale-25",
Expand Down Expand Up @@ -135,14 +143,16 @@ const FilePreviewDialog = (props: FilePreviewProps) => {
} ${getRotationClass(file_state.rotation)}`}
/>
) : file_state.extension === "pdf" ? (
<PDFViewer
url={fileUrl}
onDocumentLoadSuccess={(numPages: number) => {
setPage(1);
setNumPages(numPages);
}}
pageNumber={page}
/>
<Suspense fallback={<CircularProgress />}>
<PDFViewer
url={fileUrl}
onDocumentLoadSuccess={(numPages: number) => {
setPage(1);
setNumPages(numPages);
}}
pageNumber={page}
/>
</Suspense>
) : previewExtensions.includes(file_state.extension) ? (
<iframe
sandbox=""
Expand Down
36 changes: 6 additions & 30 deletions src/components/Facility/Consultations/components/LinePlot.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
import ReactEchartsCore from "echarts-for-react/lib/core";
import { BarChart, LineChart } from "echarts/charts";
import {
DataZoomComponent,
GridComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
} from "echarts/components";
import { lazy } from "react";

import * as echarts from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { properRoundOf } from "../../../../Utils/utils";
echarts.use([
BarChart,
LineChart,
CanvasRenderer,
DataZoomComponent,
GridComponent,
LegendComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
]);

const ReactEcharts = lazy(
() => import("@/components/Facility/Consultations/components/ReactEcharts"),
);

export const LinePlot = (props: any) => {
const {
Expand Down Expand Up @@ -234,8 +211,7 @@ export const LinePlot = (props: any) => {
{value ? properRoundOf(value) : "NA"}
</span>
))}
<ReactEchartsCore
echarts={echarts}
<ReactEcharts
option={generalOptions}
className={props.classes}
lazyUpdate={props.type === "WAVEFORM"}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { EChartsReactProps } from "echarts-for-react";
import ReactEchartsCore from "echarts-for-react/lib/core";
import { BarChart, LineChart } from "echarts/charts";
import {
DataZoomComponent,
GridComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
} from "echarts/components";

import * as echarts from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([
BarChart,
LineChart,
CanvasRenderer,
DataZoomComponent,
GridComponent,
LegendComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
]);

interface ReactEchartsProps extends EChartsReactProps {
echarts?: any;
}

export default function ReactEcharts(props: ReactEchartsProps) {
if (!props.echarts) {
props.echarts = echarts;
}
return <ReactEchartsCore {...props} />;
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
import ReactEchartsCore from "echarts-for-react/lib/core";
import { BarChart, LineChart } from "echarts/charts";
import {
DataZoomComponent,
GridComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
} from "echarts/components";
import { lazy } from "react";

const ReactEcharts = lazy(
() => import("@/components/Facility/Consultations/components/ReactEcharts"),
);

import * as echarts from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([
BarChart,
LineChart,
CanvasRenderer,
DataZoomComponent,
GridComponent,
LegendComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
]);
const COLORS = ["#B13F3C", "#2F8B35", "#44327A", "#B19D3C"];

export const StackedLinePlot = (props: any) => {
Expand Down Expand Up @@ -108,5 +85,5 @@ export const StackedLinePlot = (props: any) => {
},
series: series,
};
return <ReactEchartsCore echarts={echarts} option={generalOptions} />;
return <ReactEcharts option={generalOptions} />;
};
Loading
Loading