From 629cb61234b0f0d8897841bf603d835dc84af027 Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Thu, 18 Jan 2024 15:11:51 -0500 Subject: [PATCH] :seedling: Refactor patternfly, i18n, and dayjs initialization (#1665) Refactoring: - Explicitly add `i18n` initialization on the root `index.tsx`. - Move `dayjs` initialization to its own file `dayjs.ts` referenced from `index.tsx`. This follows the `i18n` init style. - Move PF css includes from `App.tsx` to `index.tsx` Signed-off-by: Scott J Dickerson --- client/src/app/App.tsx | 3 --- client/src/app/dayjs.ts | 10 ++++++++++ client/src/index.tsx | 14 +++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 client/src/app/dayjs.ts diff --git a/client/src/app/App.tsx b/client/src/app/App.tsx index 6b7409777..3414477ed 100644 --- a/client/src/app/App.tsx +++ b/client/src/app/App.tsx @@ -5,9 +5,6 @@ import { AppRoutes } from "./Routes"; import { DefaultLayout } from "./layout"; import { NotificationsProvider } from "./components/NotificationsContext"; -import "@patternfly/patternfly/patternfly.css"; -import "@patternfly/patternfly/patternfly-addons.css"; - import "./app.css"; const App: React.FC = () => { diff --git a/client/src/app/dayjs.ts b/client/src/app/dayjs.ts new file mode 100644 index 000000000..a86cf31f9 --- /dev/null +++ b/client/src/app/dayjs.ts @@ -0,0 +1,10 @@ +import dayjs from "dayjs"; +import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; +import utc from "dayjs/plugin/utc"; +import timezone from "dayjs/plugin/timezone"; +import customParseFormat from "dayjs/plugin/customParseFormat"; + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(customParseFormat); +dayjs.extend(isSameOrBefore); diff --git a/client/src/index.tsx b/client/src/index.tsx index 29774a8cb..ce826f80d 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -1,3 +1,6 @@ +import "@patternfly/patternfly/patternfly.css"; +import "@patternfly/patternfly/patternfly-addons.css"; + import React from "react"; import ReactDOM from "react-dom"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; @@ -7,16 +10,9 @@ import ENV from "@app/env"; import App from "@app/App"; import reportWebVitals from "@app/reportWebVitals"; import { KeycloakProvider } from "@app/components/KeycloakProvider"; -import dayjs from "dayjs"; -import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; -import utc from "dayjs/plugin/utc"; -import timezone from "dayjs/plugin/timezone"; -import customParseFormat from "dayjs/plugin/customParseFormat"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(customParseFormat); -dayjs.extend(isSameOrBefore); +import "@app/dayjs"; +import "@app/i18n"; const queryClient = new QueryClient();