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

Fix: UTC time to active importers #70

Merged
merged 8 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 12 additions & 0 deletions client/src/app/dayjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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";
import arraySupport from "dayjs/plugin/arraySupport";

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);
dayjs.extend(isSameOrBefore);
dayjs.extend(arraySupport);
12 changes: 10 additions & 2 deletions client/src/app/pages/importer-list/importer-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import dayjs from "dayjs";

import { Importer, ImporterType } from "@app/api/models";
import { ConfirmDialog } from "@app/components/ConfirmDialog";
Expand Down Expand Up @@ -250,14 +251,21 @@ export const ImporterList: React.FC = () => {
modifier="truncate"
{...getTdProps({ columnKey: "start" })}
>
{formatDate(item.report?.startDate)}
{item.state &&
configValues?.disabled == false &&
dayjs(item.report?.startDate)
.utc()
.format("YYYY-MM-DD HH:mm:ss")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea:

  • The current code in the main branch has a function formatDate() that can be reused everywhere.
  • what about having something like formatDateTime so we can reuse it too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlosthe19916,

Well I suppose this a question of reuse vs performance.
I'm not against a format function here but what's do we gain as the call to dayjs format is straightforward here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having formats in a single place will help us to change the formats in a single shot when needed. So far this is the only place where we use this format but in the case of formatDate if UX decides the format needs to change We will need to only change that function and the whole app will have the desired format rather than changing .format(ABCAD) in every single file

</Td>
<Td
width={15}
modifier="truncate"
{...getTdProps({ columnKey: "end" })}
>
{formatDate(item.report?.endDate)}
{configValues?.disabled == false &&
dayjs(item.report?.endDate)
.utc()
.format("YYYY-MM-DD HH:mm:ss")}
</Td>
<Td
width={10}
Expand Down
21 changes: 4 additions & 17 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import React from "react";

import { createRoot } from 'react-dom/client';
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import ENV from "@app/env";
import App from "@app/App";
import reportWebVitals from "@app/reportWebVitals";

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";
import arraySupport from "dayjs/plugin/arraySupport";

import "@app/dayjs";
import { OidcProvider } from "@app/components/OidcProvider";

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);
dayjs.extend(isSameOrBefore);
dayjs.extend(arraySupport);

const queryClient = new QueryClient();

const container = document.getElementById('root');
const root = createRoot(container!)
const container = document.getElementById("root");
const root = createRoot(container!);

const renderApp = () => {
return root.render(
Expand Down