Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import addonTest from '@storybook/addon-vitest';
import { MswParameters } from 'msw-storybook-addon'
import { PreviewAddon } from 'storybook/internal/csf';
import { AppRoutes } from '../src/views/MainView';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import { SnackbarProvider } from 'notistack';
import { AuthContext, AuthContextState } from '../src/components/Auth';
import { expect, waitFor } from 'storybook/test';
Expand Down
6 changes: 6 additions & 0 deletions config/jest/windowEnvMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function replaceNonDeterministicValues(value) {
// react useId
fixed = fixed.replace(/"\_r\_[0-9a-z]+_/g, '"_r_XXXX_')

// aria-live description from ag-grid that doesn't always update the same
fixed = fixed.replace(/<div[^>]*aria-relevant="additions text"[^>\/]*(>[^/]*<\/div>|\/>)/, '');
// other generated ag-grid ids
fixed = fixed.replace(/id="cell-[^-"]+-[^-"]+"/, (matched) => matched.replaceAll(/\d+/g, 'XXXX'));
fixed = fixed.replace(/id="ag-\d+/, 'id="ag-XXXX');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need /g in these? or is the first match good enough?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

doesn't seem to make a difference but should have them regardless 3a10ae6


fixed = fixed.replaceAll(/class="([^"]+)"/g, (_, classnames) => {
const classes = Array.from(new Set(classnames.trim().split(' '))).map((name) => name.replace(/css\-[0-9a-zA-Z]+/g, 'css-XXXX')).sort().join(' ');
return `class="${classes}"`;
Expand Down
52 changes: 19 additions & 33 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react-dom": "^19.2.4",
"react-google-charts": "^3.0.15",
"react-query": "npm:@tanstack/react-query@^5.96.1",
"react-router-dom": "^6.22.2",
"react-router": "^7.14.2",
"slugify": "^1.4.0",
"typescript": "5.1",
"use-debounce": "^3.4.2",
Expand Down Expand Up @@ -104,14 +104,14 @@
"build": "vite build",
"build:ci": "vite build; vite build --mode staging; NODE_ENV=development vite build --mode development",
"compress": "tar cvfz v${npm_package_version}.tar.gz dist",
"test": "TZ=UTC vitest",
"test": "REACT_APP_VERSION=1.0.0 TZ=UTC vitest",
"test:ci": "npm run test --",
"lint": "eslint src --config .eslintrc.json --quiet",
"check-types": "tsc --noEmit --project ./tsconfig.check.json",
"serve": "NODE_ENV=development serve dist/development -s",
"commit": "git-cz",
"storybook": "TZ=UTC storybook dev -p 6006",
"build-storybook": "TZ=UTC storybook build"
"storybook": "REACT_APP_VERSION=1.0.0 TZ=UTC storybook dev -p 6006",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we make this dynamic, or is this = a default already?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this is to make it not dynamic for the tests

"build-storybook": "REACT_APP_VERSION=1.0.0 TZ=UTC storybook build"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SnackbarProvider } from 'notistack';
import React from 'react';
import { QueryClientProvider } from 'react-query';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router';

import { AuthProvider } from '@/components/Auth';
import api from '@/services/api';
Expand Down
14 changes: 4 additions & 10 deletions src/components/Auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
createContext, ReactNode, useContext, useEffect, useLayoutEffect, useMemo,
} from 'react';
import { useMutation } from 'react-query';
import { useNavigate } from 'react-router-dom';
import { Outlet, useNavigate } from 'react-router';

import api from '@/services/api';

Expand Down Expand Up @@ -154,18 +154,14 @@ const Centered = ({ children }: { children: ReactNode }) => (
);

interface AuthenticatedRouteProps {
component: React.ComponentType<any>;
componentProps?: any;
admin?: boolean;
signedLicenseRequired?: boolean;
}

const AuthenticatedRoute = (props: AuthenticatedRouteProps) => {
const AuthenticatedLayout = (props: AuthenticatedRouteProps) => {
const {
admin = false,
signedLicenseRequired = false,
component: Comp,
componentProps = {},
} = props;
const auth = useAuth();
const navigate = useNavigate();
Expand Down Expand Up @@ -218,15 +214,13 @@ const AuthenticatedRoute = (props: AuthenticatedRouteProps) => {
</Centered>
);
}
const cp = componentProps || {};

// eslint-disable-next-line react/jsx-props-no-spreading
return <Comp {...cp} />;
return <Outlet />;
};

export {
AuthContext,
AuthenticatedRoute,
AuthenticatedLayout,
AuthProvider,
useAuth,
};
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ exports[`WithGetLink snapshot 1`] = `
bob (#19:0)
</h4>
<a
data-discover="true"
href="/test"
target="_blank"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailChip/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import { expect, fn, screen } from 'storybook/test';

import preview from '#.storybook/preview';
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailChip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Typography,
} from '@mui/material';
import React, { useCallback, useState } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

interface DefaultPopupComponentProps<D extends object> {
/** description of object. Defaults to title of card if title is not present */
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailDrawer/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
render,
} from '@testing-library/react';
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router';
import {
afterEach, beforeEach, describe, expect, test, vi,
} from 'vitest';
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Typography,
} from '@mui/material';
import React, { ReactNode, useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

import { GeneralRecordType } from '@/components/types';
import schema from '@/services/schema';
Expand Down
2 changes: 1 addition & 1 deletion src/components/QueryResultsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
useEffect,
} from 'react';
import { useQuery } from 'react-query';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

import useGrid from '@/components/hooks/useGrid';
import api from '@/services/api';
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecordIdLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './index.scss';

import { OpenInNew } from '@mui/icons-material';
import React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

interface RecordIdLinkProps {
recordClass: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/StatementForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React, {
useCallback, useEffect, useMemo, useState,
} from 'react';
import { useMutation, useQuery } from 'react-query';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { Link, useNavigate, useParams } from 'react-router';

import ActionButton from '@/components/ActionButton';
import { useAuth } from '@/components/Auth';
Expand Down
2 changes: 1 addition & 1 deletion src/components/types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface TGeneralRecordType {
type: Partial<TGeneralRecordType> | string;
deprecated: boolean;
firstLoginAt: number;
signedLicenseAt: number;
signedLicenseAt: number | null;
lastLoginAt: number;
groups: string[] | Partial<TGeneralRecordType>[];
loginCount: number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/util.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as qs from 'qs';
import { NavigateFunction } from 'react-router-dom';
import { NavigateFunction } from 'react-router';

const CLASS_MODEL_PROP = '@class';

Expand Down
2 changes: 1 addition & 1 deletion src/services/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Handles miscellaneous tasks.
*/

import { NavigateFunction } from 'react-router-dom';
import { NavigateFunction } from 'react-router';

import { GeneralRecordType } from '@/components/types';
import config from '@/static/config';
Expand Down
Loading
Loading